2013-08-31 12:54:59 +00:00
/ * *
2013-10-01 12:54:29 +00:00
* @ author Richard Davey < rich @ photonstorm . com >
* @ copyright 2013 Photon Storm Ltd .
* @ license { @ link https : //github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
* /
/ * *
* Phaser - Pointer constructor .
2013-08-31 12:54:59 +00:00
*
2013-10-01 12:54:29 +00:00
* @ class Phaser . Pointer
* @ classdesc A Pointer object is used by the Mouse , Touch and MSPoint managers and represents a single finger on the touch screen .
* @ constructor
* @ param { Phaser . Game } game - A reference to the currently running game .
* @ param { Description } id - Description .
2013-08-31 12:54:59 +00:00
* /
2013-08-31 20:50:34 +00:00
Phaser . Pointer = function ( game , id ) {
2013-08-31 12:54:59 +00:00
2013-10-02 14:05:55 +00:00
/ * *
* @ property { Phaser . Game } game - Local reference to game .
* /
this . game = game ;
/ * *
* @ property { Description } id - Description .
* /
this . id = id ;
2013-09-10 19:40:34 +00:00
/ * *
2013-10-01 12:54:29 +00:00
* Local private variable to store the status of dispatching a hold event .
2013-10-01 15:39:39 +00:00
* @ property { boolean } _holdSent
2013-09-10 19:40:34 +00:00
* @ private
2013-10-01 12:54:29 +00:00
* @ default
2013-09-10 19:40:34 +00:00
* /
this . _holdSent = false ;
/ * *
2013-10-01 12:54:29 +00:00
* Local private variable storing the short - term history of pointer movements .
* @ property { array } _history
2013-09-10 19:40:34 +00:00
* @ private
* /
this . _history = [ ] ;
/ * *
* Local private variable storing the time at which the next history drop should occur
2013-10-01 12:54:29 +00:00
* @ property { number } _lastDrop
2013-09-10 19:40:34 +00:00
* @ private
2013-10-01 12:54:29 +00:00
* @ default
2013-09-10 19:40:34 +00:00
* /
this . _nextDrop = 0 ;
2013-10-01 12:54:29 +00:00
/ * *
* Monitor events outside of a state reset loop .
2013-10-01 15:39:39 +00:00
* @ property { boolean } _stateReset
2013-10-01 12:54:29 +00:00
* @ private
* @ default
* /
2013-09-10 19:40:34 +00:00
this . _stateReset = false ;
/ * *
* A Vector object containing the initial position when the Pointer was engaged with the screen .
2013-10-01 12:54:29 +00:00
* @ property { Vec2 } positionDown
* @ default
2013-09-10 19:40:34 +00:00
* * /
this . positionDown = null ;
/ * *
* A Vector object containing the current position of the Pointer on the screen .
2013-10-01 12:54:29 +00:00
* @ property { Vec2 } position
* @ default
2013-09-10 19:40:34 +00:00
* * /
this . position = null ;
/ * *
* A Circle object centered on the x / y screen coordinates of the Pointer .
2013-10-01 12:54:29 +00:00
* Default size of 44 px ( Apple ' s recommended "finger tip" size ) .
* @ property { Circle } circle
* @ default
2013-09-10 19:40:34 +00:00
* * /
this . circle = null ;
/ * *
2013-10-01 12:54:29 +00:00
* Description .
2013-10-01 15:39:39 +00:00
* @ property { boolean } withinGame
2013-09-10 19:40:34 +00:00
* /
this . withinGame = false ;
/ * *
2013-10-01 12:54:29 +00:00
* The horizontal coordinate of point relative to the viewport in pixels , excluding any scroll offset .
* @ property { number } clientX
* @ default
2013-09-10 19:40:34 +00:00
* /
this . clientX = - 1 ;
/ * *
2013-10-01 12:54:29 +00:00
* The vertical coordinate of point relative to the viewport in pixels , excluding any scroll offset .
* @ property { number } clientY
* @ default
2013-09-10 19:40:34 +00:00
* /
this . clientY = - 1 ;
/ * *
2013-10-01 12:54:29 +00:00
* The horizontal coordinate of point relative to the viewport in pixels , including any scroll offset .
* @ property { number } pageX
* @ default
2013-09-10 19:40:34 +00:00
* /
this . pageX = - 1 ;
/ * *
2013-10-01 12:54:29 +00:00
* The vertical coordinate of point relative to the viewport in pixels , including any scroll offset .
* @ property { number } pageY
* @ default
2013-09-10 19:40:34 +00:00
* /
this . pageY = - 1 ;
/ * *
2013-10-01 12:54:29 +00:00
* The horizontal coordinate of point relative to the screen in pixels .
* @ property { number } screenX
* @ default
2013-09-10 19:40:34 +00:00
* /
this . screenX = - 1 ;
/ * *
2013-10-01 12:54:29 +00:00
* The vertical coordinate of point relative to the screen in pixels .
* @ property { number } screenY
* @ default
2013-09-10 19:40:34 +00:00
* /
this . screenY = - 1 ;
/ * *
* The horizontal coordinate of point relative to the game element . This value is automatically scaled based on game size .
2013-10-01 12:54:29 +00:00
* @ property { number } x
* @ default
2013-09-10 19:40:34 +00:00
* /
this . x = - 1 ;
/ * *
* The vertical coordinate of point relative to the game element . This value is automatically scaled based on game size .
2013-10-01 12:54:29 +00:00
* @ property { number } y
* @ default
2013-09-10 19:40:34 +00:00
* /
this . y = - 1 ;
/ * *
2013-10-01 12:54:29 +00:00
* If the Pointer is a mouse this is true , otherwise false .
2013-10-01 15:39:39 +00:00
* @ property { boolean } isMouse
* @ type { boolean }
2013-10-01 12:54:29 +00:00
* /
2013-09-10 19:40:34 +00:00
this . isMouse = false ;
/ * *
2013-10-01 12:54:29 +00:00
* If the Pointer is touching the touchscreen , or the mouse button is held down , isDown is set to true .
2013-10-01 15:39:39 +00:00
* @ property { boolean } isDown
2013-10-01 12:54:29 +00:00
* @ default
* /
2013-09-10 19:40:34 +00:00
this . isDown = false ;
/ * *
2013-10-01 12:54:29 +00:00
* If the Pointer is not touching the touchscreen , or the mouse button is up , isUp is set to true .
2013-10-01 15:39:39 +00:00
* @ property { boolean } isUp
2013-10-01 12:54:29 +00:00
* @ default
* /
2013-09-10 19:40:34 +00:00
this . isUp = true ;
/ * *
* A timestamp representing when the Pointer first touched the touchscreen .
2013-10-01 12:54:29 +00:00
* @ property { number } timeDown
* @ default
* /
2013-09-10 19:40:34 +00:00
this . timeDown = 0 ;
/ * *
* A timestamp representing when the Pointer left the touchscreen .
2013-10-01 12:54:29 +00:00
* @ property { number } timeUp
* @ default
* /
2013-09-10 19:40:34 +00:00
this . timeUp = 0 ;
/ * *
2013-10-01 12:54:29 +00:00
* A timestamp representing when the Pointer was last tapped or clicked .
* @ property { number } previousTapTime
* @ default
* /
2013-09-10 19:40:34 +00:00
this . previousTapTime = 0 ;
/ * *
2013-10-01 12:54:29 +00:00
* The total number of times this Pointer has been touched to the touchscreen .
* @ property { number } totalTouches
* @ default
* /
2013-09-10 19:40:34 +00:00
this . totalTouches = 0 ;
/ * *
2013-10-01 12:54:29 +00:00
* The number of miliseconds since the last click .
* @ property { number } msSinceLastClick
* @ default
* /
2013-09-10 19:40:34 +00:00
this . msSinceLastClick = Number . MAX _VALUE ;
/ * *
* The Game Object this Pointer is currently over / touching / dragging .
2013-10-01 12:54:29 +00:00
* @ property { Any } targetObject
* @ default
* /
2013-09-10 19:40:34 +00:00
this . targetObject = null ;
2013-10-01 12:54:29 +00:00
/ * *
* Description .
2013-10-01 15:39:39 +00:00
* @ property { boolean } isDown - Description .
2013-10-01 12:54:29 +00:00
* @ default
* /
2013-08-31 12:54:59 +00:00
this . active = false ;
2013-10-01 12:54:29 +00:00
/ * *
* Description
* @ property { Phaser . Point } position
* /
2013-08-31 12:54:59 +00:00
this . position = new Phaser . Point ( ) ;
2013-10-01 12:54:29 +00:00
/ * *
* Description
* @ property { Phaser . Point } positionDown
* /
2013-08-31 12:54:59 +00:00
this . positionDown = new Phaser . Point ( ) ;
2013-10-01 12:54:29 +00:00
/ * *
* Description
* @ property { Phaser . Circle } circle
* /
2013-08-31 12:54:59 +00:00
this . circle = new Phaser . Circle ( 0 , 0 , 44 ) ;
if ( id == 0 )
{
this . isMouse = true ;
}
} ;
2013-08-31 20:50:34 +00:00
Phaser . Pointer . prototype = {
2013-08-31 12:54:59 +00:00
/ * *
2013-10-01 12:54:29 +00:00
* Called when the Pointer is pressed onto the touchscreen .
2013-10-02 14:05:55 +00:00
* @ method Phaser . Pointer # start
2013-08-31 12:54:59 +00:00
* @ param { Any } event
* /
start : function ( event ) {
this . identifier = event . identifier ;
this . target = event . target ;
2013-10-11 19:02:12 +00:00
if ( typeof event . button !== 'undefined' )
2013-08-31 12:54:59 +00:00
{
this . button = event . button ;
}
// Fix to stop rogue browser plugins from blocking the visibility state event
2013-09-10 19:40:34 +00:00
if ( this . game . paused == true && this . game . stage . scale . incorrectOrientation == false )
{
this . game . paused = false ;
return this ;
}
2013-08-31 12:54:59 +00:00
this . _history . length = 0 ;
this . active = true ;
this . withinGame = true ;
this . isDown = true ;
this . isUp = false ;
// Work out how long it has been since the last click
this . msSinceLastClick = this . game . time . now - this . timeDown ;
this . timeDown = this . game . time . now ;
this . _holdSent = false ;
// This sets the x/y and other local values
this . move ( event ) ;
// x and y are the old values here?
this . positionDown . setTo ( this . x , this . y ) ;
2013-09-04 20:03:39 +00:00
if ( this . game . input . multiInputOverride == Phaser . Input . MOUSE _OVERRIDES _TOUCH || this . game . input . multiInputOverride == Phaser . Input . MOUSE _TOUCH _COMBINE || ( this . game . input . multiInputOverride == Phaser . Input . TOUCH _OVERRIDES _MOUSE && this . game . input . currentPointers == 0 ) )
2013-08-31 12:54:59 +00:00
{
2013-11-01 02:07:21 +00:00
this . game . input . x = this . x ;
this . game . input . y = this . y ;
2013-08-31 12:54:59 +00:00
this . game . input . position . setTo ( this . x , this . y ) ;
2013-10-24 03:27:28 +00:00
this . game . input . onDown . dispatch ( this , event ) ;
2013-08-31 12:54:59 +00:00
this . game . input . resetSpeed ( this . x , this . y ) ;
}
this . _stateReset = false ;
this . totalTouches ++ ;
if ( this . isMouse == false )
{
this . game . input . currentPointers ++ ;
}
if ( this . targetObject !== null )
{
2013-09-08 21:38:19 +00:00
this . targetObject . _touchedHandler ( this ) ;
2013-08-31 12:54:59 +00:00
}
return this ;
} ,
2013-10-01 12:54:29 +00:00
/ * *
* Description .
2013-10-02 14:05:55 +00:00
* @ method Phaser . Pointer # update
2013-10-01 12:54:29 +00:00
* /
2013-08-31 12:54:59 +00:00
update : function ( ) {
if ( this . active )
{
if ( this . _holdSent == false && this . duration >= this . game . input . holdRate )
{
2013-09-04 20:03:39 +00:00
if ( this . game . input . multiInputOverride == Phaser . Input . MOUSE _OVERRIDES _TOUCH || this . game . input . multiInputOverride == Phaser . Input . MOUSE _TOUCH _COMBINE || ( this . game . input . multiInputOverride == Phaser . Input . TOUCH _OVERRIDES _MOUSE && this . game . input . currentPointers == 0 ) )
2013-08-31 12:54:59 +00:00
{
this . game . input . onHold . dispatch ( this ) ;
}
this . _holdSent = true ;
}
// Update the droppings history
if ( this . game . input . recordPointerHistory && this . game . time . now >= this . _nextDrop )
{
this . _nextDrop = this . game . time . now + this . game . input . recordRate ;
this . _history . push ( {
x : this . position . x ,
y : this . position . y
} ) ;
if ( this . _history . length > this . game . input . recordLimit )
{
this . _history . shift ( ) ;
}
}
}
} ,
/ * *
* Called when the Pointer is moved
2013-10-02 14:05:55 +00:00
* @ method Phaser . Pointer # move
2013-08-31 12:54:59 +00:00
* @ param { Any } event
* /
move : function ( event ) {
if ( this . game . input . pollLocked )
{
return ;
}
2013-10-11 19:02:12 +00:00
if ( typeof event . button !== 'undefined' )
2013-08-31 12:54:59 +00:00
{
this . button = event . button ;
}
this . clientX = event . clientX ;
this . clientY = event . clientY ;
this . pageX = event . pageX ;
this . pageY = event . pageY ;
this . screenX = event . screenX ;
this . screenY = event . screenY ;
this . x = ( this . pageX - this . game . stage . offset . x ) * this . game . input . scale . x ;
this . y = ( this . pageY - this . game . stage . offset . y ) * this . game . input . scale . y ;
this . position . setTo ( this . x , this . y ) ;
this . circle . x = this . x ;
this . circle . y = this . y ;
2013-09-04 20:03:39 +00:00
if ( this . game . input . multiInputOverride == Phaser . Input . MOUSE _OVERRIDES _TOUCH || this . game . input . multiInputOverride == Phaser . Input . MOUSE _TOUCH _COMBINE || ( this . game . input . multiInputOverride == Phaser . Input . TOUCH _OVERRIDES _MOUSE && this . game . input . currentPointers == 0 ) )
2013-08-31 12:54:59 +00:00
{
this . game . input . activePointer = this ;
this . game . input . x = this . x ;
this . game . input . y = this . y ;
this . game . input . position . setTo ( this . game . input . x , this . game . input . y ) ;
this . game . input . circle . x = this . game . input . x ;
this . game . input . circle . y = this . game . input . y ;
}
// If the game is paused we don't process any target objects
if ( this . game . paused )
{
return this ;
}
// Easy out if we're dragging something and it still exists
2013-09-08 21:38:19 +00:00
if ( this . targetObject !== null && this . targetObject . isDragged == true )
2013-08-31 12:54:59 +00:00
{
2013-09-08 21:38:19 +00:00
if ( this . targetObject . update ( this ) == false )
2013-08-31 12:54:59 +00:00
{
this . targetObject = null ;
}
return this ;
}
// Work out which object is on the top
this . _highestRenderOrderID = - 1 ;
2013-09-08 16:39:23 +00:00
this . _highestRenderObject = null ;
2013-08-31 12:54:59 +00:00
this . _highestInputPriorityID = - 1 ;
2013-09-08 12:23:21 +00:00
// Just run through the linked list
2013-09-08 21:38:19 +00:00
if ( this . game . input . interactiveItems . total > 0 )
2013-09-08 12:23:21 +00:00
{
var currentNode = this . game . input . interactiveItems . next ;
2013-09-08 21:38:19 +00:00
2013-09-08 12:23:21 +00:00
do
{
2013-09-21 12:07:06 +00:00
// If the object is using pixelPerfect checks, or has a higher InputManager.PriorityID OR if the priority ID is the same as the current highest AND it has a higher renderOrderID, then set it to the top
if ( currentNode . pixelPerfect || currentNode . priorityID > this . _highestInputPriorityID || ( currentNode . priorityID == this . _highestInputPriorityID && currentNode . sprite . renderOrderID > this . _highestRenderOrderID ) )
2013-09-08 12:23:21 +00:00
{
2013-09-08 21:38:19 +00:00
if ( currentNode . checkPointerOver ( this ) )
{
// console.log('HRO set', currentNode.sprite.name);
this . _highestRenderOrderID = currentNode . sprite . renderOrderID ;
this . _highestInputPriorityID = currentNode . priorityID ;
this . _highestRenderObject = currentNode ;
}
2013-09-08 12:23:21 +00:00
}
currentNode = currentNode . next ;
}
2013-09-08 21:38:19 +00:00
while ( currentNode != null )
2013-08-31 12:54:59 +00:00
}
2013-09-08 16:39:23 +00:00
if ( this . _highestRenderObject == null )
2013-08-31 12:54:59 +00:00
{
2013-09-08 16:39:23 +00:00
// The pointer isn't currently over anything, check if we've got a lingering previous target
if ( this . targetObject )
2013-08-31 12:54:59 +00:00
{
2013-09-08 21:38:19 +00:00
// console.log("The pointer isn't currently over anything, check if we've got a lingering previous target");
2013-09-08 16:39:23 +00:00
this . targetObject . _pointerOutHandler ( this ) ;
2013-08-31 12:54:59 +00:00
this . targetObject = null ;
}
}
else
{
if ( this . targetObject == null )
{
// And now set the new one
2013-09-08 21:38:19 +00:00
// console.log('And now set the new one');
2013-09-08 16:39:23 +00:00
this . targetObject = this . _highestRenderObject ;
this . _highestRenderObject . _pointerOverHandler ( this ) ;
2013-08-31 12:54:59 +00:00
}
else
{
// We've got a target from the last update
2013-09-08 21:38:19 +00:00
// console.log("We've got a target from the last update");
2013-09-08 16:39:23 +00:00
if ( this . targetObject == this . _highestRenderObject )
2013-08-31 12:54:59 +00:00
{
// Same target as before, so update it
2013-09-08 21:38:19 +00:00
// console.log("Same target as before, so update it");
2013-09-08 16:39:23 +00:00
if ( this . _highestRenderObject . update ( this ) == false )
2013-08-31 12:54:59 +00:00
{
this . targetObject = null ;
}
}
else
{
// The target has changed, so tell the old one we've left it
2013-09-08 21:38:19 +00:00
// console.log("The target has changed, so tell the old one we've left it");
2013-09-08 16:39:23 +00:00
this . targetObject . _pointerOutHandler ( this ) ;
2013-08-31 12:54:59 +00:00
// And now set the new one
2013-09-08 16:39:23 +00:00
this . targetObject = this . _highestRenderObject ;
this . targetObject . _pointerOverHandler ( this ) ;
2013-08-31 12:54:59 +00:00
}
}
}
return this ;
} ,
/ * *
2013-10-01 12:54:29 +00:00
* Called when the Pointer leaves the target area .
2013-10-02 14:05:55 +00:00
* @ method Phaser . Pointer # leave
2013-08-31 12:54:59 +00:00
* @ param { Any } event
* /
leave : function ( event ) {
this . withinGame = false ;
this . move ( event ) ;
} ,
/ * *
2013-10-01 12:54:29 +00:00
* Called when the Pointer leaves the touchscreen .
2013-10-02 14:05:55 +00:00
* @ method Phaser . Pointer # stop
2013-08-31 12:54:59 +00:00
* @ param { Any } event
* /
stop : function ( event ) {
if ( this . _stateReset )
{
event . preventDefault ( ) ;
return ;
}
this . timeUp = this . game . time . now ;
2013-09-04 20:03:39 +00:00
if ( this . game . input . multiInputOverride == Phaser . Input . MOUSE _OVERRIDES _TOUCH || this . game . input . multiInputOverride == Phaser . Input . MOUSE _TOUCH _COMBINE || ( this . game . input . multiInputOverride == Phaser . Input . TOUCH _OVERRIDES _MOUSE && this . game . input . currentPointers == 0 ) )
2013-08-31 12:54:59 +00:00
{
2013-10-24 03:27:28 +00:00
this . game . input . onUp . dispatch ( this , event ) ;
2013-08-31 12:54:59 +00:00
// Was it a tap?
if ( this . duration >= 0 && this . duration <= this . game . input . tapRate )
{
// Was it a double-tap?
if ( this . timeUp - this . previousTapTime < this . game . input . doubleTapRate )
{
// Yes, let's dispatch the signal then with the 2nd parameter set to true
this . game . input . onTap . dispatch ( this , true ) ;
}
else
{
// Wasn't a double-tap, so dispatch a single tap signal
this . game . input . onTap . dispatch ( this , false ) ;
}
this . previousTapTime = this . timeUp ;
}
}
// Mouse is always active
if ( this . id > 0 )
{
this . active = false ;
}
this . withinGame = false ;
this . isDown = false ;
this . isUp = true ;
if ( this . isMouse == false )
{
this . game . input . currentPointers -- ;
}
2013-09-08 21:38:19 +00:00
if ( this . game . input . interactiveItems . total > 0 )
2013-08-31 12:54:59 +00:00
{
2013-09-08 16:39:23 +00:00
var currentNode = this . game . input . interactiveItems . next ;
do
2013-08-31 12:54:59 +00:00
{
2013-09-08 21:38:19 +00:00
if ( currentNode )
{
currentNode . _releasedHandler ( this ) ;
}
2013-09-08 16:39:23 +00:00
currentNode = currentNode . next ;
2013-08-31 12:54:59 +00:00
}
2013-09-08 21:38:19 +00:00
while ( currentNode != null )
2013-08-31 12:54:59 +00:00
}
if ( this . targetObject )
{
2013-09-08 16:39:23 +00:00
this . targetObject . _releasedHandler ( this ) ;
2013-08-31 12:54:59 +00:00
}
this . targetObject = null ;
return this ;
} ,
/ * *
2013-10-01 12:54:29 +00:00
* The Pointer is considered justPressed if the time it was pressed onto the touchscreen or clicked is less than justPressedRate .
2013-10-02 14:05:55 +00:00
* @ method Phaser . Pointer # justPressed
2013-10-01 12:54:29 +00:00
* @ param { number } [ duration ]
2013-10-01 15:39:39 +00:00
* @ return { boolean }
2013-08-31 12:54:59 +00:00
* /
justPressed : function ( duration ) {
2013-09-08 16:39:23 +00:00
duration = duration || this . game . input . justPressedRate ;
2013-08-31 12:54:59 +00:00
return ( this . isDown === true && ( this . timeDown + duration ) > this . game . time . now ) ;
} ,
/ * *
2013-10-01 12:54:29 +00:00
* The Pointer is considered justReleased if the time it left the touchscreen is less than justReleasedRate .
2013-10-02 14:05:55 +00:00
* @ method Phaser . Pointer # justReleased
2013-10-01 12:54:29 +00:00
* @ param { number } [ duration ]
2013-10-01 15:39:39 +00:00
* @ return { boolean }
2013-08-31 12:54:59 +00:00
* /
justReleased : function ( duration ) {
2013-09-08 16:39:23 +00:00
duration = duration || this . game . input . justReleasedRate ;
2013-08-31 12:54:59 +00:00
return ( this . isUp === true && ( this . timeUp + duration ) > this . game . time . now ) ;
} ,
/ * *
* Resets the Pointer properties . Called by InputManager . reset when you perform a State change .
2013-10-02 14:05:55 +00:00
* @ method Phaser . Pointer # reset
2013-08-31 12:54:59 +00:00
* /
reset : function ( ) {
if ( this . isMouse == false )
{
this . active = false ;
}
this . identifier = null ;
this . isDown = false ;
this . isUp = true ;
this . totalTouches = 0 ;
this . _holdSent = false ;
this . _history . length = 0 ;
this . _stateReset = true ;
2013-09-08 16:39:23 +00:00
if ( this . targetObject )
2013-08-31 12:54:59 +00:00
{
2013-09-08 16:39:23 +00:00
this . targetObject . _releasedHandler ( this ) ;
2013-08-31 12:54:59 +00:00
}
this . targetObject = null ;
} ,
/ * *
* Returns a string representation of this object .
2013-10-02 14:05:55 +00:00
* @ method Phaser . Pointer # toString
2013-10-01 12:54:29 +00:00
* @ return { string } A string representation of the instance .
2013-08-31 12:54:59 +00:00
* * /
toString : function ( ) {
return "[{Pointer (id=" + this . id + " identifer=" + this . identifier + " active=" + this . active + " duration=" + this . duration + " withinGame=" + this . withinGame + " x=" + this . x + " y=" + this . y + " clientX=" + this . clientX + " clientY=" + this . clientY + " screenX=" + this . screenX + " screenY=" + this . screenY + " pageX=" + this . pageX + " pageY=" + this . pageY + ")}]" ;
}
} ;
2013-10-01 12:54:29 +00:00
/ * *
* How long the Pointer has been depressed on the touchscreen . If not currently down it returns - 1.
2013-10-02 14:05:55 +00:00
* @ name Phaser . Pointer # duration
* @ property { number } duration - How long the Pointer has been depressed on the touchscreen . If not currently down it returns - 1.
* @ readonly
2013-10-01 12:54:29 +00:00
* /
2013-08-31 20:50:34 +00:00
Object . defineProperty ( Phaser . Pointer . prototype , "duration" , {
2013-08-31 12:54:59 +00:00
get : function ( ) {
if ( this . isUp )
{
return - 1 ;
}
return this . game . time . now - this . timeDown ;
2013-09-11 12:21:07 +00:00
}
2013-08-31 12:54:59 +00:00
} ) ;
2013-10-01 12:54:29 +00:00
/ * *
2013-10-02 14:05:55 +00:00
* Gets the X value of this Pointer in world coordinates based on the world camera .
* @ name Phaser . Pointer # worldX
* @ property { number } duration - The X value of this Pointer in world coordinates based on the world camera .
* @ readonly
* /
2013-08-31 20:50:34 +00:00
Object . defineProperty ( Phaser . Pointer . prototype , "worldX" , {
2013-08-31 12:54:59 +00:00
get : function ( ) {
2013-09-08 21:38:19 +00:00
return this . game . world . camera . x + this . x ;
2013-08-31 12:54:59 +00:00
2013-09-11 12:21:07 +00:00
}
2013-08-31 12:54:59 +00:00
} ) ;
2013-10-01 12:54:29 +00:00
/ * *
2013-10-02 14:05:55 +00:00
* Gets the Y value of this Pointer in world coordinates based on the world camera .
* @ name Phaser . Pointer # worldY
* @ property { number } duration - The Y value of this Pointer in world coordinates based on the world camera .
* @ readonly
* /
2013-08-31 20:50:34 +00:00
Object . defineProperty ( Phaser . Pointer . prototype , "worldY" , {
2013-08-31 12:54:59 +00:00
get : function ( ) {
2013-09-08 21:38:19 +00:00
return this . game . world . camera . y + this . y ;
2013-08-31 12:54:59 +00:00
2013-09-11 12:21:07 +00:00
}
2013-08-31 12:54:59 +00:00
} ) ;