Commit graph

84 commits

Author SHA1 Message Date
Richard Davey
0d90f75b5f Splitting the dev branch up into versions. 2016-11-22 01:36:56 +00:00
Richard Davey
89885dcb7c Refactored the Input Manager. 2016-11-10 00:10:39 +00:00
photonstorm
1e15012a91 PIXI.CanvasPool has been moved into the Phaser utils folder, and renamed to Phaser.CanvasPool. All references to PIXI.CanvasPool have been updated to match the new namespace. 2016-09-28 12:53:04 +01:00
photonstorm
c64749fef2 Added missing properties. 2016-06-09 14:54:39 +01:00
photonstorm
92d3a5efa8 Adds a callback that is fired every time 'Pointer.processInteractiveObjects' is called.
The purpose of `processInteractiveObjects` is to work out which Game Object the Pointer is going to
interact with. It works by polling all of the valid game objects, and then slowly discounting those
 that don't meet the criteria (i.e. they aren't under the Pointer, are disabled, invisible, etc).

Eventually a short-list of 'candidates' is created. These are all of the Game Objects which are valid
for input and overlap with the Pointer. If you need fine-grained control over which of the items is
selected then you can use this callback to do so.

The callback will be sent 3 parameters:

1) A reference to the Phaser.Pointer object that is processing the Items.
2) An array containing all potential interactive candidates. This is an array of `InputHandler` objects, not Sprites.
3) The current 'favorite' candidate, based on its priorityID and position in the display list.

