Commit graph

282 commits

Author SHA1 Message Date
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
Paul
a0dcc61df2 Mouse Scroll Events - quibbles 2014-11-12 04:01:50 -08:00
Paul
796b2a7f2f Mouse Scroll Events - added support for WheelEvent, fixes
- Added support for the Wheel Event, which is the DOM3 spec.

- Wheel Scroll Event (old non-FF) and DOM Mouse Wheel (old FF) are
  supported via a non-exported reused wrapper object, WheelEventProxy.
  The proxy methods are generated one-time dynamically; future changes
  to the Mouse class (such as requiring an opt-in for mouse scroll events)
  could bypass secondary stub generation.

- FIX: Only ONE of the mouse wheel events is listened too, newest standard first.
  This fixes a bug in FF where it would use the default DOMMouseWheel.
2014-11-12 03:53:26 -08:00
photonstorm
1352b526c7 Merged final Pixi v2.1.0 release. 2014-11-11 23:24:50 +00:00
photonstorm
0a86a7ef51 Time.now can no longer be relied upon to contain a timestamp value. If the browser supports requestAnimationFrame then Time.now will contain the high resolution timer value that rAf generates. Otherwise it will contain the value of Date.now. If you require the actual time value (in milliseconds) then please use Time.time instead. Note that all Phaser sub-systems that used to rely on Time.now have been updated, so if you have any code that extends these please be sure to check it. 2014-11-08 20:01:10 +00:00
Richard Davey
f4237b3130 Merge pull request #1272 from pnstickne/wip-1246b
Button - bug fixes, issue #1246 (try number two)
2014-11-04 23:51:46 +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
Richard Davey
5a23b77ec9 Merge pull request #1257 from pnstickne/wip-1191
Input "enabled/disabled" API and documentation consistency updates
2014-11-02 12:12:19 +00:00
photonstorm
e57c700816 The Gamepad.addCallbacks context parameter was never actually remembered, causing the callbacks to run in the wrong context (thanks @englercj #1285) 2014-11-02 11:04:02 +00:00
Paul
2f460aaf8a Browser incompatibility fix - MAX_SAFE_INTEGER
- Number.MAX_SAFE_INTEGER is only defined in ES6 and not currently cross-browser
2014-11-01 09:50:28 -07: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
31061775d7 Pointe - removed extra whitespace 2014-11-01 01:25:01 -07:00
Paul
14002ca02d Pointer - minor documentation update for click trampolines 2014-11-01 01:11:26 -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
136af47064 Merge remote-tracking branch 'upstream/dev' into wip-1246b 2014-10-29 18:09:04 -07:00
Paul
5d04c62b33 Button - bug fixes, issue #1246
- Fix incorrect passing of "was clicked" to processInteractiveObjects
  - Button would not return to Over/Out state because of strict too check to catch `undefined`
  - Removed [undocumented] property usage from processInteractiveObjects and slight reformatting
  - Update Button state frames/sounds to remove duplication
  - Updated documentation in Button for consistency
2014-10-28 23:26:35 -07:00
Paul
2a933093d9 Comment fix
- Added `@private`
2014-10-28 22:47:44 -07:00
Paul
100b69eb99 Fix for Key.enabled issue #1190
- Added `enabled` getter; this resets the key (soft) and then disables they key
- Added `_enabled` property and updated internal usage
- Updated document for `reset`.
2014-10-28 22:45:30 -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
0430cf8a6a jsdoc fix 2014-10-23 12:27:07 +01:00
photonstorm
96fd0ade74 JSDoc fixes. 2014-10-21 22:43:42 +01: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
Bobby Wilson
0482684dc8 changed all typeof comparisons from == to === 2014-10-10 21:52:06 -06:00
Victor Bjelkholm
81c0a53ef2 Add PLUS and MINUS to list of keyboard keys 2014-10-03 20:59:29 +02:00
photonstorm
2ee50d0c29 InputHandler now uses localToGlobal conversion for scaled responsive layers. 2014-09-29 12:27:28 +01:00
photonstorm
319146292b First pass at scale handling on drag. Enable with: sprite.input.scaleLayer = true; 2014-09-25 17:01:27 +01:00
photonstorm
d18f523d93 jsdoc fixes. 2014-09-18 16:58:25 +01:00
photonstorm
20551f9129 Lots of jsdocs fixes ready for the new doc generator. 2014-09-16 17:35:08 +01:00
photonstorm
67f14713af Removed Gestures stuff as it was all commented-out anyway. 2014-09-05 01:07:16 +01:00
photonstorm
4d14119a57 Removed console.log. 2014-09-05 00:14:22 +01:00
photonstorm
d5ffe1f971 Phaser.Mouse will now add a listener to the window to detect mouseup events. This is used to detect if the player releases the mouse while outside of the game canvas. Previously Pointer objects incorrectly thought they were still pressed when you returned the mouse over the canvas (#1167) 2014-09-04 23:29:43 +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
Richard Davey
b08bfec372 Fixed Key jsdocs #1157 2014-08-31 19:05:31 +01:00
photonstorm
004deff508 Note: This commit will break all input, don't pull it down until I finish this work off later today please!
Moved the DOM offset from Stage to ScaleManager (a more logical location for it) and updated Pointer to use that.
Moved the Pointer offset check to look at the ScaleManager.
Used getBoundingClientRect(), will see if that works better than Phaser.Canvas.getOffset.
2014-08-31 12:17:07 +01:00
Dan Cox
46c8fe3a09 CocoonJS doesn't support mouse wheel
CocoonJS hasn't implemented the "DOMMouseScroll" and "mousewheel" events.
2014-08-29 22:45:52 -04:00
photonstorm
719b81c6e3 GamepadButton.justPressed and justReleased now correctly report if the button has just been pressed or released (thanks @padpadpad #1019) 2014-08-29 16:08:38 +01:00
photonstorm
7b9c1a561e GamePad and SinglePad onAxisCallback parameters have changed. You are now sent: this (a reference to the SinglePad that caused the callback), the axis index and the axis value in that order.
GamePad axis detection now works again properly in Firefox (#1035)
2014-08-29 15:55:05 +01:00
photonstorm
9055fc7e01 The Pointer move callbacks are now sent an extra parameter: fromClick allowing your callbacks to distinguish between the Pointer just moving, or moving as a result of being pressed down (thanks @iforce2d #1055) 2014-08-29 14:19:47 +01:00
photonstorm
dd9e7e6297 Pointer.dirty is a new boolean that is set by the InputHandler. It tells the Pointer to re-check all interactive objects it may be over on the next update, regardless if it has moved position or not. This helps solve issues where you may have a Button that on click generates a pop-up window that now obscures the Button (thanks @jflowers45 #882) 2014-08-29 00:47:49 +01:00
photonstorm
83619ba81e InputHandler docs updated to avoid Pointer data-type confusion (#1097) 2014-08-28 04:07:24 +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
ccc8369f43 InputHandler.checkBoundsRect was incorrectly assigning a property in Sprites fixed to the camera being dragged left (thanks @CraigBeswetherick #1093) 2014-08-28 01:29:23 +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
aabdf6f97a Resolves issue with pixel perfect click / over detection on Sprites that used trimmed image atlases for animations or frames > 0. 2014-08-01 17:46:51 +01:00
photonstorm
afeeeecbe0 Keyboard.processKeyPress now checks if the Keyboard Input handler is disabled or not before processing the key callbacks. 2014-07-16 00:12:59 +01:00
photonstorm
538425193a World.wrap when using the bounds of the object wouldn't adjust the bounds correctly, meaning wrapping outside the camera failed (thanks @jackrugile #1020) 2014-07-15 14:22:24 +01:00
photonstorm
64000dfcb6 Fixed small boolean check error. 2014-07-15 11:49:05 +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
Jeroen Verfallie
01a761b77f Fixed pixel perfect dragging, this was still using the old property 'pixelPerfect' instead of the new 'pixelPerfectClick' 2014-07-11 09:58:38 +02:00
photonstorm
2293b64c94 Removing debug / console.log output. 2014-07-09 05:49:13 +01:00
photonstorm
79bd7c400b Key.duration wasn't set to zero after a Key.reset (thanks @DrHackenstein, #932) 2014-07-01 16:57:55 +01:00
Richard Davey
de270908de Merge pull request #958 from renatodarrigo/patch-2
Fix rawpad button array to support win and linux
2014-07-01 15:59:06 +01:00
Wouter Commandeur
a863482439 Add constants for wheel up and down 2014-06-29 14:23:09 +02:00
Wouter Commandeur
7b8f08d5f9 appease travis 2014-06-29 13:49:45 +02:00
Wouter Commandeur
c716709f66 Add mouse wheel support 2014-06-29 13:45:39 +02:00
renatodarrigo
149016093c Fix rawpad button array to support win and linux
On Linux, rawpad button array doesn't get populated with GamepadButton objects, so I made a check to verify if it is an object or a number, then pass the correct value to appropriate function.

Also, uncommented the axischange lines.
2014-06-28 04:11:55 -03:00
Lewis Lane
187387126d Fix checkPointerDown method
checkPointerDown method was a verbatim duplication of checkPointerOver - added pointer.isDown check to passed pointer and altered wording of associated docs to make it clearer what the method is doing.
2014-06-22 23:03:15 +01:00
photonstorm
c0b34eddda Fixed PS3 mappings. 2014-06-11 14:37:58 +01:00
photonstorm
69525799d7 New build files for testing. 2014-06-11 12:46:49 +01:00
photonstorm
907ba55478 Huge number of gamepad updates to get it working properly on Chrome again. Firefox debugging tomorrow. 2014-06-11 04:25:30 +01:00
photonstorm
0587d944b3 Added PlayStation 3 controller button mappings to Phaser.Gamepad (thanks @wayfu #887) 2014-06-11 00:25:58 +01:00
JeanDavidDaviet
89f860ad46 Updated doc for Input#deleteMoveCallback 2014-06-04 20:36:56 +10:00
photonstorm
1d428a7ca4 Recoded Gamepad detection to stop it breaking on FF. 2014-06-02 00:48:44 +01:00
photonstorm
0c675f741f Wrapped all events that CocoonJS doesn't support in conditional checks to avoid Cocoon Warnings. 2014-05-29 22:25:40 +01:00
photonstorm
8d94b4a91c Swapped keypress callback order. 2014-05-27 11:32:18 +01:00
photonstorm
890d90af4d Keyboard.addCallbacks now has a new parameter for keypress event capture.
Keyboard.pressEvent stores the most recent DOM keypress event.
Keyboard.processKeyDown now runs the callback after all the objects have been created and/or updated.
Keyboard.processKeyUp now runs the callback after all the objects have been created and/or updated.
Phaser.Keyboard.lastChar will return the string value of the last key pressed.
Phaser.Keyboard.lastKey will return the most recently pressed Key object.
2014-05-27 04:26:37 +01:00
photonstorm
f007a77f3d Fixed Gamepad issue that incorrectly checked non-webkit prefix gamepads. 2014-05-26 22:02:53 +01:00
photonstorm
7b876d5fc4 ScaleManager.bounds is a Rectangle object that holds the exact size of the game canvas, taking DOM offset and game scale into account.
Pointer.withinGame is now accurate based on game scale and updated as the Pointer moves.
Stage.bounds is now updated if the game canvas offset changes position. Note that it gives the un-scaled game dimensions.
2014-05-19 18:49:59 +01:00
photonstorm
c9656e48de Group.hasProperty fixed to not use hasOwnProperty, but a series of in checks (thanks @mgiuffrida for the idea, #829) 2014-05-19 13:11:58 +01:00
Richard Davey
ee30dd634a Merge pull request #831 from woutercommandeur/dev
Add movement data for pointerlocked mouse
2014-05-19 11:48:25 +01:00
Wouter Commandeur
ce34da80c6 Only update movement when mouse is locked 2014-05-17 12:01:40 +02:00
Wouter Commandeur
e041eea968 whitespace adjustments 2014-05-17 11:32:11 +02:00