phaser/docs/Pointer.js.html

1308 lines
38 KiB
HTML
Raw Normal View History

2013-10-02 14:05:55 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Phaser Source: input/Pointer.js</title>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
</head>
<body>
<div class="container-fluid">
<div class="navbar navbar-fixed-top navbar-inverse">
<div class="navbar-inner">
<a class="brand" href="index.html">Phaser</a>
<ul class="nav">
<li class="dropdown">
<a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b
2013-10-02 14:05:55 +00:00
class="caret"></b></a>
<ul class="dropdown-menu ">
2014-04-10 22:13:43 +00:00
<li class="class-depth-0">
<a href="Phaser.html">Phaser</a>
2013-10-02 14:05:55 +00:00
</li>
</ul>
</li>
<li class="dropdown">
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
class="caret"></b></a>
<ul class="dropdown-menu ">
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-02 14:05:55 +00:00
<a href="Phaser.Animation.html">Animation</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.AnimationManager.html">AnimationManager</a>
2013-10-02 14:05:55 +00:00
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.AnimationParser.html">AnimationParser</a>
2013-10-02 14:05:55 +00:00
</li>
2014-04-29 14:39:02 +00:00
<li class="class-depth-1">
<a href="Phaser.ArrayList.html">ArrayList</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-11-28 15:57:09 +00:00
<a href="Phaser.BitmapData.html">BitmapData</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.BitmapText.html">BitmapText</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Button.html">Button</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.Cache.html">Cache</a>
2013-10-02 14:05:55 +00:00
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.Camera.html">Camera</a>
2013-10-02 14:05:55 +00:00
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.Canvas.html">Canvas</a>
2013-10-02 14:05:55 +00:00
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.Circle.html">Circle</a>
2013-10-02 14:05:55 +00:00
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.Color.html">Color</a>
2013-10-03 00:21:08 +00:00
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.Device.html">Device</a>
2013-10-02 14:05:55 +00:00
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.Easing.html">Easing</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-2">
<a href="Phaser.Easing.Back.html">Back</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-2">
<a href="Phaser.Easing.Bounce.html">Bounce</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-2">
<a href="Phaser.Easing.Circular.html">Circular</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-2">
<a href="Phaser.Easing.Cubic.html">Cubic</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-2">
<a href="Phaser.Easing.Elastic.html">Elastic</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-2">
<a href="Phaser.Easing.Exponential.html">Exponential</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-2">
<a href="Phaser.Easing.Linear.html">Linear</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-2">
<a href="Phaser.Easing.Quadratic.html">Quadratic</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-2">
<a href="Phaser.Easing.Quartic.html">Quartic</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-2">
<a href="Phaser.Easing.Quintic.html">Quintic</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-2">
<a href="Phaser.Easing.Sinusoidal.html">Sinusoidal</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.Ellipse.html">Ellipse</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Events.html">Events</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-11-28 15:57:09 +00:00
<a href="Phaser.Filter.html">Filter</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.Frame.html">Frame</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.FrameData.html">FrameData</a>
2013-10-03 00:21:08 +00:00
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-02 14:05:55 +00:00
<a href="Phaser.Game.html">Game</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.GameObjectCreator.html">GameObjectCreator</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.GameObjectFactory.html">GameObjectFactory</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2014-02-05 06:29:17 +00:00
<a href="Phaser.Gamepad.html">Gamepad</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2014-02-05 06:29:17 +00:00
<a href="Phaser.GamepadButton.html">GamepadButton</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Graphics.html">Graphics</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-02 14:05:55 +00:00
<a href="Phaser.Group.html">Group</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.Image.html">Image</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-02 14:05:55 +00:00
<a href="Phaser.Input.html">Input</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-02 14:05:55 +00:00
<a href="Phaser.InputHandler.html">InputHandler</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-02 14:05:55 +00:00
<a href="Phaser.Key.html">Key</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-02 14:05:55 +00:00
<a href="Phaser.Keyboard.html">Keyboard</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2014-02-05 06:29:17 +00:00
<a href="Phaser.Line.html">Line</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-02 14:05:55 +00:00
<a href="Phaser.LinkedList.html">LinkedList</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-02 14:05:55 +00:00
<a href="Phaser.Loader.html">Loader</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.LoaderParser.html">LoaderParser</a>
2013-10-02 14:05:55 +00:00
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-02 14:05:55 +00:00
<a href="Phaser.Math.html">Math</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-02 14:05:55 +00:00
<a href="Phaser.Mouse.html">Mouse</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-02 14:05:55 +00:00
<a href="Phaser.MSPointer.html">MSPointer</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-02 19:18:24 +00:00
<a href="Phaser.Net.html">Net</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.Particle.html">Particle</a>
</li>
<li class="class-depth-1">
2013-10-02 19:18:24 +00:00
<a href="Phaser.Particles.html">Particles</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
2013-10-02 19:18:24 +00:00
<a href="Phaser.Particles.Arcade.Emitter.html">Emitter</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Physics.html">Physics</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-2">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Physics.Arcade.html">Arcade</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.Arcade.Body.html">Body</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-2">
<a href="Phaser.Physics.Ninja.html">Ninja</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.Ninja.AABB.html">AABB</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.Ninja.Body.html">Body</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.Ninja.Circle.html">Circle</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.Ninja.Tile.html">Tile</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-2">
<a href="Phaser.Physics.P2.html">P2</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.P2.Body.html">Body</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.P2.BodyDebug.html">BodyDebug</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.P2.CollisionGroup.html">CollisionGroup</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.P2.ContactMaterial.html">ContactMaterial</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.P2.DistanceConstraint.html">DistanceConstraint</a>
</li>
<li class="class-depth-3">
<a href="Phaser.Physics.P2.FixtureList.html">FixtureList</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.P2.GearConstraint.html">GearConstraint</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.P2.InversePointProxy.html">InversePointProxy</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.P2.LockConstraint.html">LockConstraint</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.P2.Material.html">Material</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.P2.PointProxy.html">PointProxy</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.P2.PrismaticConstraint.html">PrismaticConstraint</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.P2.RevoluteConstraint.html">RevoluteConstraint</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-3">
<a href="Phaser.Physics.P2.Spring.html">Spring</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-02 14:05:55 +00:00
<a href="Phaser.Plugin.html">Plugin</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-02 14:05:55 +00:00
<a href="Phaser.PluginManager.html">PluginManager</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-02 14:05:55 +00:00
<a href="Phaser.Point.html">Point</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-02 14:05:55 +00:00
<a href="Phaser.Pointer.html">Pointer</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.Polygon.html">Polygon</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.QuadTree.html">QuadTree</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-02 14:05:55 +00:00
<a href="Phaser.RandomDataGenerator.html">RandomDataGenerator</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-02 14:05:55 +00:00
<a href="Phaser.Rectangle.html">Rectangle</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.RenderTexture.html">RenderTexture</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-03 00:21:08 +00:00
<a href="Phaser.RequestAnimationFrame.html">RequestAnimationFrame</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.RetroFont.html">RetroFont</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.ScaleManager.html">ScaleManager</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-02 14:05:55 +00:00
<a href="Phaser.Signal.html">Signal</a>
</li>
<li class="class-depth-1">
<a href="Phaser.SignalBinding.html">SignalBinding</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2014-02-05 06:29:17 +00:00
<a href="Phaser.SinglePad.html">SinglePad</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-03 00:21:08 +00:00
<a href="Phaser.Sound.html">Sound</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-03 00:21:08 +00:00
<a href="Phaser.SoundManager.html">SoundManager</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Sprite.html">Sprite</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.SpriteBatch.html">SpriteBatch</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-02 14:05:55 +00:00
<a href="Phaser.Stage.html">Stage</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-02 14:05:55 +00:00
<a href="Phaser.State.html">State</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-02 14:05:55 +00:00
<a href="Phaser.StateManager.html">StateManager</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.Text.html">Text</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-11-28 15:57:09 +00:00
<a href="Phaser.Tile.html">Tile</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-11-28 15:57:09 +00:00
<a href="Phaser.Tilemap.html">Tilemap</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-11-28 15:57:09 +00:00
<a href="Phaser.TilemapLayer.html">TilemapLayer</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-11-28 15:57:09 +00:00
<a href="Phaser.TilemapParser.html">TilemapParser</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-11-28 15:57:09 +00:00
<a href="Phaser.Tileset.html">Tileset</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-25 15:54:40 +00:00
<a href="Phaser.TileSprite.html">TileSprite</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.Time.html">Time</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-11-28 15:57:09 +00:00
<a href="Phaser.Timer.html">Timer</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2014-02-05 06:29:17 +00:00
<a href="Phaser.TimerEvent.html">TimerEvent</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-02 14:05:55 +00:00
<a href="Phaser.Touch.html">Touch</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.Tween.html">Tween</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.TweenManager.html">TweenManager</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
<a href="Phaser.Utils.html">Utils</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-2">
<a href="Phaser.Utils.Debug.html">Debug</a>
</li>
2014-04-10 22:13:43 +00:00
<li class="class-depth-1">
2013-10-02 14:05:55 +00:00
<a href="Phaser.World.html">World</a>
</li>
</ul>
</li>
2014-05-20 09:12:48 +00:00
2013-10-02 14:05:55 +00:00
</ul>
</div>
</div>
<div class="row-fluid">
<div class="span12">
<div id="main">
<h1 class="page-title">Source: input/Pointer.js</h1>
<section>
<article>
<pre class="sunlight-highlight-javascript linenums">/**
* @author Richard Davey &lt;rich@photonstorm.com>
2014-02-05 06:29:17 +00:00
* @copyright 2014 Photon Storm Ltd.
2013-10-02 14:05:55 +00:00
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
* Phaser - Pointer constructor.
*
* @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.
2013-11-28 15:57:09 +00:00
* @param {number} id - The ID of the Pointer object within the game. Each game can have up to 10 active pointers.
2013-10-02 14:05:55 +00:00
*/
Phaser.Pointer = function (game, id) {
/**
2013-11-28 15:57:09 +00:00
* @property {Phaser.Game} game - A reference to the currently running game.
2013-10-02 14:05:55 +00:00
*/
this.game = game;
/**
2013-11-28 15:57:09 +00:00
* @property {number} id - The ID of the Pointer object within the game. Each game can have up to 10 active pointers.
2013-10-02 14:05:55 +00:00
*/
this.id = id;
2014-05-20 09:12:48 +00:00
/**
* @property {number} type - The const type of this object.
* @readonly
*/
this.type = Phaser.POINTER;
/**
* @property {boolean} exists - A Pointer object that exists is allowed to be checked for physics collisions and overlaps.
* @default
*/
this.exists = true;
/**
* @property {number} identifier - The identifier property of the Pointer as set by the DOM event when this Pointer is started.
* @default
*/
this.identifier = 0;
/**
* @property {number} pointerId - The pointerId property of the Pointer as set by the DOM event when this Pointer is started. The browser can and will recycle this value.
* @default
*/
this.pointerId = null;
/**
* @property {any} target - The target property of the Pointer as set by the DOM event when this Pointer is started.
* @default
*/
this.target = null;
/**
* @property {any} button - The button property of the Pointer as set by the DOM event when this Pointer is started.
* @default
*/
this.button = null;
2013-10-02 14:05:55 +00:00
/**
2013-11-28 15:57:09 +00:00
* @property {boolean} _holdSent - Local private variable to store the status of dispatching a hold event.
2013-10-02 14:05:55 +00:00
* @private
* @default
*/
this._holdSent = false;
/**
2013-11-28 15:57:09 +00:00
* @property {array} _history - Local private variable storing the short-term history of pointer movements.
2013-10-02 14:05:55 +00:00
* @private
*/
this._history = [];
/**
2014-05-20 09:12:48 +00:00
* @property {number} _nextDrop - Local private variable storing the time at which the next history drop should occur.
2013-10-02 14:05:55 +00:00
* @private
*/
this._nextDrop = 0;
/**
2013-11-28 15:57:09 +00:00
* @property {boolean} _stateReset - Monitor events outside of a state reset loop.
* @private
*/
this._stateReset = false;
2013-10-02 14:05:55 +00:00
/**
2014-05-20 09:12:48 +00:00
* @property {boolean} withinGame - true if the Pointer is over the game canvas, otherwise false.
2013-10-02 14:05:55 +00:00
*/
this.withinGame = false;
/**
2014-05-20 09:12:48 +00:00
* @property {number} clientX - The horizontal coordinate of the Pointer within the application's client area at which the event occurred (as opposed to the coordinates within the page).
2013-10-02 14:05:55 +00:00
*/
this.clientX = -1;
/**
2014-05-20 09:12:48 +00:00
* @property {number} clientY - The vertical coordinate of the Pointer within the application's client area at which the event occurred (as opposed to the coordinates within the page).
2013-10-02 14:05:55 +00:00
*/
this.clientY = -1;
/**
2014-05-20 09:12:48 +00:00
* @property {number} pageX - The horizontal coordinate of the Pointer relative to whole document.
2013-10-02 14:05:55 +00:00
*/
this.pageX = -1;
/**
2014-05-20 09:12:48 +00:00
* @property {number} pageY - The vertical coordinate of the Pointer relative to whole document.
2013-10-02 14:05:55 +00:00
*/
this.pageY = -1;
/**
2014-05-20 09:12:48 +00:00
* @property {number} screenX - The horizontal coordinate of the Pointer relative to the screen.
2013-10-02 14:05:55 +00:00
*/
this.screenX = -1;
/**
2014-05-20 09:12:48 +00:00
* @property {number} screenY - The vertical coordinate of the Pointer relative to the screen.
2013-10-02 14:05:55 +00:00
*/
this.screenY = -1;
/**
2014-05-20 09:12:48 +00:00
* @property {number} rawMovementX - The horizontal raw relative movement of the Pointer in pixels since last event.
* @default
*/
this.rawMovementX = 0;
/**
* @property {number} rawMovementY - The vertical raw relative movement of the Pointer in pixels since last event.
* @default
*/
this.rawMovementY = 0;
/**
* @property {number} movementX - The horizontal processed relative movement of the Pointer in pixels since last event.
* @default
*/
this.movementX = 0;
/**
* @property {number} movementY - The vertical processed relative movement of the Pointer in pixels since last event.
* @default
*/
this.movementY = 0;
/**
* @property {number} x - The horizontal coordinate of the Pointer. This value is automatically scaled based on the game scale.
2013-10-02 14:05:55 +00:00
* @default
*/
this.x = -1;
/**
2014-05-20 09:12:48 +00:00
* @property {number} y - The vertical coordinate of the Pointer. This value is automatically scaled based on the game scale.
2013-10-02 14:05:55 +00:00
* @default
*/
this.y = -1;
/**
2013-11-28 15:57:09 +00:00
* @property {boolean} isMouse - If the Pointer is a mouse this is true, otherwise false.
* @default
2013-10-02 14:05:55 +00:00
*/
this.isMouse = false;
/**
2013-11-28 15:57:09 +00:00
* @property {boolean} isDown - If the Pointer is touching the touchscreen, or the mouse button is held down, isDown is set to true.
2013-10-02 14:05:55 +00:00
* @default
*/
this.isDown = false;
/**
2013-11-28 15:57:09 +00:00
* @property {boolean} isUp - If the Pointer is not touching the touchscreen, or the mouse button is up, isUp is set to true.
2013-10-02 14:05:55 +00:00
* @default
*/
this.isUp = true;
/**
2013-11-28 15:57:09 +00:00
* @property {number} timeDown - A timestamp representing when the Pointer first touched the touchscreen.
2013-10-02 14:05:55 +00:00
* @default
*/
this.timeDown = 0;
/**
2013-11-28 15:57:09 +00:00
* @property {number} timeUp - A timestamp representing when the Pointer left the touchscreen.
2013-10-02 14:05:55 +00:00
* @default
*/
this.timeUp = 0;
/**
2013-11-28 15:57:09 +00:00
* @property {number} previousTapTime - A timestamp representing when the Pointer was last tapped or clicked.
2013-10-02 14:05:55 +00:00
* @default
*/
this.previousTapTime = 0;
/**
2013-11-28 15:57:09 +00:00
* @property {number} totalTouches - The total number of times this Pointer has been touched to the touchscreen.
2013-10-02 14:05:55 +00:00
* @default
*/
this.totalTouches = 0;
/**
2014-05-20 09:12:48 +00:00
* @property {number} msSinceLastClick - The number of milliseconds since the last click or touch event.
2013-10-02 14:05:55 +00:00
* @default
*/
this.msSinceLastClick = Number.MAX_VALUE;
/**
2013-11-28 15:57:09 +00:00
* @property {any} targetObject - The Game Object this Pointer is currently over / touching / dragging.
2013-10-02 14:05:55 +00:00
* @default
*/
this.targetObject = null;
/**
2013-11-28 15:57:09 +00:00
* @property {boolean} active - An active pointer is one that is currently pressed down on the display. A Mouse is always active.
2013-10-02 14:05:55 +00:00
* @default
*/
this.active = false;
/**
2013-11-28 15:57:09 +00:00
* @property {Phaser.Point} position - A Phaser.Point object containing the current x/y values of the pointer on the display.
2013-10-02 14:05:55 +00:00
*/
this.position = new Phaser.Point();
2013-10-02 14:05:55 +00:00
/**
2013-11-28 15:57:09 +00:00
* @property {Phaser.Point} positionDown - A Phaser.Point object containing the x/y values of the pointer when it was last in a down state on the display.
2013-10-02 14:05:55 +00:00
*/
this.positionDown = new Phaser.Point();
2014-04-10 22:13:43 +00:00
/**
* @property {Phaser.Point} positionUp - A Phaser.Point object containing the x/y values of the pointer when it was last released.
*/
this.positionUp = new Phaser.Point();
2013-10-02 14:05:55 +00:00
/**
2013-11-28 15:57:09 +00:00
* A Phaser.Circle that is centered on the x/y coordinates of this pointer, useful for hit detection.
* The Circle size is 44px (Apples recommended "finger tip" size).
2013-10-02 14:05:55 +00:00
* @property {Phaser.Circle} circle
*/
this.circle = new Phaser.Circle(0, 0, 44);
2013-11-28 15:57:09 +00:00
if (id === 0)
2013-10-02 14:05:55 +00:00
{
this.isMouse = true;
}
};
Phaser.Pointer.prototype = {
2013-11-28 15:57:09 +00:00
/**
2013-10-02 14:05:55 +00:00
* Called when the Pointer is pressed onto the touchscreen.
* @method Phaser.Pointer#start
2014-05-20 09:12:48 +00:00
* @param {any} event - The DOM event from the browser.
2013-10-02 14:05:55 +00:00
*/
start: function (event) {
2014-05-20 09:12:48 +00:00
if (event['pointerId'])
{
this.pointerId = event.pointerId;
}
2013-10-02 14:05:55 +00:00
this.identifier = event.identifier;
this.target = event.target;
if (typeof event.button !== 'undefined')
2013-10-02 14:05:55 +00:00
{
this.button = event.button;
}
2014-04-10 22:13:43 +00:00
this._history = [];
2013-10-02 14:05:55 +00:00
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, true);
2013-10-02 14:05:55 +00:00
// x and y are the old values here?
this.positionDown.setTo(this.x, this.y);
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-10-02 14:05:55 +00:00
{
2013-11-01 18:16:52 +00:00
this.game.input.x = this.x;
this.game.input.y = this.y;
2013-10-02 14:05:55 +00:00
this.game.input.position.setTo(this.x, this.y);
2013-10-25 15:54:40 +00:00
this.game.input.onDown.dispatch(this, event);
2013-10-02 14:05:55 +00:00
this.game.input.resetSpeed(this.x, this.y);
}
this._stateReset = false;
this.totalTouches++;
if (!this.isMouse)
2013-10-02 14:05:55 +00:00
{
this.game.input.currentPointers++;
}
if (this.targetObject !== null)
{
this.targetObject._touchedHandler(this);
}
return this;
},
2013-11-28 15:57:09 +00:00
/**
2014-02-05 06:29:17 +00:00
* Called by the Input Manager.
2013-10-02 14:05:55 +00:00
* @method Phaser.Pointer#update
*/
update: function () {
if (this.active)
{
if (this._holdSent === false && this.duration >= this.game.input.holdRate)
2013-10-02 14:05:55 +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-10-02 14:05:55 +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)
2013-10-02 14:05:55 +00:00
{
this._nextDrop = this.game.time.now + this.game.input.recordRate;
this._history.push({
x: this.position.x,
y: this.position.y
});
2013-10-02 14:05:55 +00:00
if (this._history.length > this.game.input.recordLimit)
{
this._history.shift();
}
}
}
},
2013-11-28 15:57:09 +00:00
/**
* Called when the Pointer is moved.
2013-10-02 14:05:55 +00:00
* @method Phaser.Pointer#move
2013-11-28 15:57:09 +00:00
* @param {MouseEvent|PointerEvent|TouchEvent} event - The event passed up from the input handler.
* @param {boolean} [fromClick=false] - Was this called from the click event?
2013-10-02 14:05:55 +00:00
*/
move: function (event, fromClick) {
2013-10-02 14:05:55 +00:00
if (this.game.input.pollLocked)
{
return;
}
if (typeof fromClick === 'undefined') { fromClick = false; }
if (typeof event.button !== 'undefined')
2013-10-02 14:05:55 +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;
2014-05-20 09:12:48 +00:00
if (this.isMouse && this.game.input.mouse.locked && !fromClick)
{
this.rawMovementX = event.movementX || event.mozMovementX || event.webkitMovementX || 0;
this.rawMovementY = event.movementY || event.mozMovementY || event.webkitMovementY || 0;
this.movementX += this.rawMovementX;
this.movementY += this.rawMovementY;
}
2013-10-02 14:05:55 +00:00
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;
2014-05-20 09:12:48 +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-10-02 14:05:55 +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;
}
2014-05-20 09:12:48 +00:00
this.withinGame = this.game.scale.bounds.contains(this.pageX, this.pageY);
2014-02-05 06:29:17 +00:00
// If the game is paused we don't process any target objects or callbacks
2013-10-02 14:05:55 +00:00
if (this.game.paused)
{
return this;
}
2014-05-20 09:12:48 +00:00
// DEPRECATED - Soon to be removed
2014-02-05 06:29:17 +00:00
if (this.game.input.moveCallback)
{
this.game.input.moveCallback.call(this.game.input.moveCallbackContext, this, this.x, this.y);
}
2014-05-20 09:12:48 +00:00
var i = this.game.input.moveCallbacks.length;
while (i--)
{
this.game.input.moveCallbacks[i].callback.call(this.game.input.moveCallbacks[i].context, this, this.x, this.y);
}
2013-10-02 14:05:55 +00:00
// Easy out if we're dragging something and it still exists
if (this.targetObject !== null && this.targetObject.isDragged === true)
2013-10-02 14:05:55 +00:00
{
2013-11-28 15:57:09 +00:00
if (this.targetObject.update(this) === false)
2013-10-02 14:05:55 +00:00
{
this.targetObject = null;
}
return this;
}
// Work out which object is on the top
this._highestRenderOrderID = Number.MAX_SAFE_INTEGER;
2013-10-02 14:05:55 +00:00
this._highestRenderObject = null;
this._highestInputPriorityID = -1;
2014-04-29 14:39:02 +00:00
// Run through the list
2013-10-02 14:05:55 +00:00
if (this.game.input.interactiveItems.total > 0)
{
2014-04-29 14:39:02 +00:00
var currentNode = this.game.input.interactiveItems.first;
2013-10-02 14:05:55 +00:00
2013-11-28 15:57:09 +00:00
do
2013-10-02 14:05:55 +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
2014-04-29 14:39:02 +00:00
if (currentNode && currentNode.validForInput(this._highestInputPriorityID, this._highestRenderOrderID))
2013-10-02 14:05:55 +00:00
{
if ((!fromClick && currentNode.checkPointerOver(this)) || (fromClick && currentNode.checkPointerDown(this)))
2013-10-02 14:05:55 +00:00
{
this._highestRenderOrderID = currentNode.sprite._cache[3]; // renderOrderID
2013-10-02 14:05:55 +00:00
this._highestInputPriorityID = currentNode.priorityID;
this._highestRenderObject = currentNode;
}
}
2014-04-29 14:39:02 +00:00
currentNode = this.game.input.interactiveItems.next;
2013-10-02 14:05:55 +00:00
}
2014-04-29 14:39:02 +00:00
while (currentNode !== null);
2013-10-02 14:05:55 +00:00
}
if (this._highestRenderObject === null)
2013-10-02 14:05:55 +00:00
{
// The pointer isn't currently over anything, check if we've got a lingering previous target
if (this.targetObject)
{
// console.log("The pointer isn't currently over anything, check if we've got a lingering previous target");
this.targetObject._pointerOutHandler(this);
this.targetObject = null;
}
}
else
{
if (this.targetObject === null)
2013-10-02 14:05:55 +00:00
{
// And now set the new one
// console.log('And now set the new one');
this.targetObject = this._highestRenderObject;
this._highestRenderObject._pointerOverHandler(this);
}
else
{
// We've got a target from the last update
// console.log("We've got a target from the last update");
if (this.targetObject === this._highestRenderObject)
2013-10-02 14:05:55 +00:00
{
// Same target as before, so update it
// console.log("Same target as before, so update it");
2013-11-28 15:57:09 +00:00
if (this._highestRenderObject.update(this) === false)
2013-10-02 14:05:55 +00:00
{
this.targetObject = null;
}
}
else
{
// The target has changed, so tell the old one we've left it
// console.log("The target has changed, so tell the old one we've left it");
this.targetObject._pointerOutHandler(this);
// And now set the new one
this.targetObject = this._highestRenderObject;
this.targetObject._pointerOverHandler(this);
}
}
}
return this;
},
2013-11-28 15:57:09 +00:00
/**
2013-10-02 14:05:55 +00:00
* Called when the Pointer leaves the target area.
2014-05-20 09:12:48 +00:00
*
2013-10-02 14:05:55 +00:00
* @method Phaser.Pointer#leave
2013-11-28 15:57:09 +00:00
* @param {MouseEvent|PointerEvent|TouchEvent} event - The event passed up from the input handler.
2013-10-02 14:05:55 +00:00
*/
leave: function (event) {
this.withinGame = false;
this.move(event, false);
2013-10-02 14:05:55 +00:00
},
2013-11-28 15:57:09 +00:00
/**
2013-10-02 14:05:55 +00:00
* Called when the Pointer leaves the touchscreen.
2014-05-20 09:12:48 +00:00
*
2013-10-02 14:05:55 +00:00
* @method Phaser.Pointer#stop
2013-11-28 15:57:09 +00:00
* @param {MouseEvent|PointerEvent|TouchEvent} event - The event passed up from the input handler.
2013-10-02 14:05:55 +00:00
*/
stop: function (event) {
if (this._stateReset)
{
event.preventDefault();
return;
}
this.timeUp = this.game.time.now;
2014-05-20 09:12:48 +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-10-02 14:05:55 +00:00
{
2013-10-25 15:54:40 +00:00
this.game.input.onUp.dispatch(this, event);
2013-10-02 14:05:55 +00:00
// Was it a tap?
if (this.duration >= 0 && this.duration &lt;= this.game.input.tapRate)
2013-10-02 14:05:55 +00:00
{
// Was it a double-tap?
if (this.timeUp - this.previousTapTime &lt; 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;
2014-05-20 09:12:48 +00:00
this.pointerId = null;
this.identifier = null;
2014-04-10 22:13:43 +00:00
this.positionUp.setTo(this.x, this.y);
2013-11-28 15:57:09 +00:00
if (this.isMouse === false)
2013-10-02 14:05:55 +00:00
{
this.game.input.currentPointers--;
}
2014-04-29 14:39:02 +00:00
this.game.input.interactiveItems.callAll('_releasedHandler', this);
2013-10-02 14:05:55 +00:00
this.targetObject = null;
2014-04-29 14:39:02 +00:00
2013-10-02 14:05:55 +00:00
return this;
},
2013-11-28 15:57:09 +00:00
/**
2013-10-02 14:05:55 +00:00
* The Pointer is considered justPressed if the time it was pressed onto the touchscreen or clicked is less than justPressedRate.
2013-11-28 15:57:09 +00:00
* Note that calling justPressed doesn't reset the pressed status of the Pointer, it will return `true` for as long as the duration is valid.
* If you wish to check if the Pointer was pressed down just once then see the Sprite.events.onInputDown event.
2013-10-02 14:05:55 +00:00
* @method Phaser.Pointer#justPressed
2013-11-28 15:57:09 +00:00
* @param {number} [duration] - The time to check against. If none given it will use InputManager.justPressedRate.
* @return {boolean} true if the Pointer was pressed down within the duration given.
2013-10-02 14:05:55 +00:00
*/
justPressed: function (duration) {
duration = duration || this.game.input.justPressedRate;
return (this.isDown === true && (this.timeDown + duration) > this.game.time.now);
2013-10-02 14:05:55 +00:00
},
2013-11-28 15:57:09 +00:00
/**
2013-10-02 14:05:55 +00:00
* The Pointer is considered justReleased if the time it left the touchscreen is less than justReleasedRate.
2013-11-28 15:57:09 +00:00
* Note that calling justReleased doesn't reset the pressed status of the Pointer, it will return `true` for as long as the duration is valid.
* If you wish to check if the Pointer was released just once then see the Sprite.events.onInputUp event.
2013-10-02 14:05:55 +00:00
* @method Phaser.Pointer#justReleased
2013-11-28 15:57:09 +00:00
* @param {number} [duration] - The time to check against. If none given it will use InputManager.justReleasedRate.
* @return {boolean} true if the Pointer was released within the duration given.
2013-10-02 14:05:55 +00:00
*/
justReleased: function (duration) {
duration = duration || this.game.input.justReleasedRate;
return (this.isUp === true && (this.timeUp + duration) > this.game.time.now);
2013-10-02 14:05:55 +00:00
},
2013-11-28 15:57:09 +00:00
/**
2013-10-02 14:05:55 +00:00
* Resets the Pointer properties. Called by InputManager.reset when you perform a State change.
* @method Phaser.Pointer#reset
*/
reset: function () {
2013-11-28 15:57:09 +00:00
if (this.isMouse === false)
2013-10-02 14:05:55 +00:00
{
this.active = false;
}
2014-05-20 09:12:48 +00:00
this.pointerId = null;
2013-10-02 14:05:55 +00:00
this.identifier = null;
this.isDown = false;
this.isUp = true;
this.totalTouches = 0;
this._holdSent = false;
this._history.length = 0;
this._stateReset = true;
if (this.targetObject)
{
this.targetObject._releasedHandler(this);
}
this.targetObject = null;
2014-05-20 09:12:48 +00:00
},
/**
* Resets the movementX and movementY properties. Use in your update handler after retrieving the values.
* @method Phaser.Pointer#resetMovement
*/
resetMovement: function() {
this.movementX = 0;
this.movementY = 0;
2013-10-02 14:05:55 +00:00
}
};
2014-02-05 06:29:17 +00:00
Phaser.Pointer.prototype.constructor = Phaser.Pointer;
2013-10-02 14:05:55 +00:00
/**
* How long the Pointer has been depressed on the touchscreen. If not currently down it returns -1.
* @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
*/
Object.defineProperty(Phaser.Pointer.prototype, "duration", {
get: function () {
if (this.isUp)
{
return -1;
}
return this.game.time.now - this.timeDown;
}
});
/**
* 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
*/
Object.defineProperty(Phaser.Pointer.prototype, "worldX", {
get: function () {
2013-11-28 15:57:09 +00:00
return this.game.world.camera.x + this.x;
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
*/
Object.defineProperty(Phaser.Pointer.prototype, "worldY", {
get: function () {
2013-11-28 15:57:09 +00:00
return this.game.world.camera.y + this.y;
2013-10-02 14:05:55 +00:00
}
});
</pre>
</article>
</section>
</div>
<div class="clearfix"></div>
<footer>
<span class="copyright">
2014-02-05 06:29:17 +00:00
Phaser Copyright © 2012-2014 Photon Storm Ltd.
2013-10-02 14:05:55 +00:00
</span>
<br />
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-dev</a>
2014-05-20 09:12:48 +00:00
on Tue May 20 2014 10:05:49 GMT+0100 (BST) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
2013-10-02 14:05:55 +00:00
</span>
</footer>
</div>
<br clear="both">
</div>
</div>
<script src="scripts/sunlight.js"></script>
<script src="scripts/sunlight.javascript.js"></script>
<script src="scripts/sunlight-plugin.doclinks.js"></script>
<script src="scripts/sunlight-plugin.linenumbers.js"></script>
<script src="scripts/sunlight-plugin.menu.js"></script>
<script src="scripts/jquery.min.js"></script>
<script src="scripts/jquery.scrollTo.js"></script>
<script src="scripts/jquery.localScroll.js"></script>
<script src="scripts/bootstrap-dropdown.js"></script>
<script src="scripts/toc.js"></script>
<script> Sunlight.highlightAll({lineNumbers:true, showMenu: true, enableDoclinks :true}); </script>
<script>
$( function () {
$( "#toc" ).toc( {
2014-04-10 22:13:43 +00:00
anchorName : function(i, heading, prefix) {
return $(heading).attr("id") || ( prefix + i );
},
2013-10-02 14:05:55 +00:00
selectors : "h1,h2,h3,h4",
showAndHide : false,
scrollTo : 60
} );
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
} );
</script>
</body>
</html>