Commit graph

259 commits

Author SHA1 Message Date
photonstorm
157df30696 Pointer button handling has been given an overhaul. It has the following new boolean properties: leftButton, rightButton, middleButton, backButton, forwardButton and eraserButton. So you can now easily check which buttons are active and build right or middle click support into your games. The Pointer object normalises these properties for you, regardless if they came from a MouseEvent or PointerEvent (thanks @youssefdetovernickr for the idea #1848) 2015-07-07 16:53:56 +01:00
photonstorm
ab092c5c14 Keyboard.addKeys is a practical way to create an object containing user selected hotkeys. For example: addKeys( [Phaser.Keyboard.W, Phaser.Keyboard.S, Phaser.Keyboard.A, Phaser.Keyboard.D], [ 'up', 'down', 'left', 'right' ] ); would return an object containing the properties up, down, left and right that you could poll just like a Phaser.Key object. (thanks @Mourtz #1857) 2015-07-02 14:15:06 +01:00
Richard Davey
755a247e31 Merge pull request #1857 from Mourtz/master
Implemented Keyboard.AddKeys function.
2015-07-02 13:54:18 +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
Alex Mourtziapis
7252666e9a fixed minor jshint warnings. 2015-06-15 04:35:06 +03:00
Alex Mourtziapis
9d16e3e9a0 Update Keyboard.js 2015-06-15 04:33:40 +03:00
Alex Mourtziapis
4cc3777d36 Fixed some Travis CI errors. 2015-06-15 00:41:37 +03:00
Alex Mourtziapis
565d8e6e4a Implemented Keyboard.AddKeys function. 2015-06-14 23:35:38 +03:00
photonstorm
2b0abb67dd onDragUpdate is a new signal that is dispatched whenever a Game object enabled for input and drag is moved by a pointer (i.e. during a drag event). See the Phaser.InputHandler.enableDrag docs for parameter details and the new Phaser Example. 2015-06-04 20:58:00 +01:00
photonstorm
fcb2dc8306 Added snapPoint value (currently unused) 2015-05-26 20:01:57 +01:00
photonstorm
5278c16acc Swapped to using touchlock object. 2015-05-05 17:03:27 +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
f265f98eb4 Input.Touch.addTouchLockCallback allows you to add a callback that will be invoked automatically upon a touchstart event. This is used internally by the SoundManager and Video objects to handle mobile device unlocking, but is exposed publicly as well. 2015-05-05 16:24:49 +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
b645b277aa jsdoc fix. 2015-04-27 16:22:36 +01:00
photonstorm
8bca406889 Console update. 2015-04-13 11:58:44 +01:00
photonstorm
67039df214 jsdoc fixes. 2015-03-27 10:47:25 +00:00
photonstorm
ca752cc59c jsdoc updates. 2015-03-23 08:13:59 +00:00
photonstorm
5a9b509b44 ArraySet.removeAll allows you to remove all members of an ArraySet and optionally call destroy on them as well.
GameObject.input.dragStartPoint now stores the coordinates the object was at when the drag started. This value is populated when the drag starts. It can be used to return an object to its pre-drag position, for example if it was dropped in an invalid place in-game.
2015-03-19 00:51:13 +00: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
8483eac6aa Removing all use of _cache from all Game Objects. 2015-02-16 17:22:51 +00:00
photonstorm
9670c8aa86 InputHandler.enableDrag with a boundsRect set now takes into account the Sprites anchor when limiting the drag (thanks @unindented #1593)
InputHandler.enableDrag with a boundsSprite set now takes into account both the Sprites anchor and the boundsSprite anchor when limiting the drag.
2015-02-16 15:49:46 +00:00
photonstorm
ae198e9364 InputHandler was using the wrong property in checkBoundsSprite when fixedToCamera (thanks @yig #1613) 2015-02-14 19:10:06 +00:00
photonstorm
aa2df803b7 Pointer.stop would call event.preventDefault if Pointer._stateReset was true, which is always true after a State has changed and before Pointer.start has been called. However this broken interacting with DOM elements in the case where the State changes and you immediately try to use the DOM element without first having clicked on the Phaser game. An additional guard was added so preventDefault will now only be called if both _stateReste and Pointer.withinGame are true (thanks @satan6 #1509) 2015-02-11 16:03:24 +00:00
photonstorm
c891d617d9 Swapped back to 2.2.2 expected setting. 2015-02-08 21:57:09 +00:00
photonstorm
9cdcdc7bc5 Device.touch checks if window.navigator.maxTouchPoints is >= 1 rather than > 1, which now allows touch events to work properly in Chrome mobile emulation. 2015-02-05 06:12:20 +00:00
photonstorm
5bd231d532 JSDoc fixes. 2015-02-05 05:13:22 +00:00
photonstorm
8dec37107e MSPointer.capture allows you to optionally event.preventDefault the pointer events (was previously always on)
MSPointer.event now stores the most recent pointer event.
MSPointer.pointerDownCallback, pointerMoveCallback and pointerUpCallback all allow you to set your own event based callbacks.
2015-02-05 05:12:00 +00:00
photonstorm
f55ba6755f jsdoc fix 2015-02-03 21:32:39 +00:00
photonstorm
3eba508382 Sprite.events.onDragStart has 2 new parameters x and y which is the position of the Sprite before the drag was started. The full list of parameters is: (sprite, pointer, x, y). This allows you to retain the position of the Sprite prior to dragging should dragFromCenter have been enabled (thanks @vulvulune #1583) 2015-02-03 21:32:39 +00:00
Richard Davey
a2854d21fd Merge pull request #1580 from integricho/fix#1551
fix #1551 - detect mouseup on tilesprites
2015-02-03 21:16:33 +00:00
photonstorm
7003b65df6 Added missing properties to the InputHandler prototype, reducing hidden class modifications. 2015-02-03 20:28:18 +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
photonstorm
c1eb456ed2 Mouse.mouseMoveCallback is flagged as deprecated. 2015-01-02 04:14:44 +00:00
Richard Davey
81f356c235 Merge pull request #1386 from pnstickne/wip-docs-1130
Assorted documentation/consistency updates
2014-12-01 12:07:10 +00:00
Paul
d15037e283 Event-Signal object count optimization
There are a bunch of signals added for Sprites; more when input is
enabled. However, very few of these signals are ever actually used. While
the previous performance update related to Signals addressed the size of
each Signal object, this update is to reduce the number of Signal objects
as used by the Events type.

As a comparison the "Particle: Random Sprite" demo creates 3200+ Signals;
with this change there less than 70 signals created when running the same
demo. (Each Event creates at 8 signals by default, and there is an Event
for each of the 400 particles.) While this is an idealized scenario, a
huge amount (of albeit small) object reduction should be expected.

It does this by creating a signal proxy property getter and a signal
dispatch proxy. When the event property (eg. `onEvent`) is accessed a new
Signal object is created (and cached in `_onEvent`) as required. This
ensures that no user code has to perform an existance-check on the event
property first: it just continues to use the signal property as normal.

When the Phaser game code needs to dispatch the event it uses
`event.onEvent$dispath(..)` instead of `event.onEvent.dispatch(..)`. This
special auto-generated method automatically takes care of checking for if
the Signal has been created and only dispatches the event if this is the
case. (If the game code used the `onEvent` property itself the event
deferal approach would be defeated.)

This approach is designed to require minimal changes, not negatively
affect performance, and reduce the number of Signal objects and
corresponding Signal/Event resource usage.

The only known user-code change is that code can add to signal (eg.
onInput) events even when input is not enabled - this will allow some
previously invalid code run without throwing an exception.
2014-11-30 21:39:25 -08: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
photonstorm
c4b81ff6ea jsdoc fixes. 2014-11-25 00:24:28 +00:00
photonstorm
69b57073f2 Added missing duration parameter. 2014-11-20 21:19:09 +00:00
photonstorm
7e4a494f13 Keyboard.justPressed has bee renamed to Keyboard.downDuration which is a much clearer name for what the method actually does.
Keyboard.justReleased has bee renamed to Keyboard.upDuration which is a much clearer name for what the method actually does.
Keyboard.downDuration, Keyboard.upDuration and Keyboard.isDown now all return `null` if the Key wasn't found in the local keys array.
2014-11-20 20:55:51 +00:00
Geoff Gaudreault
dbde5ee913 Keyboard.js does not reflect Phaser.Key changes
Calling justPressed or justReleased on Phaser.Keyboard throws an exception. Changed to reflect new method names in Phaser.Key

I imagine you'd want these methods renamed as well, but it appears to be called by a few other classes and I didn't want a huge pull-request.
2014-11-20 11:23:43 -08:00
Richard Davey
5fa06a241b Merge pull request #1325 from pnstickne/wip-collections
ArrayList/LinkedList updates
2014-11-16 18:54:24 +00:00
photonstorm
527934d909 Key.justPressed has bee renamed to Key.downDuration which is a much clearer name for what the method actually does. See Key.justDown for a nice clean alternative.
Key.justReleased has bee renamed to Key.upDuration which is a much clearer name for what the method actually does. See Key.justUp for a nice clean alternative.
Key.justDown allows you to test if a Key has just been pressed down or not. You can only call justDown once per key press. It will only return `true` once, until the Key is released and pressed down again. This allows you to use it in situations where you want to check if this key is down without using a Signal, such as in a core game loop (thanks @pjbaron #1321)
Key.justUp allows you to test if a Key has just been released or not. You can only call justUp once per key press. It will only return `true` once, until the Key is pressed down and released again. This allows you to use it in situations where you want to check if this key is up without using a Signal, such as in a core game loop (thanks @pjbaron #1321)
2014-11-13 13:01:58 +00:00
Richard Davey
5dc6a8a8c5 Merge pull request #1321 from pjbaron/dev
justDown property indicates if a key has been newly pressed since last time you checked
2014-11-13 12:39:24 +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
Pete Baron
d1a8ecf3e6 Added justDown access to _justDown internal boolean. Records whether the key has been pressed since the last time it was checked. Resets to false only when it is read. Used for anything that needs to know when a key is first pressed with no autorepeat, without using closures or callbacks. 2014-11-13 18:34:36 +13:00
Paul
7004d68cbd Mouse Scroll Events - device separation
- The wheel event type is now determined in by Device

- The various input checking in Device have been moved to a new function
2014-11-12 13:24:03 -08:00