Your callback MUST return one of the candidates sent to it.
2016-06-09 14:49:10 +01:00
photonstorm
9649f714bb InputHandler.checkPointerDown and checkPointerOver will now test the worldTransform scale property of a Sprite. If zero it will fast return, where-as before it would incorrectly report an up event (thanks @jaapaurelio #2466) 2016-05-11 12:25:35 +01:00
photonstorm
16378713b4 JSDocs update (#249) 2016-04-27 12:57:41 +01:00
photonstorm
f40cfbe2ae 2015 - 2016. 2016-04-04 22:16:16 +01:00
Paul
31e5202eff Fixes #2062 and forward-support for pointer modes
Impact:
  - *none for touch devices*
  - *low* / 'expected behavior' for mouse devices

Adds a PointerMode enumeration value for better simple input
discrimination in the future.

The added Button#justReleasedPreventsOver controls if a just-release event
on a pointer prevents it from being able to trigger an over event.

The default value is PointerMode.CONTACT which means this 'release guard'
applies only to touch inputs.

It should fix #2062 as Mouse (PointerMode.CURSOR) input is not caught in the default.

Also expands Button#forceOut to accept a PointerMode value such that it
can be controlled per-input mode.

This is a configurable partial revert of a possibly rogue commit in 2.1.3
and the behavior persists through 2.4.3.
2015-09-22 01:12:43 -07:00
photonstorm
50516e3d34 Testing CanvasPool. 2015-08-03 14:33:12 +01:00
photonstorm
f15fe6706c All undefined argument checks were changed from if (typeof x === 'undefined') to if (x === undefined) removing the typeof check and saving some bytes across the codebase in the process. 2015-07-22 10:37:15 +01:00
photonstorm
cf74eaa396 MSPointer now checks the pointerType property of the DOM event and if it matches 'mouse' it will update Input.mousePointer, rather than Input.pointer1 (or whatever the next free Pointer was). 2015-07-20 14:01:21 +01:00
photonstorm
a19479d948 jsdocs update. 2015-07-07 16:58:41 +01:00
photonstorm
102c74e121 Deprecated the following:
* Camera.screenView
* ScaleManager.maxIterations
* ScaleManager.enterPortrait (see onOrientationChange)
* ScaleManager.enterLandscape (see onOrientationChange)
* ScaleManager.enterFullScreen (see onFullScreenChange)
* ScaleManager.leaveFullScreen (see onFullScreenChange)
* ScaleManager.fullScreenFailed (see onFullScreenError)
* ScaleManager.checkResize
* ScaleManager.checkOrientation
* ScaleManager.setScreenSize (see updateLayout)
* ScaleManager.setSize (see reflowCanvas)
* ScaleManager.checkOrientationState (see reflowCanvas)
* ScaleManager.orientation (see screenOrientation)
* Gamepad.disabled (see enabled)
* Input.currentPointers (see totalActivePointers)
* Input.disabled (see enabled)
* Keyboard.disabled (see enabled)
* Mouse.disabled (see enabled)
* Mouse.mouseMoveCallback (see Input.addMoveCallback)
* MSPointer.disabled (see enabled)
* Touch.disabled (see enabled)
* Cache.getUrl (see getURL)
* Math.truncate (see Math.trunc)
* Math.snapToInArray (see Phaser.ArrayUtils.findClosest)
* Math.interpolateFloat (see Math.linear)
* Math.normalizeLatitude (use Phaser.Math.clamp(lat, -90, 90))
* Math.normalizeLongitude (use Phaser.Math.wrap(lng, -180, 180))
* Math.chanceRoll (use Phaser.Utils.chanceRoll)
* Math.numberArray (use Phaser.ArrayUtils.numberArray)
* Math.numberArrayStep (use Phaser.ArrayUtils.numberArrayStep)
* Math.limitValue (use Phaser.Math.clamp)
* Math.randomSign (use Phaser.Utils.randomChoice(-1, 1))
* Math.angleLimit (use Phaser.Math.clamp)
* Math.getRandom (use Phaser.ArrayUtils.getRandomItem)
* Math.removeRandom (use Phaser.ArrayUtils.removeRandomItem)
* Math.floor (use Math.trunc)
* Math.ceil (use Phaser.Math.roundAwayFromZero)
* Math.shift (use Phaser.ArrayUtils.rotate)
* Math.shuffleArray (use Phaser.ArrayUtils.shuffle)
* Math.distanceRounded (do the rounding locally)
* Canvas.getOffset (see Phaser.DOM.getOffset)
* Canvas.getAspectRatio (see Phaser.DOM.getAspectRatio)
* TilemapLayer.tileColor (use TilemapLayer.debugSettings.missingImageFill)
* Phaser.ArrayList alias removed, now use Phaser.ArraySet
* Utils.transposeArray (see Phaser.ArrayUtils.transposeMatrix)
* Utils.rotateArray (see Phaser.ArrayUtils.rotateMatrix)
* Utils.shuffle (see Phaser.ArrayUtils.shuffle)
2015-06-17 03:14:31 +01:00
photonstorm
4a91d97812 Input.addMoveCallback used to return the index of the callback entry in the internal moveCallbacks array. However as callbacks were removed the indexes became invalid, potentially causing a future Input.deleteMoveCallback to remove the wrong callback entirely or error. Input.deleteMoveCallback now takes the original callback and context as its parameters to ensure deletion safety. 2015-05-05 16:53:02 +01:00
photonstorm
f032578f27 Removed Input.moveCallback and Input.moveCallbackContext as neither are used any longer. Use Input.addMoveCallback. 2015-05-05 16:09:22 +01:00
photonstorm
8bca406889 Console update. 2015-04-13 11:58:44 +01:00
photonstorm
a69e53f901 Copyright date change. 2015-02-25 03:36:23 +00:00
photonstorm
f613e5882e Allowed Keyboard and Gamepad to be optional. 2015-02-19 05:00:41 +00:00
photonstorm
5bd231d532 JSDoc fixes. 2015-02-05 05:13:22 +00:00
Andrean Franc
b52b765c53 fix #1551 - detect mouseup on tilesprites 2015-01-28 19:31:36 +01:00
photonstorm
d6ea8fb956 jsdoc updates (spelling mistakes, code formatting, etc) 2015-01-28 17:18:33 +00:00
Paul
dab8772de0 Documentation - consistency updates
- Updated `readOnly` doclet to `readonly`

- `array` refined to `type[]`, where such information was immediately
determinable.

- Updated {Any}/{*} to {any}; {...*} is standard exception

- Udated {Object} to {object}
2014-11-30 04:03:35 -08:00
photonstorm
a012d8caa2 jsdoc update 2014-11-29 19:40:50 +00:00
Paul
aa3c21ade7 ArraySet/LinkedList - minor updates
- Renamed ArrayList to ArraySet
  - Added ArrayList is a deprecated proxy for compatibility
  - Updated internal code to use ArraySet

- ArraySet can be constructed with an array; if the caller is willing to
  accept some responsibility this can remove the O(n^2) behavior of
  repeatedly calling `add`.
  - Updated Group.filter to take advantage of this

- ArraySet.total is read-only proxy for for list.length

- Fixes ArraySet.setAll where it would only set properties with truthy
  values

- Updated documentation
2014-11-13 01:41:08 -08:00
photonstorm
1352b526c7 Merged final Pixi v2.1.0 release. 2014-11-11 23:24:50 +00:00
Richard Davey
a4870a7e62 Merge pull request #1283 from pnstickne/wip-pointer-mgmt
Input - Minor Pointer refactor and documentation updates
2014-11-02 12:24:50 +00:00
photonstorm
30159691fa Fixed onClickTrampoline jsdocs. 2014-11-02 12:20:19 +00:00
Richard Davey
21a47faaed Merge pull request #1282 from pnstickne/wip-trampoline-click
Click Trampolines - support to trampoline pointer events into 'click' events
2014-11-02 12:15:37 +00:00
Paul
5ec14929de Input - Minor Pointer refactor and documentation updates
- `pointerN` are aliases to backed `pointers[N-1]` array.
  This simplifies (and increases the efficiency of) looping through all the pointers when applicable; also eliminates pointer-existance checks
  Removes various hard-coded limits (added MAX_POINTERS); changed `maxPointers` default
- Removed some special-casing from cases where it did not matter
- Removed `=== false/true`, `==` usage for consistency, changed missing value check to `typeof`, etc.
- Updated documentation for specificty; added `@public\@protected`
- `@deprecated` currentPointers due to odd set pattern; `totalCurrentPointers` is more appropriate.
2014-11-01 09:45:12 -07:00
Paul
3005419435 Click Trampolines - support to trampoline pointer events into 'click' events
- This is needed to support Fullscreen on IE11 because IE only trusts 'click' events for this operation; click trampolines as a general solution, although they are only required in some "special" cases.
2014-11-01 01:04:17 -07:00
Paul
84363d9f36 Updated documentation per current Phaser tag usage 2014-10-28 21:46:33 -07:00
Paul
9a16448021 API / documentation consistency updates
- The `disabled` property of various input classes has been inverted to `enabled`.
  Direct/internal usage of `disabled` has been transformed to `!enabled`.
- A `disabled` get/set property has been added to wrap `enabled`, and marked as @deprecated
  This ensures current API compatibility.
2014-10-26 17:25:03 -07:00
photonstorm
b580746cb8 Input.hitTest now accurately detects hits on the extreme edges of a display object (thanks InsaneHero) 2014-10-20 14:28:09 +01:00
photonstorm
6b2dbed96b Fixed Input.getLocalPosition.
Updated Input.hitTest so it supports Phaser.Graphics objects.
2014-10-20 01:25:58 +01:00
photonstorm
35d29170d0 Lots of small jsdoc fixes and DocGen updates. 2014-10-20 00:54:56 +01:00
photonstorm
67f14713af Removed Gestures stuff as it was all commented-out anyway. 2014-09-05 01:07:16 +01:00
photonstorm
5fb8c7eb85 ScaleManager window.resize handler would constantly dispatch enterPortrait and enterLandscape events on window resizing, regardless if it actually entered that orientation or not.
Stage.offset has been moved to ScaleManager.offset
Stage.bounds has been removed, you can access it via Stage.getBounds.
Stage.checkOffsetInterval has been moved to ScaleManager.trackParentInterval
ScaleManager.hasResized signal has been removed. Use ScaleManager.setResizeCallback instead.
2014-09-01 01:02:48 +01:00
photonstorm
ec687868de Input.setMoveCallback has been removed due to deprecation.
BitmapData.refreshBuffer has been removed and replaced with BitmapData.update.
BitmapData.drawSprite has been removed due to deprecation. Use BitmapData.draw instead.
Pointer.moveCallback has been removed due to deprecation.
SinglePad.addButton has been removed due to deprecation.
P2.Body.loadData has been removed due to deprecation.
P2.World.defaultFriction and defaultRestitution have been removed due to deprecation.
Canvas.create noCocoon parameter has been removed due to deprecation.
Color.getColorInfo, RGBtoHexstring, RGBtoWebstring and colorToHexstring has been removed due to deprecation.
2014-08-28 03:40:59 +01:00
photonstorm
6e2cd37776 ScaleManager.destroy now removes the window and document event listeners, which are no longer created anonymously (thanks @eguneys #1092)
Input.Gamepad.destroy now destroys all connected SinglePads and clears event listeners.
SinglePad.destroy now clears all associated GamepadButton objects and signals.
2014-08-28 03:31:47 +01:00
photonstorm
33c52eaf09 BitmapData alpha option added.
Pointer return type added.
pixi manifest updated to remove need for geom classes.
2014-08-27 21:26:29 +01:00
photonstorm
f78a527ad5 Prevented objects with pixel perfect checks from over-riding other higher priority ID items (#983)
Rebuilt the way items are polled for Pointer events (drag, click, move). Now faster and more efficient, especially when some items in the stack require pixel perfect checks.
2014-07-15 11:20:57 +01:00
JeanDavidDaviet
89f860ad46 Updated doc for Input#deleteMoveCallback 2014-06-04 20:36:56 +10:00
photonstorm
5d8a11ae29 Input.addMoveCallback allows you to bind as many callbacks as you like to the DOM move events (Input.setMoveCallback is now flagged as deprecated)
Input.deleteMoveCallback will remove a previously set movement event callback.
2014-05-14 03:01:24 +01:00
photonstorm
c94e842c75 InputManager.minPriorityID lets you set the minimum priority level an object needs to be to be checked by a Pointer. Useful for UI layer stacking. 2014-05-07 00:11:28 +01:00
photonstorm
ad7e2aff1f Input.getPointerFromId will return a pointer with a matching pointerId value, if any. pointerId is a value set by the browser in the DOM event. 2014-05-02 12:21:57 +01:00
photonstorm
4466b3cd5d Input.getPointerFromIdentifier docs update to reflect where the identifier comes from. Pointer properties now set to give it fixed defaults (thanks @JirkaDellOro, #793) 2014-05-01 23:35:40 +01:00
photonstorm
54b71ddc23 Phaser.ArrayList is a new iterative object, similar in principal to a linked list but operating on a single array without modifying the object structure.
Input and Pointer now use the new ArrayList instead of a LinkedList, which resolve list item removable during callback issues.
Input.reset no longer resets every interactive item it knows of, because they are removed during the destroy phase and can now persist between States if needed.
2014-04-25 15:11:54 +01:00
photonstorm
a7f6165e39 InputManager.resetLocked - If the Input Manager has been reset locked then all calls made to InputManager.reset, such as from a State change, are ignored.
Keyboard.reset has a new `hard` parameter which controls the severity of the reset. A soft reset doesn't remove any callbacks or event listeners.
Key.reset has a new `hard` parameter which controls the severity of the reset. A soft reset doesn't remove any callbacks or event listeners.
2014-04-14 21:53:08 +01:00
Christian Wesselhoeft
61f18b675c Trim trailing whitespace. 2014-03-25 14:56:04 -07:00