InteractionData Class
+ + + + +Constructor
+InteractionData
+
+
+ ()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
- Index + + + +
- Properties + + + +
diff --git a/README.md b/README.md
index b9a1118..263ccf9 100644
--- a/README.md
+++ b/README.md
@@ -86,4 +86,8 @@ last 2 examples and allowing us to share the source code :)
}
```
+<<<<<<< HEAD
This content is released under the (http://opensource.org/licenses/MIT) MIT License.
+=======
+This content is released under the (http://opensource.org/licenses/MIT) MIT License.
+>>>>>>> Interactivity Added
diff --git a/bin/pixi.js b/bin/pixi.js
index 775c51c..e4c61db 100644
--- a/bin/pixi.js
+++ b/bin/pixi.js
@@ -1,114 +1,128 @@
-var PIXI=PIXI||{};PIXI.Point=function(b,c){this.x=b?b:0;this.y=c?c:0};PIXI.Point.clone=function(){return new PIXI.Point(this.x,this.y)};PIXI.Point.constructor=PIXI.Point;PIXI.Rectangle=function(b,c,f,e){this.x=b?b:0;this.y=c?c:0;this.width=f?f:0;this.height=e?e:0};PIXI.Rectangle.clone=function(){return new PIXI.Rectangle(this.x,this.y,this.width,this.height)};PIXI.Rectangle.constructor=PIXI.Rectangle;window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(b){window.setTimeout(b,1E3/60)}}();function HEXtoRGB(b){return[(b>>16&255)/255,(b>>8&255)/255,(b&255)/255]}
-"function"!=typeof Function.prototype.bind&&(Function.prototype.bind=function(){var b=Array.prototype.slice;return function(c){function f(){var h=g.concat(b.call(arguments));e.apply(this instanceof f?this:c,h)}var e=this,g=b.call(arguments,1);if("function"!=typeof e)throw new TypeError;f.prototype=function j(b){b&&(j.prototype=b);if(!(this instanceof j))return new j}(e.prototype);return f}}());
-var AjaxRequest=function(){var b=["Msxml2.XMLHTTP","Microsoft.XMLHTTP"];if(window.ActiveXObject)for(var c=0;c the canvas to use as a view, optional The interaction manager deals with mouse and touch events. At this moment only Sprite's can be interactive.
+This manager also supports multitouch. This method will disable rollover/rollout for ALL interactive items
+You may wish to use this an optimization if your app does not require rollover/rollout funcitonality This method will enable rollover/rollout for ALL interactive items
+It is enabled by default an object that stores current touches (InteractionData) by id reference A callback that is used when the users clicks on the sprite with thier mouse A callback that is used when the user clicks the mouse down over the sprite A callback that is used when the users mouse leaves the sprite A callback that is used when the users mouse rolls over the sprite A callback that is used when the user releases the mouse that was over the sprite
+for this callback to be fired the mouse must have been pressed down over the sprite Indicates if the sprite will have touch and mouse interactivity. It is false by default A callback that is used when the users taps on the sprite with thier finger
+basically a touch version of click A callback that is used when the user releases the touch that was over the sprite
+for this callback to be fired. The touch must have started over the sprite A callback that is used when the user touch's over the sprite A callback that is used when the users clicks on the sprite with thier mouse Helper function that creates a sprite that will contain a texture from the TextureCache based on tjhe frameId
+ Helper function that creates a sprite that will contain a texture from the TextureCache based on the frameId
The frame ids are created when a Texture packer file has been loaded A callback that is used when the user clicks the mouse down over the sprite A callback that is used when the users mouse leaves the sprite A callback that is used when the users mouse rolls over the sprite A callback that is used when the user releases the mouse that was over the sprite
+for this callback to be fired the mouse must have been pressed down over the sprite Indicates if the sprite will have touch and mouse interactivity. It is false by default
+
+
+ pixi/renderers/CanvasRenderer.js:56
+ pixi/renderers/CanvasRenderer.js:57
@@ -341,7 +345,7 @@ Dont forget to add the view to your DOM or you will not see anything :)
- pixi/renderers/CanvasRenderer.js:45
+ pixi/renderers/CanvasRenderer.js:46
@@ -385,7 +389,7 @@ Dont forget to add the view to your DOM or you will not see anything :)
- pixi/renderers/CanvasRenderer.js:21
+ pixi/renderers/CanvasRenderer.js:22
@@ -431,7 +435,7 @@ Dont forget to add the view to your DOM or you will not see anything :)
- pixi/renderers/CanvasRenderer.js:31
+ pixi/renderers/CanvasRenderer.js:32
@@ -475,7 +479,7 @@ Dont forget to add the view to your DOM or you will not see anything :)
- pixi/renderers/CanvasRenderer.js:14
+ pixi/renderers/CanvasRenderer.js:15
diff --git a/docs/classes/DisplayObject.html b/docs/classes/DisplayObject.html
index 2474970..151abad 100644
--- a/docs/classes/DisplayObject.html
+++ b/docs/classes/DisplayObject.html
@@ -15,11 +15,11 @@
+ view
+
+ view
+ Canvas
+
+
+
+
+
+
+
+ InteractionData Class
+
+
+
+
+Constructor
+
+
+
+ ()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ InteractionData
+
+
+
+
+ InteractionManager Class
+
+
+
+
+Constructor
+
+
+
+ InteractionManager
+
+
)
+ stage
+
+ Parameters:
+
+
+
+
+ stage
+ Stage
+
+
+
+
+
+
+
+ Item Index
+
+
+ Methods
+
+
+
+
+ Methods
+
+
+
+
+
+ ()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ disableMouseOver
+
+
+ ()
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ enableMouseOver
Properties
+
+
+
+
+
+
+
+
+
+ Object
+
+
+
+
+
+
+
+
+
+
+
+ touchs
+
+
+
+ click
+
+
)
+ interactionData
+
+ Parameters:
+
+
+
+
+ interactionData
+ InteractionData
+
+
+
+
+
+
+
+ mousedown
+
+
)
+ interactionData
+
+ Parameters:
+
+
+
+
+ interactionData
+ InteractionData
+
+
+
+
+
+
+
+ mouseout
+
+
)
+ interactionData
+
+ Parameters:
+
+
+
+
+ interactionData
+ InteractionData
+
+
+
+
+
+
+
+ mouseover
+
+
)
+ interactionData
+
+ Parameters:
+
+
+
+
+ interactionData
+ InteractionData
+
+
+
+
+
+
+
+ mouseup
+
+
)
+ interactionData
+
+ Parameters:
+
+
+
+
+ interactionData
+ InteractionData
+
+
+
+
+
+
+
+ setInteractive
+
+
)
+ interactive
+
+ Parameters:
+
+
+
+
+ interactive
+ Boolean
+
+
+
+
+ pixi/Sprite.js:79
+ pixi/Sprite.js:146
@@ -1092,6 +1664,260 @@
+
+
+
+ tap
+
+
)
+ interactionData
+
+ Parameters:
+
+
+
+
+ interactionData
+ InteractionData
+
+
+
+
+
+
+
+ touchend
+
+
)
+ interactionData
+
+ Parameters:
+
+
+
+
+ interactionData
+ InteractionData
+
+
+
+
+
+
+
+ touchstart
+
+
)
+ interactionData
+
+ Parameters:
+
+
+
+
+ interactionData
+ InteractionData
+
+
+
+
+
+
+
+
+
+
+ click
+
+
)
+ interactionData
+
+ Parameters:
+
+
+
+
+ interactionData
+ InteractionData
+
+
+
+
+ pixi/Sprite.js:111
+ pixi/Sprite.js:189
@@ -666,7 +820,7 @@
pixi/Sprite.js:127
+ pixi/Sprite.js:205
@@ -818,6 +972,355 @@
+
+
+
+ mousedown
+
+
)
+ interactionData
+
+ Parameters:
+
+
+
+
+ interactionData
+ InteractionData
+
+
+
+
+
+
+
+ mouseout
+
+
)
+ interactionData
+
+ Parameters:
+
+
+
+
+ interactionData
+ InteractionData
+
+
+
+
+
+
+
+ mouseover
+
+
)
+ interactionData
+
+ Parameters:
+
+
+
+
+ interactionData
+ InteractionData
+
+
+
+
+
+
+
+ mouseup
+
+
)
+ interactionData
+
+ Parameters:
+
+
+
+
+ interactionData
+ InteractionData
+
+
+
+
+
+
+
+ setInteractive
+
+
)
+ interactive
+
+ Parameters:
+
+
+
+
+ interactive
+ Boolean
+
+
+
+
+ pixi/Sprite.js:79
+ pixi/Sprite.js:146
tap
interactionData
+
+ A callback that is used when the users taps on the sprite with thier finger +basically a touch version of click
+interactionData
+ InteractionData
+
+
+
+
+ touchend
interactionData
+
+ A callback that is used when the user releases the touch that was over the sprite +for this callback to be fired. The touch must have started over the sprite
+interactionData
+ InteractionData
+
+
+
+
+ touchstart
interactionData
+
+ A callback that is used when the user touch's over the sprite
+interactionData
+ InteractionData
+
+
+
+
+ interactive
+
+ interactive
+ Boolean
+
+
+
+
+ enable / disable interaction (default is false)
+pixi/Stage.js:44
+ pixi/Stage.js:59
@@ -764,7 +789,7 @@
- pixi/Stage.js:30
+ pixi/Stage.js:35
diff --git a/docs/classes/Texture.html b/docs/classes/Texture.html
index 48980dc..94ae696 100644
--- a/docs/classes/Texture.html
+++ b/docs/classes/Texture.html
@@ -15,11 +15,11 @@
view
+
+ view
+ Canvas
+
+
+
+
+ the canvas to use as a view, optional
+pixi/renderers/WebGLRenderer.js:157
+ pixi/renderers/WebGLRenderer.js:158
@@ -438,7 +463,7 @@ Dont forget to add the view to your DOM or you will not see anything :)
- pixi/renderers/WebGLRenderer.js:526
+ pixi/renderers/WebGLRenderer.js:538
diff --git a/docs/data.json b/docs/data.json
index 246ea87..5e94f50 100644
--- a/docs/data.json
+++ b/docs/data.json
@@ -1,9 +1,9 @@
{
"project": {
"name": "Pixi.js API",
- "logo": "../logo_small.png",
- "description": "The Foo API: a library for doing X, Y, and Z",
- "version": "0.9",
+ "logo": "http://www.goodboydigital.com/pixijs/logo_small.png",
+ "description": "Pixi.js is a fast lightweight 2D library that works across all devices.",
+ "version": "1.0",
"url": "http://goodboydigital.com/"
},
"files": {
@@ -130,6 +130,16 @@
"fors": {},
"namespaces": {}
},
+ "pixi/InteractionManager.js": {
+ "name": "pixi/InteractionManager.js",
+ "modules": {},
+ "classes": {
+ "InteractionManager": 1,
+ "InteractionData": 1
+ },
+ "fors": {},
+ "namespaces": {}
+ },
"pixi/MovieClip.js": {
"name": "pixi/MovieClip.js",
"modules": {},
@@ -199,6 +209,8 @@
"Texture": 1,
"DisplayObject": 1,
"DisplayObjectContainer": 1,
+ "InteractionManager": 1,
+ "InteractionData": 1,
"MovieClip": 1,
"Point": 1,
"Rectangle": 1,
@@ -279,6 +291,11 @@
"name": "height",
"description": "the height of the canvas view",
"type": "Number"
+ },
+ {
+ "name": "view",
+ "description": "the canvas to use as a view, optional",
+ "type": "Canvas"
}
]
},
@@ -328,6 +345,11 @@
"name": "height",
"description": "the height of the canvas view",
"type": "Number"
+ },
+ {
+ "name": "view",
+ "description": "the canvas to use as a view, optional",
+ "type": "Canvas"
}
],
"default": "0"
@@ -410,6 +432,41 @@
"extends": "DisplayObject",
"is_constructor": 1
},
+ "InteractionManager": {
+ "name": "InteractionManager",
+ "shortname": "InteractionManager",
+ "classitems": [],
+ "plugins": [],
+ "extensions": [],
+ "plugin_for": [],
+ "extension_for": [],
+ "module": "PIXI",
+ "file": "pixi/InteractionManager.js",
+ "line": 7,
+ "description": "The interaction manager deals with mouse and touch events. At this moment only Sprite's can be interactive.\nThis manager also supports multitouch.",
+ "is_constructor": 1,
+ "params": [
+ {
+ "name": "stage",
+ "description": "",
+ "type": "Stage"
+ }
+ ],
+ "type": "Stage"
+ },
+ "InteractionData": {
+ "name": "InteractionData",
+ "shortname": "InteractionData",
+ "classitems": [],
+ "plugins": [],
+ "extensions": [],
+ "plugin_for": [],
+ "extension_for": [],
+ "module": "PIXI",
+ "file": "pixi/InteractionManager.js",
+ "line": 319,
+ "is_constructor": 1
+ },
"MovieClip": {
"name": "MovieClip",
"shortname": "MovieClip",
@@ -539,6 +596,11 @@
"name": "backgroundColor",
"description": "the background color of the stage",
"type": "Number"
+ },
+ {
+ "name": "interactive",
+ "description": "enable / disable interaction (default is false)",
+ "type": "Boolean"
}
]
}
@@ -613,7 +675,7 @@
},
{
"file": "pixi/renderers/CanvasRenderer.js",
- "line": 14,
+ "line": 15,
"description": "The width of the canvas view",
"itemtype": "property",
"name": "width",
@@ -623,7 +685,7 @@
},
{
"file": "pixi/renderers/CanvasRenderer.js",
- "line": 21,
+ "line": 22,
"description": "The height of the canvas view",
"itemtype": "property",
"name": "height",
@@ -633,7 +695,7 @@
},
{
"file": "pixi/renderers/CanvasRenderer.js",
- "line": 31,
+ "line": 32,
"description": "The canvas element that the everything is drawn to",
"itemtype": "property",
"name": "view",
@@ -642,7 +704,7 @@
},
{
"file": "pixi/renderers/CanvasRenderer.js",
- "line": 45,
+ "line": 46,
"description": "The canvas context that the everything is drawn to",
"itemtype": "property",
"name": "context",
@@ -651,7 +713,7 @@
},
{
"file": "pixi/renderers/CanvasRenderer.js",
- "line": 56,
+ "line": 57,
"description": "Renders the stage to its canvas view",
"itemtype": "method",
"name": "render",
@@ -666,7 +728,7 @@
},
{
"file": "pixi/renderers/CanvasRenderer.js",
- "line": 83,
+ "line": 96,
"description": "resizes the canvas view to the specified width and height",
"params": [
{
@@ -682,21 +744,21 @@
},
{
"file": "pixi/renderers/CanvasRenderer.js",
- "line": 97,
+ "line": 110,
"access": "private",
"tagname": "",
"class": "CanvasRenderer"
},
{
"file": "pixi/renderers/CanvasRenderer.js",
- "line": 167,
+ "line": 180,
"access": "private",
"tagname": "",
"class": "CanvasRenderer"
},
{
"file": "pixi/renderers/CanvasRenderer.js",
- "line": 202,
+ "line": 215,
"access": "private",
"tagname": "",
"class": "CanvasRenderer"
@@ -877,21 +939,21 @@
},
{
"file": "pixi/renderers/WebGLRenderer.js",
- "line": 64,
+ "line": 65,
"access": "private",
"tagname": "",
"class": "WebGLRenderer"
},
{
"file": "pixi/renderers/WebGLRenderer.js",
- "line": 103,
+ "line": 104,
"access": "private",
"tagname": "",
"class": "WebGLRenderer"
},
{
"file": "pixi/renderers/WebGLRenderer.js",
- "line": 157,
+ "line": 158,
"description": "Renders the stage to its webGL view",
"itemtype": "method",
"name": "render",
@@ -906,28 +968,28 @@
},
{
"file": "pixi/renderers/WebGLRenderer.js",
- "line": 223,
+ "line": 235,
"access": "private",
"tagname": "",
"class": "WebGLRenderer"
},
{
"file": "pixi/renderers/WebGLRenderer.js",
- "line": 252,
+ "line": 264,
"access": "private",
"tagname": "",
"class": "WebGLRenderer"
},
{
"file": "pixi/renderers/WebGLRenderer.js",
- "line": 448,
+ "line": 460,
"access": "private",
"tagname": "",
"class": "WebGLRenderer"
},
{
"file": "pixi/renderers/WebGLRenderer.js",
- "line": 526,
+ "line": 538,
"description": "resizes the webGL view to the specified width and height",
"itemtype": "method",
"name": "resize",
@@ -947,28 +1009,28 @@
},
{
"file": "pixi/renderers/WebGLRenderer.js",
- "line": 547,
+ "line": 559,
"access": "private",
"tagname": "",
"class": "WebGLRenderer"
},
{
"file": "pixi/renderers/WebGLRenderer.js",
- "line": 575,
+ "line": 587,
"access": "private",
"tagname": "",
"class": "WebGLRenderer"
},
{
"file": "pixi/renderers/WebGLRenderer.js",
- "line": 653,
+ "line": 665,
"access": "private",
"tagname": "",
"class": "WebGLRenderer"
},
{
"file": "pixi/renderers/WebGLRenderer.js",
- "line": 662,
+ "line": 674,
"access": "private",
"tagname": "",
"class": "WebGLRenderer"
@@ -1140,6 +1202,10 @@
"type": "String"
}
],
+ "return": {
+ "description": "the texture that was removed",
+ "type": "Texture"
+ },
"class": "Texture"
},
{
@@ -1165,6 +1231,11 @@
"name": "height",
"description": "the height of the renderers view",
"type": "Number"
+ },
+ {
+ "name": "view",
+ "description": "the canvas to use as a view, optional",
+ "type": "Canvas"
}
],
"class": "DisplayObject"
@@ -1258,7 +1329,7 @@
},
{
"file": "pixi/DisplayObject.js",
- "line": 79,
+ "line": 82,
"access": "private",
"tagname": "",
"class": "DisplayObject"
@@ -1335,6 +1406,73 @@
"tagname": "",
"class": "DisplayObjectContainer"
},
+ {
+ "file": "pixi/InteractionManager.js",
+ "line": 1,
+ "author": "Mat Groves http://matgroves.com/ @Doormat23",
+ "class": "InteractionManager"
+ },
+ {
+ "file": "pixi/InteractionManager.js",
+ "line": 17,
+ "description": "a refference to the stage",
+ "itemtype": "property",
+ "name": "stage",
+ "type": "Stage",
+ "class": "InteractionManager"
+ },
+ {
+ "file": "pixi/InteractionManager.js",
+ "line": 30,
+ "description": "the mouse data",
+ "itemtype": "property",
+ "name": "mouse",
+ "type": "InteractionData",
+ "class": "InteractionManager"
+ },
+ {
+ "file": "pixi/InteractionManager.js",
+ "line": 37,
+ "description": "an object that stores current touches (InteractionData) by id reference",
+ "itemtype": "property",
+ "name": "touchs",
+ "type": "Object",
+ "class": "InteractionManager"
+ },
+ {
+ "file": "pixi/InteractionManager.js",
+ "line": 53,
+ "description": "This method will disable rollover/rollout for ALL interactive items\nYou may wish to use this an optimization if your app does not require rollover/rollout funcitonality",
+ "itemtype": "method",
+ "name": "disableMouseOver",
+ "class": "InteractionManager"
+ },
+ {
+ "file": "pixi/InteractionManager.js",
+ "line": 66,
+ "description": "This method will enable rollover/rollout for ALL interactive items\nIt is enabled by default",
+ "itemtype": "method",
+ "name": "enableMouseOver",
+ "class": "InteractionManager"
+ },
+ {
+ "file": "pixi/InteractionManager.js",
+ "line": 325,
+ "description": "This point stores the global coords of where the touch/mouse event happened",
+ "itemtype": "property",
+ "name": "global",
+ "type": "Point",
+ "class": "InteractionData"
+ },
+ {
+ "file": "pixi/InteractionManager.js",
+ "line": 332,
+ "description": "This point stores the local coords of where the touch/mouse event happened",
+ "itemtype": "property",
+ "name": "local",
+ "type": "Point",
+ "class": "InteractionData"
+ },
{
"file": "pixi/MovieClip.js",
"line": 1,
@@ -1584,7 +1722,135 @@
},
{
"file": "pixi/Sprite.js",
- "line": 79,
+ "line": 86,
+ "description": "A callback that is used when the users clicks on the sprite with thier mouse",
+ "itemtype": "method",
+ "name": "click",
+ "params": [
+ {
+ "name": "interactionData",
+ "description": "",
+ "type": "InteractionData"
+ }
+ ],
+ "class": "Sprite",
+ "module": "PIXI"
+ },
+ {
+ "file": "pixi/Sprite.js",
+ "line": 92,
+ "description": "A callback that is used when the user clicks the mouse down over the sprite",
+ "itemtype": "method",
+ "name": "mousedown",
+ "params": [
+ {
+ "name": "interactionData",
+ "description": "",
+ "type": "InteractionData"
+ }
+ ],
+ "class": "Sprite",
+ "module": "PIXI"
+ },
+ {
+ "file": "pixi/Sprite.js",
+ "line": 98,
+ "description": "A callback that is used when the user releases the mouse that was over the sprite\nfor this callback to be fired the mouse must have been pressed down over the sprite",
+ "itemtype": "method",
+ "name": "mouseup",
+ "params": [
+ {
+ "name": "interactionData",
+ "description": "",
+ "type": "InteractionData"
+ }
+ ],
+ "class": "Sprite",
+ "module": "PIXI"
+ },
+ {
+ "file": "pixi/Sprite.js",
+ "line": 105,
+ "description": "A callback that is used when the users mouse rolls over the sprite",
+ "itemtype": "method",
+ "name": "mouseover",
+ "params": [
+ {
+ "name": "interactionData",
+ "description": "",
+ "type": "InteractionData"
+ }
+ ],
+ "class": "Sprite",
+ "module": "PIXI"
+ },
+ {
+ "file": "pixi/Sprite.js",
+ "line": 111,
+ "description": "A callback that is used when the users mouse leaves the sprite",
+ "itemtype": "method",
+ "name": "mouseout",
+ "params": [
+ {
+ "name": "interactionData",
+ "description": "",
+ "type": "InteractionData"
+ }
+ ],
+ "class": "Sprite",
+ "module": "PIXI"
+ },
+ {
+ "file": "pixi/Sprite.js",
+ "line": 121,
+ "description": "A callback that is used when the users taps on the sprite with thier finger\nbasically a touch version of click",
+ "itemtype": "method",
+ "name": "tap",
+ "params": [
+ {
+ "name": "interactionData",
+ "description": "",
+ "type": "InteractionData"
+ }
+ ],
+ "class": "Sprite",
+ "module": "PIXI"
+ },
+ {
+ "file": "pixi/Sprite.js",
+ "line": 128,
+ "description": "A callback that is used when the user touch's over the sprite",
+ "itemtype": "method",
+ "name": "touchstart",
+ "params": [
+ {
+ "name": "interactionData",
+ "description": "",
+ "type": "InteractionData"
+ }
+ ],
+ "class": "Sprite",
+ "module": "PIXI"
+ },
+ {
+ "file": "pixi/Sprite.js",
+ "line": 134,
+ "description": "A callback that is used when the user releases the touch that was over the sprite\nfor this callback to be fired. The touch must have started over the sprite",
+ "itemtype": "method",
+ "name": "touchend",
+ "params": [
+ {
+ "name": "interactionData",
+ "description": "",
+ "type": "InteractionData"
+ }
+ ],
+ "class": "Sprite",
+ "module": "PIXI"
+ },
+ {
+ "file": "pixi/Sprite.js",
+ "line": 146,
"itemtype": "method",
"name": "setTexture",
"params": [
@@ -1599,7 +1865,23 @@
},
{
"file": "pixi/Sprite.js",
- "line": 98,
+ "line": 164,
+ "description": "Indicates if the sprite will have touch and mouse interactivity. It is false by default",
+ "itemtype": "method",
+ "name": "setInteractive",
+ "params": [
+ {
+ "name": "interactive",
+ "description": "",
+ "type": "Boolean"
+ }
+ ],
+ "class": "Sprite",
+ "module": "PIXI"
+ },
+ {
+ "file": "pixi/Sprite.js",
+ "line": 177,
"access": "private",
"tagname": "",
"class": "Sprite",
@@ -1607,8 +1889,8 @@
},
{
"file": "pixi/Sprite.js",
- "line": 111,
- "description": "Helper function that creates a sprite that will contain a texture from the TextureCache based on tjhe frameId\n The frame ids are created when a Texture packer file has been loaded",
+ "line": 189,
+ "description": "Helper function that creates a sprite that will contain a texture from the TextureCache based on the frameId\n The frame ids are created when a Texture packer file has been loaded",
"itemtype": "method",
"name": "fromFrame",
"static": 1,
@@ -1628,7 +1910,7 @@
},
{
"file": "pixi/Sprite.js",
- "line": 127,
+ "line": 205,
"description": "Helper function that creates a sprite that will contain a texture based on an image url\n If the image is not in the texture cache it will be loaded",
"itemtype": "method",
"name": "fromImage",
@@ -1655,7 +1937,7 @@
},
{
"file": "pixi/Stage.js",
- "line": 30,
+ "line": 35,
"itemtype": "method",
"name": "updateTransform",
"internal": "",
@@ -1664,7 +1946,7 @@
},
{
"file": "pixi/Stage.js",
- "line": 44,
+ "line": 59,
"itemtype": "method",
"name": "setBackgroundColor",
"params": [
@@ -1685,7 +1967,7 @@
},
{
"message": "unknown tag: internal",
- "line": " pixi/Stage.js:30"
+ "line": " pixi/Stage.js:35"
},
{
"message": "Missing item type",
@@ -1717,19 +1999,19 @@
},
{
"message": "Missing item type\nresizes the canvas view to the specified width and height",
- "line": " pixi/renderers/CanvasRenderer.js:83"
+ "line": " pixi/renderers/CanvasRenderer.js:96"
},
{
"message": "Missing item type",
- "line": " pixi/renderers/CanvasRenderer.js:97"
+ "line": " pixi/renderers/CanvasRenderer.js:110"
},
{
"message": "Missing item type",
- "line": " pixi/renderers/CanvasRenderer.js:167"
+ "line": " pixi/renderers/CanvasRenderer.js:180"
},
{
"message": "Missing item type",
- "line": " pixi/renderers/CanvasRenderer.js:202"
+ "line": " pixi/renderers/CanvasRenderer.js:215"
},
{
"message": "Missing item type",
@@ -1761,39 +2043,39 @@
},
{
"message": "Missing item type",
- "line": " pixi/renderers/WebGLRenderer.js:64"
+ "line": " pixi/renderers/WebGLRenderer.js:65"
},
{
"message": "Missing item type",
- "line": " pixi/renderers/WebGLRenderer.js:103"
+ "line": " pixi/renderers/WebGLRenderer.js:104"
},
{
"message": "Missing item type",
- "line": " pixi/renderers/WebGLRenderer.js:223"
+ "line": " pixi/renderers/WebGLRenderer.js:235"
},
{
"message": "Missing item type",
- "line": " pixi/renderers/WebGLRenderer.js:252"
+ "line": " pixi/renderers/WebGLRenderer.js:264"
},
{
"message": "Missing item type",
- "line": " pixi/renderers/WebGLRenderer.js:448"
+ "line": " pixi/renderers/WebGLRenderer.js:460"
},
{
"message": "Missing item type",
- "line": " pixi/renderers/WebGLRenderer.js:547"
+ "line": " pixi/renderers/WebGLRenderer.js:559"
},
{
"message": "Missing item type",
- "line": " pixi/renderers/WebGLRenderer.js:575"
+ "line": " pixi/renderers/WebGLRenderer.js:587"
},
{
"message": "Missing item type",
- "line": " pixi/renderers/WebGLRenderer.js:653"
+ "line": " pixi/renderers/WebGLRenderer.js:665"
},
{
"message": "Missing item type",
- "line": " pixi/renderers/WebGLRenderer.js:662"
+ "line": " pixi/renderers/WebGLRenderer.js:674"
},
{
"message": "Missing item type",
@@ -1829,7 +2111,7 @@
},
{
"message": "Missing item type",
- "line": " pixi/DisplayObject.js:79"
+ "line": " pixi/DisplayObject.js:82"
},
{
"message": "Missing item type",
@@ -1839,6 +2121,10 @@
"message": "Missing item type",
"line": " pixi/DisplayObjectContainer.js:126"
},
+ {
+ "message": "Missing item type",
+ "line": " pixi/InteractionManager.js:1"
+ },
{
"message": "Missing item type",
"line": " pixi/MovieClip.js:1"
@@ -1861,7 +2147,7 @@
},
{
"message": "Missing item type",
- "line": " pixi/Sprite.js:98"
+ "line": " pixi/Sprite.js:177"
},
{
"message": "Missing item type",
diff --git a/docs/files/pixi_DisplayObject.js.html b/docs/files/pixi_DisplayObject.js.html
index 3314e86..a1d9784 100644
--- a/docs/files/pixi_DisplayObject.js.html
+++ b/docs/files/pixi_DisplayObject.js.html
@@ -15,11 +15,11 @@
+/** + * @author Mat Groves http://matgroves.com/ @Doormat23 + */ + + + +/** +The interaction manager deals with mouse and touch events. At this moment only Sprite's can be interactive. +This manager also supports multitouch. +@class InteractionManager +@constructor +@param stage {Stage} +@type Stage +*/ +PIXI.InteractionManager = function(stage) +{ + /** + * a refference to the stage + * @property stage + * @type Stage + */ + this.stage = stage; + + // helpers + this.tempPoint = new PIXI.Point(); + this.tempMatrix = mat3.create(); + + this.mouseoverEnabled = true; + + /** + * the mouse data + * @property mouse + * @type InteractionData + */ + this.mouse = new PIXI.InteractionData(); + + /** + * an object that stores current touches (InteractionData) by id reference + * @property touchs + * @type Object + */ + this.touchs = {}; + + //tiny little interactiveData pool! + this.pool = []; + + this.interactiveItems = []; +} + +// constructor +PIXI.InteractionManager.constructor = PIXI.InteractionManager; + +/** + * This method will disable rollover/rollout for ALL interactive items + * You may wish to use this an optimization if your app does not require rollover/rollout funcitonality + * @method disableMouseOver + */ +PIXI.InteractionManager.prototype.disableMouseOver = function() +{ + if(!this.mouseoverEnabled)return; + + this.mouseoverEnabled = false; + if(this.target)this.target.view.removeEventListener('mousemove', this.onMouseMove.bind(this)); +} + +/** + * This method will enable rollover/rollout for ALL interactive items + * It is enabled by default + * @method enableMouseOver + */ +PIXI.InteractionManager.prototype.enableMouseOver = function() +{ + if(this.mouseoverEnabled)return; + + this.mouseoverEnabled = false; + if(this.target)this.target.view.addEventListener('mousemove', this.onMouseMove.bind(this)); +} + +PIXI.InteractionManager.prototype.collectInteractiveSprite = function(displayObject) +{ + var children = displayObject.children; + var length = children.length; + + for (var i = length - 1; i >= 0; i--) + { + var child = children[i]; + + // only sprite's right now... + if(child instanceof PIXI.Sprite) + { + if(child.interactive)this.interactiveItems.push(child); + } + else + { + // use this to optimize.. + if(!child.interactive)continue; + } + + if(child.children.length > 0) + { + this.collectInteractiveSprite(child); + } + } +} + +PIXI.InteractionManager.prototype.setTarget = function(target) +{ + this.target = target; + if(this.mouseoverEnabled)target.view.addEventListener('mousemove', this.onMouseMove.bind(this), true); + target.view.addEventListener('mousedown', this.onMouseDown.bind(this), true); + target.view.addEventListener('mouseup', this.onMouseUp.bind(this), true); + target.view.addEventListener('mouseout', this.onMouseUp.bind(this), true); + + // aint no multi touch just yet! + target.view.addEventListener("touchstart", this.onTouchStart.bind(this), true); + target.view.addEventListener("touchend", this.onTouchEnd.bind(this), true); + target.view.addEventListener("touchmove", this.onTouchMove.bind(this), true); +} + +PIXI.InteractionManager.prototype.hitTest = function(interactionData) +{ + if(this.dirty) + { + this.dirty = false; + this.interactiveItems = []; + // go through and collect all the objects that are interactive.. + this.collectInteractiveSprite(this.stage); + } + + var tempPoint = this.tempPoint; + var tempMatrix = this.tempMatrix; + var global = interactionData.global; + + var length = this.interactiveItems.length; + + for (var i = 0; i < length; i++) + { + var item = this.interactiveItems[i]; + if(!item.visible)continue; + + // TODO this could do with some optimizing! + // maybe store the inverse? + // or do a lazy check first? + //mat3.inverse(item.worldTransform, tempMatrix); + //tempPoint.x = tempMatrix[0] * global.x + tempMatrix[1] * global.y + tempMatrix[2]; + //tempPoint.y = tempMatrix[4] * global.y + tempMatrix[3] * global.x + tempMatrix[5]; + + // OPTIMIZED! assuming the matrix transform is affine.. which it totally shold be! + + var worldTransform = item.worldTransform; + + var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2], + a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5], + id = 1 / (a00 * a11 + a01 * -a10); + + tempPoint.x = a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id; + tempPoint.y = a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id; + + + var x1 = -item.width * item.anchor.x + + if(tempPoint.x > x1 && tempPoint.x < x1 + item.width) + { + var y1 = -item.height * item.anchor.y; + + if(tempPoint.y > y1 && tempPoint.y < y1 + item.height) + { + interactionData.local.x = tempPoint.x; + interactionData.local.y = tempPoint.y; + + return item; + } + } + } + + return null; +} + +PIXI.InteractionManager.prototype.onMouseMove = function(event) +{ + event.preventDefault(); + + // TODO optimize by not check EVERY TIME! maybe half as often? // + var rect = this.target.view.getBoundingClientRect(); + + this.mouse.global.x = (event.clientX - rect.left) * (this.target.width / rect.width); + this.mouse.global.y = (event.clientY - rect.top) * ( this.target.height / rect.height); + + var item = this.hitTest(this.mouse); + + if(this.currentOver != item) + { + if(this.currentOver) + { + if(this.currentOver.mouseout)this.currentOver.mouseout(this.mouse); + this.currentOver = null; + } + + this.target.view.style.cursor = "default"; + } + + if(item) + { + + if(this.currentOver == item)return; + + this.currentOver = item; + this.target.view.style.cursor = "pointer"; + + if(item.mouseover)item.mouseover(this.mouse); + } +} + +PIXI.InteractionManager.prototype.onMouseDown = function(event) +{ + var rect = this.target.view.getBoundingClientRect(); + this.mouse.global.x = (event.clientX - rect.left) * (this.target.width / rect.width); + this.mouse.global.y = (event.clientY - rect.top) * (this.target.height / rect.height); + + var item = this.hitTest(this.mouse); + if(item) + { + this.currentDown = item; + if(item.mousedown)item.mousedown(this.mouse); + } +} + +PIXI.InteractionManager.prototype.onMouseUp = function(event) +{ + if(this.currentDown) + { + if(this.currentDown.mouseup)this.currentDown.mouseup(this.mouse); + + if(this.currentOver == this.currentDown)if(this.currentDown.click)this.currentDown.click(this.mouse); + this.currentDown = null; + } +} + + +PIXI.InteractionManager.prototype.onTouchMove = function(event) +{ + event.preventDefault(); + + var rect = this.target.view.getBoundingClientRect(); + var changedTouches = event.changedTouches; + + for (var i=0; i < changedTouches.length; i++) + { + var touchEvent = changedTouches[i]; + + var touchData = this.touchs[touchEvent.identifier]; + + // update the touch position + touchData.global.x = (touchEvent.clientX - rect.left) * (this.target.width / rect.width); + touchData.global.y = (touchEvent.clientY - rect.top) * (this.target.height / rect.height); + } +} + +PIXI.InteractionManager.prototype.onTouchStart = function(event) +{ + event.preventDefault(); + var rect = this.target.view.getBoundingClientRect(); + var changedTouches = event.changedTouches; + + for (var i=0; i < changedTouches.length; i++) + { + var touchEvent = changedTouches[i]; + + var touchData = this.pool.pop(); + if(!touchData)touchData = new PIXI.InteractionData(); + + this.touchs[touchEvent.identifier] = touchData; + + touchData.global.x = (touchEvent.clientX - rect.left) * (this.target.width / rect.width); + touchData.global.y = (touchEvent.clientY - rect.top) * (this.target.height / rect.height); + + var item = this.hitTest(touchData); + if(item) + { + touchData.currentDown = item; + if(item.touchstart)item.touchstart(touchData); + } + } +} + +PIXI.InteractionManager.prototype.onTouchEnd = function(event) +{ + event.preventDefault(); + + var rect = this.target.view.getBoundingClientRect(); + var changedTouches = event.changedTouches; + + for (var i=0; i < changedTouches.length; i++) + { + var touchEvent = changedTouches[i]; + var touchData = this.touchs[touchEvent.identifier]; + + touchData.global.x = (touchEvent.clientX - rect.left) * (this.target.width / rect.width); + touchData.global.y = (touchEvent.clientY - rect.top) * (this.target.height / rect.height); + + if(touchData.currentDown) + { + if(touchData.currentDown.touchend)touchData.currentDown.touchend(touchData); + + var item = this.hitTest(touchData); + if(item == touchData.currentDown) + { + if(touchData.currentDown.tap)touchData.currentDown.tap(touchData); + } + touchData.currentDown = null; + } + + // remove the touch.. + this.pool.push(touchData); + this.touchs[touchEvent.identifier] = null; + } +} + +/** +@class InteractionData +@constructor +*/ +PIXI.InteractionData = function() +{ + /** + * This point stores the global coords of where the touch/mouse event happened + * @property global + * @type Point + */ + this.global = new PIXI.Point(); + + /** + * This point stores the local coords of where the touch/mouse event happened + * @property local + * @type Point + */ + this.local = new PIXI.Point(); +} + +// constructor +PIXI.InteractionData.constructor = PIXI.InteractionData; + + + ++