Documentation Fix
This commit is contained in:
parent
8093792ed5
commit
4dab30ee17
85 changed files with 16528 additions and 1633 deletions
|
@ -63,14 +63,20 @@
|
|||
|
||||
<li><a href="../classes/InteractionManager.html">InteractionManager</a></li>
|
||||
|
||||
<li><a href="../classes/JsonLoader.html">JsonLoader</a></li>
|
||||
|
||||
<li><a href="../classes/MovieClip.html">MovieClip</a></li>
|
||||
|
||||
<li><a href="../classes/Point.html">Point</a></li>
|
||||
|
||||
<li><a href="../classes/Polygon.html">Polygon</a></li>
|
||||
|
||||
<li><a href="../classes/Rectangle.html">Rectangle</a></li>
|
||||
|
||||
<li><a href="../classes/RenderTexture.html">RenderTexture</a></li>
|
||||
|
||||
<li><a href="../classes/Spine.html">Spine</a></li>
|
||||
|
||||
<li><a href="../classes/Sprite.html">Sprite</a></li>
|
||||
|
||||
<li><a href="../classes/SpriteSheetLoader.html">SpriteSheetLoader</a></li>
|
||||
|
@ -197,25 +203,27 @@ PIXI.InteractionManager.prototype.collectInteractiveSprite = function(displayObj
|
|||
{
|
||||
var child = children[i];
|
||||
|
||||
// push all interactive bits
|
||||
if(child.interactive)
|
||||
{
|
||||
iParent.interactiveChildren = true;
|
||||
//child.__iParent = iParent;
|
||||
this.interactiveItems.push(child);
|
||||
|
||||
if(child.children.length > 0)
|
||||
if(child.visible) {
|
||||
// push all interactive bits
|
||||
if(child.interactive)
|
||||
{
|
||||
this.collectInteractiveSprite(child, child);
|
||||
iParent.interactiveChildren = true;
|
||||
//child.__iParent = iParent;
|
||||
this.interactiveItems.push(child);
|
||||
|
||||
if(child.children.length > 0)
|
||||
{
|
||||
this.collectInteractiveSprite(child, child);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
child.__iParent = null;
|
||||
|
||||
if(child.children.length > 0)
|
||||
else
|
||||
{
|
||||
this.collectInteractiveSprite(child, iParent);
|
||||
child.__iParent = null;
|
||||
|
||||
if(child.children.length > 0)
|
||||
{
|
||||
this.collectInteractiveSprite(child, iParent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -325,8 +333,6 @@ PIXI.InteractionManager.prototype.update = function()
|
|||
|
||||
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();
|
||||
|
||||
|
@ -351,8 +357,6 @@ PIXI.InteractionManager.prototype.onMouseMove = function(event)
|
|||
|
||||
PIXI.InteractionManager.prototype.onMouseDown = function(event)
|
||||
{
|
||||
event.preventDefault();
|
||||
|
||||
// loop through inteaction tree...
|
||||
// hit test each item! ->
|
||||
// get interactive items under point??
|
||||
|
@ -389,7 +393,6 @@ PIXI.InteractionManager.prototype.onMouseDown = function(event)
|
|||
|
||||
PIXI.InteractionManager.prototype.onMouseUp = function(event)
|
||||
{
|
||||
event.preventDefault();
|
||||
var global = this.mouse.global;
|
||||
|
||||
|
||||
|
@ -436,27 +439,66 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
var global = interactionData.global;
|
||||
|
||||
if(!item.visible)return false;
|
||||
|
||||
if(item instanceof PIXI.Sprite)
|
||||
|
||||
var isSprite = (item instanceof PIXI.Sprite),
|
||||
worldTransform = item.worldTransform,
|
||||
a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2],
|
||||
a10 = worldTransform[3], a11 = worldTransform[4], a12 = worldTransform[5],
|
||||
id = 1 / (a00 * a11 + a01 * -a10),
|
||||
x = a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id,
|
||||
y = a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id;
|
||||
|
||||
//a sprite or display object with a hit area defined
|
||||
if(item.hitArea)
|
||||
{
|
||||
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);
|
||||
|
||||
var x = a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id;
|
||||
var y = a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id;
|
||||
|
||||
var width = item.texture.frame.width;
|
||||
var height = item.texture.frame.height;
|
||||
|
||||
var x1 = -width * item.anchor.x;
|
||||
var hitArea = item.hitArea;
|
||||
|
||||
//Polygon hit area
|
||||
if(item.hitArea instanceof PIXI.Polygon) {
|
||||
var inside = false;
|
||||
|
||||
// use some raycasting to test hits
|
||||
// https://github.com/substack/point-in-polygon/blob/master/index.js
|
||||
for(var i = 0, j = item.hitArea.points.length - 1; i < item.hitArea.points.length; j = i++) {
|
||||
var xi = item.hitArea.points[i].x, yi = item.hitArea.points[i].y,
|
||||
xj = item.hitArea.points[j].x, yj = item.hitArea.points[j].y,
|
||||
intersect = ((yi > y) != (yj > y)) && (x < (xj - xi) * (y - yi) / (yj - yi) + xi);
|
||||
|
||||
if(intersect) inside = !inside;
|
||||
}
|
||||
|
||||
if(inside) {
|
||||
if(isSprite) interactionData.target = item;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//Rectangle hit area
|
||||
else {
|
||||
var x1 = hitArea.x;
|
||||
if(x > x1 && x < x1 + hitArea.width)
|
||||
{
|
||||
var y1 = hitArea.y;
|
||||
|
||||
if(y > y1 && y < y1 + hitArea.height)
|
||||
{
|
||||
if(isSprite) interactionData.target = item;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// a sprite with no hitarea defined
|
||||
else if(isSprite)
|
||||
{
|
||||
var width = item.texture.frame.width,
|
||||
height = item.texture.frame.height,
|
||||
x1 = -width * item.anchor.x,
|
||||
y1;
|
||||
|
||||
if(x > x1 && x < x1 + width)
|
||||
{
|
||||
var y1 = -height * item.anchor.y;
|
||||
|
||||
y1 = -height * item.anchor.y;
|
||||
|
||||
if(y > y1 && y < y1 + height)
|
||||
{
|
||||
// set the target property if a hit is true!
|
||||
|
@ -465,30 +507,7 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
}
|
||||
}
|
||||
}
|
||||
else if(item.hitArea)
|
||||
{
|
||||
var worldTransform = item.worldTransform;
|
||||
var hitArea = item.hitArea;
|
||||
|
||||
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);
|
||||
|
||||
var x = a11 * id * global.x + -a01 * id * global.y + (a12 * a01 - a02 * a11) * id;
|
||||
var y = a00 * id * global.y + -a10 * id * global.x + (-a12 * a00 + a02 * a10) * id;
|
||||
|
||||
var x1 = hitArea.x;
|
||||
if(x > x1 && x < x1 + hitArea.width)
|
||||
{
|
||||
var y1 = hitArea.y;
|
||||
|
||||
if(y > y1 && y < y1 + hitArea.height)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var length = item.children.length;
|
||||
|
||||
for (var i = 0; i < length; i++)
|
||||
|
@ -497,7 +516,7 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
var hit = this.hitTest(tempItem, interactionData);
|
||||
if(hit)return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -505,8 +524,6 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
|
||||
PIXI.InteractionManager.prototype.onTouchMove = function(event)
|
||||
{
|
||||
event.preventDefault();
|
||||
|
||||
var rect = this.target.view.getBoundingClientRect();
|
||||
var changedTouches = event.changedTouches;
|
||||
|
||||
|
@ -530,7 +547,6 @@ PIXI.InteractionManager.prototype.onTouchMove = function(event)
|
|||
|
||||
PIXI.InteractionManager.prototype.onTouchStart = function(event)
|
||||
{
|
||||
event.preventDefault();
|
||||
var rect = this.target.view.getBoundingClientRect();
|
||||
|
||||
var changedTouches = event.changedTouches;
|
||||
|
@ -572,9 +588,6 @@ PIXI.InteractionManager.prototype.onTouchStart = function(event)
|
|||
|
||||
PIXI.InteractionManager.prototype.onTouchEnd = function(event)
|
||||
{
|
||||
event.preventDefault();
|
||||
|
||||
|
||||
var rect = this.target.view.getBoundingClientRect();
|
||||
var changedTouches = event.changedTouches;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue