Documentation Fix
This commit is contained in:
parent
8093792ed5
commit
4dab30ee17
85 changed files with 16528 additions and 1633 deletions
197
bin/pixi.dev.js
197
bin/pixi.dev.js
|
@ -4,7 +4,7 @@
|
|||
* Copyright (c) 2012, Mat Groves
|
||||
* http://goodboydigital.com/
|
||||
*
|
||||
* Compiled: 2013-06-12
|
||||
* Compiled: 2013-06-19
|
||||
*
|
||||
* Pixi.JS is licensed under the MIT License.
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
|
@ -124,6 +124,37 @@ PIXI.Rectangle.prototype.clone = function()
|
|||
PIXI.Rectangle.constructor = PIXI.Rectangle;
|
||||
|
||||
|
||||
/**
|
||||
* @author Adrien Brault <adrien.brault@gmail.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class Polygon
|
||||
* @constructor
|
||||
* @param points {Array}
|
||||
*/
|
||||
PIXI.Polygon = function(points)
|
||||
{
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
/**
|
||||
* @method clone
|
||||
* @return a copy of the polygon
|
||||
*/
|
||||
PIXI.Polygon.clone = function()
|
||||
{
|
||||
var points = [];
|
||||
for (var i=0; i<this.points.length; i++) {
|
||||
points.push(this.points[i].clone());
|
||||
}
|
||||
|
||||
return new PIXI.Polygon(points);
|
||||
}
|
||||
|
||||
PIXI.Polygon.constructor = PIXI.Polygon;
|
||||
|
||||
|
||||
/**
|
||||
* @author Mat Groves http://matgroves.com/ @Doormat23
|
||||
*/
|
||||
|
@ -956,7 +987,7 @@ PIXI.Text.prototype = Object.create(PIXI.Sprite.prototype);
|
|||
* @param {String} [style.font="bold 20pt Arial"] The style and size of the font
|
||||
* @param {Object} [style.fill="black"] A canvas fillstyle that will be used on the text eg "red", "#00FF00"
|
||||
* @param {String} [style.align="left"] An alignment of the multiline text ("left", "center" or "right")
|
||||
* @param {String} [style.stroke] A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00"
|
||||
* @param {String} [style.stroke="black"] A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00"
|
||||
* @param {Number} [style.strokeThickness=0] A number that represents the thickness of the stroke. Default is 0 (no stroke)
|
||||
* @param {Boolean} [style.wordWrap=false] Indicates if word wrap should be used
|
||||
* @param {Number} [style.wordWrapWidth=100] The width at which text will wrap
|
||||
|
@ -967,6 +998,7 @@ PIXI.Text.prototype.setStyle = function(style)
|
|||
style.font = style.font || "bold 20pt Arial";
|
||||
style.fill = style.fill || "black";
|
||||
style.align = style.align || "left";
|
||||
style.stroke = style.stroke || "black"; //provide a default, see: https://github.com/GoodBoyDigital/pixi.js/issues/136
|
||||
style.strokeThickness = style.strokeThickness || 0;
|
||||
style.wordWrap = style.wordWrap || false;
|
||||
style.wordWrapWidth = style.wordWrapWidth || 100;
|
||||
|
@ -1102,7 +1134,7 @@ PIXI.Text.prototype.determineFontHeight = function(fontStyle)
|
|||
var dummy = document.createElement("div");
|
||||
var dummyText = document.createTextNode("M");
|
||||
dummy.appendChild(dummyText);
|
||||
dummy.setAttribute("style", fontStyle);
|
||||
dummy.setAttribute("style", fontStyle + ';position:absolute;top:0;left:0');
|
||||
body.appendChild(dummy);
|
||||
|
||||
result = dummy.offsetHeight;
|
||||
|
@ -1301,11 +1333,11 @@ PIXI.BitmapText.prototype.updateText = function()
|
|||
|
||||
for(i = 0; i < chars.length; i++)
|
||||
{
|
||||
var char = new PIXI.Sprite(chars[i].texture)//PIXI.Sprite.fromFrame(chars[i].charCode);
|
||||
char.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
|
||||
char.position.y = chars[i].position.y * scale;
|
||||
char.scale.x = char.scale.y = scale;
|
||||
this.addChild(char);
|
||||
var c = new PIXI.Sprite(chars[i].texture)//PIXI.Sprite.fromFrame(chars[i].charCode);
|
||||
c.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
|
||||
c.position.y = chars[i].position.y * scale;
|
||||
c.scale.x = c.scale.y = scale;
|
||||
this.addChild(c);
|
||||
}
|
||||
|
||||
this.width = pos.x * scale;
|
||||
|
@ -1397,6 +1429,7 @@ PIXI.InteractionManager.prototype.collectInteractiveSprite = function(displayObj
|
|||
{
|
||||
var child = children[i];
|
||||
|
||||
if(child.visible) {
|
||||
// push all interactive bits
|
||||
if(child.interactive)
|
||||
{
|
||||
|
@ -1420,6 +1453,7 @@ PIXI.InteractionManager.prototype.collectInteractiveSprite = function(displayObj
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PIXI.InteractionManager.prototype.setTarget = function(target)
|
||||
{
|
||||
|
@ -1525,8 +1559,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();
|
||||
|
||||
|
@ -1551,8 +1583,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??
|
||||
|
@ -1589,7 +1619,6 @@ PIXI.InteractionManager.prototype.onMouseDown = function(event)
|
|||
|
||||
PIXI.InteractionManager.prototype.onMouseUp = function(event)
|
||||
{
|
||||
event.preventDefault();
|
||||
var global = this.mouse.global;
|
||||
|
||||
|
||||
|
@ -1637,46 +1666,40 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
|
||||
if(!item.visible)return false;
|
||||
|
||||
if(item instanceof PIXI.Sprite)
|
||||
{
|
||||
var worldTransform = item.worldTransform;
|
||||
|
||||
var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2],
|
||||
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);
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
if(x > x1 && x < x1 + width)
|
||||
//a sprite or display object with a hit area defined
|
||||
if(item.hitArea)
|
||||
{
|
||||
var y1 = -height * item.anchor.y;
|
||||
var hitArea = item.hitArea;
|
||||
|
||||
if(y > y1 && y < y1 + height)
|
||||
{
|
||||
// set the target property if a hit is true!
|
||||
interactionData.target = item
|
||||
//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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
||||
//Rectangle hit area
|
||||
else {
|
||||
var x1 = hitArea.x;
|
||||
if(x > x1 && x < x1 + hitArea.width)
|
||||
{
|
||||
|
@ -1684,6 +1707,28 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
|
||||
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)
|
||||
{
|
||||
y1 = -height * item.anchor.y;
|
||||
|
||||
if(y > y1 && y < y1 + height)
|
||||
{
|
||||
// set the target property if a hit is true!
|
||||
interactionData.target = item
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1705,8 +1750,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;
|
||||
|
||||
|
@ -1730,7 +1773,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;
|
||||
|
@ -1772,9 +1814,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;
|
||||
|
||||
|
@ -1956,7 +1995,9 @@ PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor)
|
|||
{
|
||||
this.backgroundColor = backgroundColor || 0x000000;
|
||||
this.backgroundColorSplit = HEXtoRGB(this.backgroundColor);
|
||||
this.backgroundColorString = "#" + this.backgroundColor.toString(16);
|
||||
var hex = this.backgroundColor.toString(16);
|
||||
hex = "000000".substr(0, 6 - hex.length) + hex;
|
||||
this.backgroundColorString = "#" + hex;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2001,19 +2042,38 @@ PIXI.Stage.prototype.__removeChild = function(child)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides requestAnimationFrame in a cross browser way.
|
||||
*/
|
||||
window.requestAnimFrame = (function() {
|
||||
return window.requestAnimationFrame ||
|
||||
window.webkitRequestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame ||
|
||||
window.oRequestAnimationFrame ||
|
||||
window.msRequestAnimationFrame ||
|
||||
function(/* function FrameRequestCallback */ callback, /* DOMElement Element */ element) {
|
||||
window.setTimeout(callback, 1000/60);
|
||||
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
|
||||
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
|
||||
|
||||
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
|
||||
|
||||
// MIT license
|
||||
|
||||
|
||||
var lastTime = 0;
|
||||
var vendors = ['ms', 'moz', 'webkit', 'o'];
|
||||
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
||||
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
|
||||
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
|
||||
|| window[vendors[x]+'CancelRequestAnimationFrame'];
|
||||
}
|
||||
|
||||
if (!window.requestAnimationFrame)
|
||||
window.requestAnimationFrame = function(callback, element) {
|
||||
var currTime = new Date().getTime();
|
||||
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
||||
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
|
||||
timeToCall);
|
||||
lastTime = currTime + timeToCall;
|
||||
return id;
|
||||
};
|
||||
})();
|
||||
|
||||
if (!window.cancelAnimationFrame)
|
||||
window.cancelAnimationFrame = function(id) {
|
||||
clearTimeout(id);
|
||||
};
|
||||
|
||||
window.requestAnimFrame = window.requestAnimationFrame;
|
||||
|
||||
function HEXtoRGB(hex) {
|
||||
return [(hex >> 16 & 0xFF) / 255, ( hex >> 8 & 0xFF) / 255, (hex & 0xFF)/ 255];
|
||||
|
@ -2045,7 +2105,7 @@ if (typeof Function.prototype.bind != 'function') {
|
|||
})();
|
||||
}
|
||||
|
||||
var AjaxRequest = function()
|
||||
var AjaxRequest = PIXI.AjaxRequest = function()
|
||||
{
|
||||
var activexmodes = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE
|
||||
|
||||
|
@ -4488,10 +4548,13 @@ PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject)
|
|||
}
|
||||
|
||||
// render!
|
||||
if(displayObject.children)
|
||||
{
|
||||
for (var i=0; i < displayObject.children.length; i++)
|
||||
{
|
||||
this.renderDisplayObject(displayObject.children[i]);
|
||||
}
|
||||
}
|
||||
|
||||
this.context.setTransform(1,0,0,1,0,0);
|
||||
}
|
||||
|
@ -7439,7 +7502,7 @@ PIXI.BitmapFontLoader.prototype.onLoaded = function()
|
|||
* When loaded this class will dispatch a "loaded" event
|
||||
* @class Spine
|
||||
* @constructor
|
||||
* @extends
|
||||
* @extends EventTarget
|
||||
* @param {String} url the url of the sprite sheet JSON file
|
||||
* @param {Boolean} crossorigin
|
||||
*/
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -12,10 +12,13 @@ YUI.add("yuidoc-meta", function(Y) {
|
|||
"ImageLoader",
|
||||
"InteractionData",
|
||||
"InteractionManager",
|
||||
"JsonLoader",
|
||||
"MovieClip",
|
||||
"Point",
|
||||
"Polygon",
|
||||
"Rectangle",
|
||||
"RenderTexture",
|
||||
"Spine",
|
||||
"Sprite",
|
||||
"SpriteSheetLoader",
|
||||
"Stage",
|
||||
|
|
|
@ -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>
|
||||
|
@ -401,7 +407,7 @@ As each individual item is loaded this class will dispatch a "onProgress" event<
|
|||
|
||||
|
||||
|
||||
<a href="../files/src_pixi_loaders_AssetLoader.js.html#l43"><code>src/pixi/loaders/AssetLoader.js:43</code></a>
|
||||
<a href="../files/src_pixi_loaders_AssetLoader.js.html#l46"><code>src/pixi/loaders/AssetLoader.js:46</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
@ -444,7 +450,7 @@ As each individual item is loaded this class will dispatch a "onProgress" event<
|
|||
|
||||
|
||||
|
||||
<a href="../files/src_pixi_loaders_AssetLoader.js.html#l38"><code>src/pixi/loaders/AssetLoader.js:38</code></a>
|
||||
<a href="../files/src_pixi_loaders_AssetLoader.js.html#l41"><code>src/pixi/loaders/AssetLoader.js:41</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
@ -377,7 +383,7 @@
|
|||
|
||||
|
||||
|
||||
<a href="../files/src_pixi_textures_BaseTexture.js.html#l103"><code>src/pixi/textures/BaseTexture.js:103</code></a>
|
||||
<a href="../files/src_pixi_textures_BaseTexture.js.html#l101"><code>src/pixi/textures/BaseTexture.js:101</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
@ -136,7 +142,7 @@
|
|||
|
||||
|
||||
<div class="foundat">
|
||||
Defined in: <a href="../files/src_pixi_InteractionManager.js.html#l506"><code>src/pixi/InteractionManager.js:506</code></a>
|
||||
Defined in: <a href="../files/src_pixi_InteractionManager.js.html#l513"><code>src/pixi/InteractionManager.js:513</code></a>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -190,7 +196,7 @@
|
|||
|
||||
|
||||
|
||||
<a href="../files/src_pixi_InteractionManager.js.html#l506"><code>src/pixi/InteractionManager.js:506</code></a>
|
||||
<a href="../files/src_pixi_InteractionManager.js.html#l513"><code>src/pixi/InteractionManager.js:513</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
@ -329,7 +335,7 @@
|
|||
|
||||
|
||||
|
||||
<a href="../files/src_pixi_InteractionManager.js.html#l530"><code>src/pixi/InteractionManager.js:530</code></a>
|
||||
<a href="../files/src_pixi_InteractionManager.js.html#l537"><code>src/pixi/InteractionManager.js:537</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
@ -418,7 +424,7 @@
|
|||
|
||||
|
||||
|
||||
<a href="../files/src_pixi_InteractionManager.js.html#l512"><code>src/pixi/InteractionManager.js:512</code></a>
|
||||
<a href="../files/src_pixi_InteractionManager.js.html#l519"><code>src/pixi/InteractionManager.js:519</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
@ -462,7 +468,7 @@
|
|||
|
||||
|
||||
|
||||
<a href="../files/src_pixi_InteractionManager.js.html#l522"><code>src/pixi/InteractionManager.js:522</code></a>
|
||||
<a href="../files/src_pixi_InteractionManager.js.html#l529"><code>src/pixi/InteractionManager.js:529</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
331
docs/classes/JsonLoader.html
Normal file
331
docs/classes/JsonLoader.html
Normal file
|
@ -0,0 +1,331 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>JsonLoader - Pixi.JS</title>
|
||||
<link rel="stylesheet" href="http://yui.yahooapis.com/3.8.0/build/cssgrids/cssgrids-min.css">
|
||||
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
|
||||
<link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
|
||||
<link rel="shortcut icon" type="image/png" href="../assets/favicon.png">
|
||||
<script src="http://yui.yahooapis.com/combo?3.8.0/build/yui/yui-min.js"></script>
|
||||
</head>
|
||||
<body class="yui3-skin-sam">
|
||||
|
||||
<div id="doc">
|
||||
<div id="hd" class="yui3-g header">
|
||||
<div class="yui3-u-3-4">
|
||||
|
||||
<h1><img src="http://www.goodboydigital.com/pixijs/logo_small.png" title="Pixi.JS"></h1>
|
||||
|
||||
</div>
|
||||
<div class="yui3-u-1-4 version">
|
||||
<em>API Docs for: 1.0.0</em>
|
||||
</div>
|
||||
</div>
|
||||
<div id="bd" class="yui3-g">
|
||||
|
||||
<div class="yui3-u-1-4">
|
||||
<div id="docs-sidebar" class="sidebar apidocs">
|
||||
<div id="api-list">
|
||||
<h2 class="off-left">APIs</h2>
|
||||
<div id="api-tabview" class="tabview">
|
||||
<ul class="tabs">
|
||||
<li><a href="#api-classes">Classes</a></li>
|
||||
<li><a href="#api-modules">Modules</a></li>
|
||||
</ul>
|
||||
|
||||
<div id="api-tabview-filter">
|
||||
<input type="search" id="api-filter" placeholder="Type to filter APIs">
|
||||
</div>
|
||||
|
||||
<div id="api-tabview-panel">
|
||||
<ul id="api-classes" class="apis classes">
|
||||
|
||||
<li><a href="../classes/AssetLoader.html">AssetLoader</a></li>
|
||||
|
||||
<li><a href="../classes/BaseTexture.html">BaseTexture</a></li>
|
||||
|
||||
<li><a href="../classes/BitmapFontLoader.html">BitmapFontLoader</a></li>
|
||||
|
||||
<li><a href="../classes/BitmapText.html">BitmapText</a></li>
|
||||
|
||||
<li><a href="../classes/CanvasRenderer.html">CanvasRenderer</a></li>
|
||||
|
||||
<li><a href="../classes/CustomRenderable.html">CustomRenderable</a></li>
|
||||
|
||||
<li><a href="../classes/DisplayObject.html">DisplayObject</a></li>
|
||||
|
||||
<li><a href="../classes/DisplayObjectContainer.html">DisplayObjectContainer</a></li>
|
||||
|
||||
<li><a href="../classes/ImageLoader.html">ImageLoader</a></li>
|
||||
|
||||
<li><a href="../classes/InteractionData.html">InteractionData</a></li>
|
||||
|
||||
<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>
|
||||
|
||||
<li><a href="../classes/Stage.html">Stage</a></li>
|
||||
|
||||
<li><a href="../classes/Text.html">Text</a></li>
|
||||
|
||||
<li><a href="../classes/Texture.html">Texture</a></li>
|
||||
|
||||
<li><a href="../classes/TilingSprite.html">TilingSprite</a></li>
|
||||
|
||||
<li><a href="../classes/WebGLBatch.html">WebGLBatch</a></li>
|
||||
|
||||
<li><a href="../classes/WebGLRenderer.html">WebGLRenderer</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
<ul id="api-modules" class="apis modules">
|
||||
|
||||
<li><a href="../modules/PIXI.html">PIXI</a></li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="yui3-u-3-4">
|
||||
<div id="api-options">
|
||||
Show:
|
||||
<label for="api-show-inherited">
|
||||
<input type="checkbox" id="api-show-inherited" checked>
|
||||
Inherited
|
||||
</label>
|
||||
|
||||
<label for="api-show-protected">
|
||||
<input type="checkbox" id="api-show-protected">
|
||||
Protected
|
||||
</label>
|
||||
|
||||
<label for="api-show-private">
|
||||
<input type="checkbox" id="api-show-private">
|
||||
Private
|
||||
</label>
|
||||
<label for="api-show-deprecated">
|
||||
<input type="checkbox" id="api-show-deprecated">
|
||||
Deprecated
|
||||
</label>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="apidocs">
|
||||
<div id="docs-main">
|
||||
<div class="content">
|
||||
<h1>JsonLoader Class</h1>
|
||||
<div class="box meta">
|
||||
|
||||
|
||||
|
||||
<div class="extends">
|
||||
Extends EventTarget
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="foundat">
|
||||
Defined in: <a href="../files/src_pixi_loaders_JsonLoader.js.html#l5"><code>src/pixi/loaders/JsonLoader.js:5</code></a>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
Module: <a href="../modules/PIXI.html">PIXI</a>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="box intro">
|
||||
<p>The json file loader is used to load in JSON data and parsing it
|
||||
When loaded this class will dispatch a "loaded" event
|
||||
If load failed this class will dispatch a "error" event</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="constructor">
|
||||
<h2>Constructor</h2>
|
||||
<div id="method_JsonLoader" class="method item">
|
||||
<h3 class="name"><code>JsonLoader</code></h3>
|
||||
|
||||
|
||||
<div class="args">
|
||||
<span class="paren">(</span><ul class="args-list inline commas">
|
||||
|
||||
<li class="arg">
|
||||
|
||||
<code>url</code>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="arg">
|
||||
|
||||
<code>crossorigin</code>
|
||||
|
||||
</li>
|
||||
|
||||
</ul><span class="paren">)</span>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="meta">
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
|
||||
Defined in
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="../files/src_pixi_loaders_JsonLoader.js.html#l5"><code>src/pixi/loaders/JsonLoader.js:5</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="params">
|
||||
<h4>Parameters:</h4>
|
||||
|
||||
<ul class="params-list">
|
||||
|
||||
<li class="param">
|
||||
|
||||
<code class="param-name">url</code>
|
||||
<span class="type">String</span>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="param-description">
|
||||
<p>the url of the JSON file</p>
|
||||
</div>
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="param">
|
||||
|
||||
<code class="param-name">crossorigin</code>
|
||||
<span class="type">Boolean</span>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="param-description">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div id="classdocs" class="tabview">
|
||||
<ul class="api-class-tabs">
|
||||
<li class="api-class-tab index"><a href="#index">Index</a></li>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
<div>
|
||||
<div id="index" class="api-class-tabpanel index">
|
||||
<h2 class="off-left">Item Index</h2>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="../assets/vendor/prettify/prettify-min.js"></script>
|
||||
<script>prettyPrint();</script>
|
||||
<script src="../assets/js/yui-prettify.js"></script>
|
||||
<script src="../assets/../api.js"></script>
|
||||
<script src="../assets/js/api-filter.js"></script>
|
||||
<script src="../assets/js/api-list.js"></script>
|
||||
<script src="../assets/js/api-search.js"></script>
|
||||
<script src="../assets/js/apidocs.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
396
docs/classes/Polygon.html
Normal file
396
docs/classes/Polygon.html
Normal file
|
@ -0,0 +1,396 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Polygon - Pixi.JS</title>
|
||||
<link rel="stylesheet" href="http://yui.yahooapis.com/3.8.0/build/cssgrids/cssgrids-min.css">
|
||||
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
|
||||
<link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
|
||||
<link rel="shortcut icon" type="image/png" href="../assets/favicon.png">
|
||||
<script src="http://yui.yahooapis.com/combo?3.8.0/build/yui/yui-min.js"></script>
|
||||
</head>
|
||||
<body class="yui3-skin-sam">
|
||||
|
||||
<div id="doc">
|
||||
<div id="hd" class="yui3-g header">
|
||||
<div class="yui3-u-3-4">
|
||||
|
||||
<h1><img src="http://www.goodboydigital.com/pixijs/logo_small.png" title="Pixi.JS"></h1>
|
||||
|
||||
</div>
|
||||
<div class="yui3-u-1-4 version">
|
||||
<em>API Docs for: 1.0.0</em>
|
||||
</div>
|
||||
</div>
|
||||
<div id="bd" class="yui3-g">
|
||||
|
||||
<div class="yui3-u-1-4">
|
||||
<div id="docs-sidebar" class="sidebar apidocs">
|
||||
<div id="api-list">
|
||||
<h2 class="off-left">APIs</h2>
|
||||
<div id="api-tabview" class="tabview">
|
||||
<ul class="tabs">
|
||||
<li><a href="#api-classes">Classes</a></li>
|
||||
<li><a href="#api-modules">Modules</a></li>
|
||||
</ul>
|
||||
|
||||
<div id="api-tabview-filter">
|
||||
<input type="search" id="api-filter" placeholder="Type to filter APIs">
|
||||
</div>
|
||||
|
||||
<div id="api-tabview-panel">
|
||||
<ul id="api-classes" class="apis classes">
|
||||
|
||||
<li><a href="../classes/AssetLoader.html">AssetLoader</a></li>
|
||||
|
||||
<li><a href="../classes/BaseTexture.html">BaseTexture</a></li>
|
||||
|
||||
<li><a href="../classes/BitmapFontLoader.html">BitmapFontLoader</a></li>
|
||||
|
||||
<li><a href="../classes/BitmapText.html">BitmapText</a></li>
|
||||
|
||||
<li><a href="../classes/CanvasRenderer.html">CanvasRenderer</a></li>
|
||||
|
||||
<li><a href="../classes/CustomRenderable.html">CustomRenderable</a></li>
|
||||
|
||||
<li><a href="../classes/DisplayObject.html">DisplayObject</a></li>
|
||||
|
||||
<li><a href="../classes/DisplayObjectContainer.html">DisplayObjectContainer</a></li>
|
||||
|
||||
<li><a href="../classes/ImageLoader.html">ImageLoader</a></li>
|
||||
|
||||
<li><a href="../classes/InteractionData.html">InteractionData</a></li>
|
||||
|
||||
<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>
|
||||
|
||||
<li><a href="../classes/Stage.html">Stage</a></li>
|
||||
|
||||
<li><a href="../classes/Text.html">Text</a></li>
|
||||
|
||||
<li><a href="../classes/Texture.html">Texture</a></li>
|
||||
|
||||
<li><a href="../classes/TilingSprite.html">TilingSprite</a></li>
|
||||
|
||||
<li><a href="../classes/WebGLBatch.html">WebGLBatch</a></li>
|
||||
|
||||
<li><a href="../classes/WebGLRenderer.html">WebGLRenderer</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
<ul id="api-modules" class="apis modules">
|
||||
|
||||
<li><a href="../modules/PIXI.html">PIXI</a></li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="yui3-u-3-4">
|
||||
<div id="api-options">
|
||||
Show:
|
||||
<label for="api-show-inherited">
|
||||
<input type="checkbox" id="api-show-inherited" checked>
|
||||
Inherited
|
||||
</label>
|
||||
|
||||
<label for="api-show-protected">
|
||||
<input type="checkbox" id="api-show-protected">
|
||||
Protected
|
||||
</label>
|
||||
|
||||
<label for="api-show-private">
|
||||
<input type="checkbox" id="api-show-private">
|
||||
Private
|
||||
</label>
|
||||
<label for="api-show-deprecated">
|
||||
<input type="checkbox" id="api-show-deprecated">
|
||||
Deprecated
|
||||
</label>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="apidocs">
|
||||
<div id="docs-main">
|
||||
<div class="content">
|
||||
<h1>Polygon Class</h1>
|
||||
<div class="box meta">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="foundat">
|
||||
Defined in: <a href="../files/src_pixi_Polygon.js.html#l5"><code>src/pixi/Polygon.js:5</code></a>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
Module: <a href="../modules/PIXI.html">PIXI</a>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="box intro">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="constructor">
|
||||
<h2>Constructor</h2>
|
||||
<div id="method_Polygon" class="method item">
|
||||
<h3 class="name"><code>Polygon</code></h3>
|
||||
|
||||
|
||||
<div class="args">
|
||||
<span class="paren">(</span><ul class="args-list inline commas">
|
||||
|
||||
<li class="arg">
|
||||
|
||||
<code>points</code>
|
||||
|
||||
</li>
|
||||
|
||||
</ul><span class="paren">)</span>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="meta">
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
|
||||
Defined in
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="../files/src_pixi_Polygon.js.html#l5"><code>src/pixi/Polygon.js:5</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="params">
|
||||
<h4>Parameters:</h4>
|
||||
|
||||
<ul class="params-list">
|
||||
|
||||
<li class="param">
|
||||
|
||||
<code class="param-name">points</code>
|
||||
<span class="type">Array</span>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="param-description">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div id="classdocs" class="tabview">
|
||||
<ul class="api-class-tabs">
|
||||
<li class="api-class-tab index"><a href="#index">Index</a></li>
|
||||
|
||||
|
||||
<li class="api-class-tab methods"><a href="#methods">Methods</a></li>
|
||||
|
||||
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
<div>
|
||||
<div id="index" class="api-class-tabpanel index">
|
||||
<h2 class="off-left">Item Index</h2>
|
||||
|
||||
|
||||
<div class="index-section methods">
|
||||
<h3>Methods</h3>
|
||||
|
||||
<ul class="index-list methods">
|
||||
|
||||
<li class="index-item method">
|
||||
<a href="#method_clone">clone</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div id="methods" class="api-class-tabpanel">
|
||||
<h2 class="off-left">Methods</h2>
|
||||
|
||||
|
||||
<div id="method_clone" class="method item">
|
||||
<h3 class="name"><code>clone</code></h3>
|
||||
|
||||
|
||||
<span class="paren">()</span>
|
||||
|
||||
|
||||
|
||||
<span class="returns-inline">
|
||||
<span class="type"></span>
|
||||
</span>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="meta">
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
|
||||
Defined in
|
||||
|
||||
|
||||
|
||||
|
||||
<a href="../files/src_pixi_Polygon.js.html#l15"><code>src/pixi/Polygon.js:15</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="description">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="returns">
|
||||
<h4>Returns:</h4>
|
||||
|
||||
<div class="returns-description">
|
||||
|
||||
|
||||
a copy of the polygon
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="../assets/vendor/prettify/prettify-min.js"></script>
|
||||
<script>prettyPrint();</script>
|
||||
<script src="../assets/js/yui-prettify.js"></script>
|
||||
<script src="../assets/../api.js"></script>
|
||||
<script src="../assets/js/api-filter.js"></script>
|
||||
<script src="../assets/js/api-list.js"></script>
|
||||
<script src="../assets/js/api-search.js"></script>
|
||||
<script src="../assets/js/apidocs.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
@ -547,7 +553,7 @@
|
|||
|
||||
|
||||
<div class="param-description">
|
||||
<p>If true the texture will not be cleared before the displayObject is drawn</p>
|
||||
<p>If true the texture will be cleared before the displayObject is drawn</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
|
2376
docs/classes/Spine.html
Normal file
2376
docs/classes/Spine.html
Normal file
File diff suppressed because it is too large
Load diff
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
@ -923,7 +929,7 @@
|
|||
|
||||
|
||||
|
||||
<a href="../files/src_pixi_Stage.js.html#l72"><code>src/pixi/Stage.js:72</code></a>
|
||||
<a href="../files/src_pixi_Stage.js.html#l76"><code>src/pixi/Stage.js:76</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
@ -1506,7 +1512,7 @@ for this callback to be fired, The touch must have started over the displayObjec
|
|||
|
||||
|
||||
|
||||
<a href="../files/src_pixi_Stage.js.html#l61"><code>src/pixi/Stage.js:61</code></a>
|
||||
<a href="../files/src_pixi_Stage.js.html#l63"><code>src/pixi/Stage.js:63</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
@ -2110,7 +2116,7 @@ for this callback to be fired, The touch must have started over the sprite</p>
|
|||
|
||||
|
||||
|
||||
<a href="../files/src_pixi_Stage.js.html#l38"><code>src/pixi/Stage.js:38</code></a>
|
||||
<a href="../files/src_pixi_Stage.js.html#l40"><code>src/pixi/Stage.js:40</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
@ -331,6 +337,34 @@
|
|||
|
||||
</li>
|
||||
|
||||
<li class="param">
|
||||
|
||||
<code class="param-name optional">[wordWrap=false]</code>
|
||||
<span class="type">Boolean</span>
|
||||
<span class="flag optional" title="This parameter is optional.">optional</span>
|
||||
|
||||
|
||||
<div class="param-description">
|
||||
<p>Indicates if word wrap should be used</p>
|
||||
</div>
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="param">
|
||||
|
||||
<code class="param-name optional">[wordWrapWidth=100]</code>
|
||||
<span class="type">Number</span>
|
||||
<span class="flag optional" title="This parameter is optional.">optional</span>
|
||||
|
||||
|
||||
<div class="param-description">
|
||||
<p>The width at which text will wrap</p>
|
||||
</div>
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
@ -1628,7 +1662,7 @@ for this callback to be fired, The touch must have started over the displayObjec
|
|||
|
||||
|
||||
|
||||
<a href="../files/src_pixi_text_Text.js.html#l35"><code>src/pixi/text/Text.js:35</code></a>
|
||||
<a href="../files/src_pixi_text_Text.js.html#l37"><code>src/pixi/text/Text.js:37</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
@ -1694,7 +1728,7 @@ for this callback to be fired, The touch must have started over the displayObjec
|
|||
|
||||
<li class="param">
|
||||
|
||||
<code class="param-name optional">[stroke]</code>
|
||||
<code class="param-name optional">[stroke="black"]</code>
|
||||
<span class="type">String</span>
|
||||
<span class="flag optional" title="This parameter is optional.">optional</span>
|
||||
|
||||
|
@ -1720,6 +1754,34 @@ for this callback to be fired, The touch must have started over the displayObjec
|
|||
|
||||
</li>
|
||||
|
||||
<li class="param">
|
||||
|
||||
<code class="param-name optional">[wordWrap=false]</code>
|
||||
<span class="type">Boolean</span>
|
||||
<span class="flag optional" title="This parameter is optional.">optional</span>
|
||||
|
||||
|
||||
<div class="param-description">
|
||||
<p>Indicates if word wrap should be used</p>
|
||||
</div>
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="param">
|
||||
|
||||
<code class="param-name optional">[wordWrapWidth=100]</code>
|
||||
<span class="type">Number</span>
|
||||
<span class="flag optional" title="This parameter is optional.">optional</span>
|
||||
|
||||
|
||||
<div class="param-description">
|
||||
<p>The width at which text will wrap</p>
|
||||
</div>
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
@ -604,7 +610,7 @@ if a group of sprites all have the same baseTexture and blendMode then they can
|
|||
|
||||
|
||||
|
||||
<a href="../files/src_pixi_renderers_WebGLBatch.js.html#l267"><code>src/pixi/renderers/WebGLBatch.js:267</code></a>
|
||||
<a href="../files/src_pixi_renderers_WebGLBatch.js.html#l268"><code>src/pixi/renderers/WebGLBatch.js:268</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
@ -681,7 +687,7 @@ if a group of sprites all have the same baseTexture and blendMode then they can
|
|||
|
||||
|
||||
|
||||
<a href="../files/src_pixi_renderers_WebGLBatch.js.html#l345"><code>src/pixi/renderers/WebGLBatch.js:345</code></a>
|
||||
<a href="../files/src_pixi_renderers_WebGLBatch.js.html#l346"><code>src/pixi/renderers/WebGLBatch.js:346</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
@ -980,7 +986,7 @@ if a group of sprites all have the same baseTexture and blendMode then they can
|
|||
|
||||
|
||||
|
||||
<a href="../files/src_pixi_renderers_WebGLBatch.js.html#l400"><code>src/pixi/renderers/WebGLBatch.js:400</code></a>
|
||||
<a href="../files/src_pixi_renderers_WebGLBatch.js.html#l401"><code>src/pixi/renderers/WebGLBatch.js:401</code></a>
|
||||
|
||||
</p>
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
606
docs/data.json
606
docs/data.json
File diff suppressed because it is too large
Load diff
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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,6 +203,7 @@ PIXI.InteractionManager.prototype.collectInteractiveSprite = function(displayObj
|
|||
{
|
||||
var child = children[i];
|
||||
|
||||
if(child.visible) {
|
||||
// push all interactive bits
|
||||
if(child.interactive)
|
||||
{
|
||||
|
@ -220,6 +227,7 @@ PIXI.InteractionManager.prototype.collectInteractiveSprite = function(displayObj
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PIXI.InteractionManager.prototype.setTarget = function(target)
|
||||
{
|
||||
|
@ -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;
|
||||
|
||||
|
||||
|
@ -437,46 +440,40 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
|
||||
if(!item.visible)return false;
|
||||
|
||||
if(item instanceof PIXI.Sprite)
|
||||
{
|
||||
var worldTransform = item.worldTransform;
|
||||
|
||||
var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2],
|
||||
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);
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
if(x > x1 && x < x1 + width)
|
||||
//a sprite or display object with a hit area defined
|
||||
if(item.hitArea)
|
||||
{
|
||||
var y1 = -height * item.anchor.y;
|
||||
var hitArea = item.hitArea;
|
||||
|
||||
if(y > y1 && y < y1 + height)
|
||||
{
|
||||
// set the target property if a hit is true!
|
||||
interactionData.target = item
|
||||
//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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
||||
//Rectangle hit area
|
||||
else {
|
||||
var x1 = hitArea.x;
|
||||
if(x > x1 && x < x1 + hitArea.width)
|
||||
{
|
||||
|
@ -484,6 +481,28 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
|
||||
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)
|
||||
{
|
||||
y1 = -height * item.anchor.y;
|
||||
|
||||
if(y > y1 && y < y1 + height)
|
||||
{
|
||||
// set the target property if a hit is true!
|
||||
interactionData.target = item
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
190
docs/files/src_pixi_Polygon.js.html
Normal file
190
docs/files/src_pixi_Polygon.js.html
Normal file
|
@ -0,0 +1,190 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>src/pixi/Polygon.js - Pixi.JS</title>
|
||||
<link rel="stylesheet" href="http://yui.yahooapis.com/3.8.0/build/cssgrids/cssgrids-min.css">
|
||||
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
|
||||
<link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
|
||||
<link rel="shortcut icon" type="image/png" href="../assets/favicon.png">
|
||||
<script src="http://yui.yahooapis.com/combo?3.8.0/build/yui/yui-min.js"></script>
|
||||
</head>
|
||||
<body class="yui3-skin-sam">
|
||||
|
||||
<div id="doc">
|
||||
<div id="hd" class="yui3-g header">
|
||||
<div class="yui3-u-3-4">
|
||||
|
||||
<h1><img src="http://www.goodboydigital.com/pixijs/logo_small.png" title="Pixi.JS"></h1>
|
||||
|
||||
</div>
|
||||
<div class="yui3-u-1-4 version">
|
||||
<em>API Docs for: 1.0.0</em>
|
||||
</div>
|
||||
</div>
|
||||
<div id="bd" class="yui3-g">
|
||||
|
||||
<div class="yui3-u-1-4">
|
||||
<div id="docs-sidebar" class="sidebar apidocs">
|
||||
<div id="api-list">
|
||||
<h2 class="off-left">APIs</h2>
|
||||
<div id="api-tabview" class="tabview">
|
||||
<ul class="tabs">
|
||||
<li><a href="#api-classes">Classes</a></li>
|
||||
<li><a href="#api-modules">Modules</a></li>
|
||||
</ul>
|
||||
|
||||
<div id="api-tabview-filter">
|
||||
<input type="search" id="api-filter" placeholder="Type to filter APIs">
|
||||
</div>
|
||||
|
||||
<div id="api-tabview-panel">
|
||||
<ul id="api-classes" class="apis classes">
|
||||
|
||||
<li><a href="../classes/AssetLoader.html">AssetLoader</a></li>
|
||||
|
||||
<li><a href="../classes/BaseTexture.html">BaseTexture</a></li>
|
||||
|
||||
<li><a href="../classes/BitmapFontLoader.html">BitmapFontLoader</a></li>
|
||||
|
||||
<li><a href="../classes/BitmapText.html">BitmapText</a></li>
|
||||
|
||||
<li><a href="../classes/CanvasRenderer.html">CanvasRenderer</a></li>
|
||||
|
||||
<li><a href="../classes/CustomRenderable.html">CustomRenderable</a></li>
|
||||
|
||||
<li><a href="../classes/DisplayObject.html">DisplayObject</a></li>
|
||||
|
||||
<li><a href="../classes/DisplayObjectContainer.html">DisplayObjectContainer</a></li>
|
||||
|
||||
<li><a href="../classes/ImageLoader.html">ImageLoader</a></li>
|
||||
|
||||
<li><a href="../classes/InteractionData.html">InteractionData</a></li>
|
||||
|
||||
<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>
|
||||
|
||||
<li><a href="../classes/Stage.html">Stage</a></li>
|
||||
|
||||
<li><a href="../classes/Text.html">Text</a></li>
|
||||
|
||||
<li><a href="../classes/Texture.html">Texture</a></li>
|
||||
|
||||
<li><a href="../classes/TilingSprite.html">TilingSprite</a></li>
|
||||
|
||||
<li><a href="../classes/WebGLBatch.html">WebGLBatch</a></li>
|
||||
|
||||
<li><a href="../classes/WebGLRenderer.html">WebGLRenderer</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
<ul id="api-modules" class="apis modules">
|
||||
|
||||
<li><a href="../modules/PIXI.html">PIXI</a></li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="yui3-u-3-4">
|
||||
<div id="api-options">
|
||||
Show:
|
||||
<label for="api-show-inherited">
|
||||
<input type="checkbox" id="api-show-inherited" checked>
|
||||
Inherited
|
||||
</label>
|
||||
|
||||
<label for="api-show-protected">
|
||||
<input type="checkbox" id="api-show-protected">
|
||||
Protected
|
||||
</label>
|
||||
|
||||
<label for="api-show-private">
|
||||
<input type="checkbox" id="api-show-private">
|
||||
Private
|
||||
</label>
|
||||
<label for="api-show-deprecated">
|
||||
<input type="checkbox" id="api-show-deprecated">
|
||||
Deprecated
|
||||
</label>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="apidocs">
|
||||
<div id="docs-main">
|
||||
<div class="content">
|
||||
<h1 class="file-heading">File: src/pixi/Polygon.js</h1>
|
||||
|
||||
<div class="file">
|
||||
<pre class="code prettyprint linenums">
|
||||
/**
|
||||
* @author Adrien Brault <adrien.brault@gmail.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class Polygon
|
||||
* @constructor
|
||||
* @param points {Array}
|
||||
*/
|
||||
PIXI.Polygon = function(points)
|
||||
{
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
/**
|
||||
* @method clone
|
||||
* @return a copy of the polygon
|
||||
*/
|
||||
PIXI.Polygon.clone = function()
|
||||
{
|
||||
var points = [];
|
||||
for (var i=0; i<this.points.length; i++) {
|
||||
points.push(this.points[i].clone());
|
||||
}
|
||||
|
||||
return new PIXI.Polygon(points);
|
||||
}
|
||||
|
||||
PIXI.Polygon.constructor = PIXI.Polygon;
|
||||
|
||||
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="../assets/vendor/prettify/prettify-min.js"></script>
|
||||
<script>prettyPrint();</script>
|
||||
<script src="../assets/js/yui-prettify.js"></script>
|
||||
<script src="../assets/../api.js"></script>
|
||||
<script src="../assets/js/api-filter.js"></script>
|
||||
<script src="../assets/js/api-list.js"></script>
|
||||
<script src="../assets/js/api-search.js"></script>
|
||||
<script src="../assets/js/apidocs.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
@ -162,6 +168,8 @@ PIXI.Stage = function(backgroundColor, interactive)
|
|||
|
||||
this.setBackgroundColor(backgroundColor);
|
||||
this.worldVisible = true;
|
||||
|
||||
this.stage.dirty = true;
|
||||
}
|
||||
|
||||
// constructor
|
||||
|
@ -200,7 +208,9 @@ PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor)
|
|||
{
|
||||
this.backgroundColor = backgroundColor || 0x000000;
|
||||
this.backgroundColorSplit = HEXtoRGB(this.backgroundColor);
|
||||
this.backgroundColorString = "#" + this.backgroundColor.toString(16);
|
||||
var hex = this.backgroundColor.toString(16);
|
||||
hex = "000000".substr(0, 6 - hex.length) + hex;
|
||||
this.backgroundColorString = "#" + hex;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
1606
docs/files/src_pixi_extras_Spine.js.html
Normal file
1606
docs/files/src_pixi_extras_Spine.js.html
Normal file
File diff suppressed because it is too large
Load diff
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
@ -163,10 +169,13 @@ PIXI.AssetLoader = function(assetURLs)
|
|||
"jpeg": PIXI.ImageLoader,
|
||||
"png": PIXI.ImageLoader,
|
||||
"gif": PIXI.ImageLoader,
|
||||
"json": PIXI.SpriteSheetLoader,
|
||||
"json": PIXI.JsonLoader,
|
||||
"anim": PIXI.SpineLoader,
|
||||
"xml": PIXI.BitmapFontLoader,
|
||||
"fnt": PIXI.BitmapFontLoader
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -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>
|
||||
|
@ -223,7 +229,9 @@ PIXI.BitmapFontLoader.prototype.onXMLLoaded = function()
|
|||
xOffset: parseInt(letters[i].attributes.getNamedItem("xoffset").nodeValue, 10),
|
||||
yOffset: parseInt(letters[i].attributes.getNamedItem("yoffset").nodeValue, 10),
|
||||
xAdvance: parseInt(letters[i].attributes.getNamedItem("xadvance").nodeValue, 10),
|
||||
kerning: {}
|
||||
kerning: {},
|
||||
texture:new PIXI.Texture(this.texture, textureRect)
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -238,6 +246,7 @@ PIXI.BitmapFontLoader.prototype.onXMLLoaded = function()
|
|||
data.chars[second].kerning[first] = amount;
|
||||
|
||||
}
|
||||
|
||||
PIXI.BitmapText.fonts[data.font] = data;
|
||||
|
||||
var scope = this;
|
||||
|
|
|
@ -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>
|
||||
|
|
288
docs/files/src_pixi_loaders_JsonLoader.js.html
Normal file
288
docs/files/src_pixi_loaders_JsonLoader.js.html
Normal file
|
@ -0,0 +1,288 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>src/pixi/loaders/JsonLoader.js - Pixi.JS</title>
|
||||
<link rel="stylesheet" href="http://yui.yahooapis.com/3.8.0/build/cssgrids/cssgrids-min.css">
|
||||
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
|
||||
<link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
|
||||
<link rel="shortcut icon" type="image/png" href="../assets/favicon.png">
|
||||
<script src="http://yui.yahooapis.com/combo?3.8.0/build/yui/yui-min.js"></script>
|
||||
</head>
|
||||
<body class="yui3-skin-sam">
|
||||
|
||||
<div id="doc">
|
||||
<div id="hd" class="yui3-g header">
|
||||
<div class="yui3-u-3-4">
|
||||
|
||||
<h1><img src="http://www.goodboydigital.com/pixijs/logo_small.png" title="Pixi.JS"></h1>
|
||||
|
||||
</div>
|
||||
<div class="yui3-u-1-4 version">
|
||||
<em>API Docs for: 1.0.0</em>
|
||||
</div>
|
||||
</div>
|
||||
<div id="bd" class="yui3-g">
|
||||
|
||||
<div class="yui3-u-1-4">
|
||||
<div id="docs-sidebar" class="sidebar apidocs">
|
||||
<div id="api-list">
|
||||
<h2 class="off-left">APIs</h2>
|
||||
<div id="api-tabview" class="tabview">
|
||||
<ul class="tabs">
|
||||
<li><a href="#api-classes">Classes</a></li>
|
||||
<li><a href="#api-modules">Modules</a></li>
|
||||
</ul>
|
||||
|
||||
<div id="api-tabview-filter">
|
||||
<input type="search" id="api-filter" placeholder="Type to filter APIs">
|
||||
</div>
|
||||
|
||||
<div id="api-tabview-panel">
|
||||
<ul id="api-classes" class="apis classes">
|
||||
|
||||
<li><a href="../classes/AssetLoader.html">AssetLoader</a></li>
|
||||
|
||||
<li><a href="../classes/BaseTexture.html">BaseTexture</a></li>
|
||||
|
||||
<li><a href="../classes/BitmapFontLoader.html">BitmapFontLoader</a></li>
|
||||
|
||||
<li><a href="../classes/BitmapText.html">BitmapText</a></li>
|
||||
|
||||
<li><a href="../classes/CanvasRenderer.html">CanvasRenderer</a></li>
|
||||
|
||||
<li><a href="../classes/CustomRenderable.html">CustomRenderable</a></li>
|
||||
|
||||
<li><a href="../classes/DisplayObject.html">DisplayObject</a></li>
|
||||
|
||||
<li><a href="../classes/DisplayObjectContainer.html">DisplayObjectContainer</a></li>
|
||||
|
||||
<li><a href="../classes/ImageLoader.html">ImageLoader</a></li>
|
||||
|
||||
<li><a href="../classes/InteractionData.html">InteractionData</a></li>
|
||||
|
||||
<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>
|
||||
|
||||
<li><a href="../classes/Stage.html">Stage</a></li>
|
||||
|
||||
<li><a href="../classes/Text.html">Text</a></li>
|
||||
|
||||
<li><a href="../classes/Texture.html">Texture</a></li>
|
||||
|
||||
<li><a href="../classes/TilingSprite.html">TilingSprite</a></li>
|
||||
|
||||
<li><a href="../classes/WebGLBatch.html">WebGLBatch</a></li>
|
||||
|
||||
<li><a href="../classes/WebGLRenderer.html">WebGLRenderer</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
<ul id="api-modules" class="apis modules">
|
||||
|
||||
<li><a href="../modules/PIXI.html">PIXI</a></li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="yui3-u-3-4">
|
||||
<div id="api-options">
|
||||
Show:
|
||||
<label for="api-show-inherited">
|
||||
<input type="checkbox" id="api-show-inherited" checked>
|
||||
Inherited
|
||||
</label>
|
||||
|
||||
<label for="api-show-protected">
|
||||
<input type="checkbox" id="api-show-protected">
|
||||
Protected
|
||||
</label>
|
||||
|
||||
<label for="api-show-private">
|
||||
<input type="checkbox" id="api-show-private">
|
||||
Private
|
||||
</label>
|
||||
<label for="api-show-deprecated">
|
||||
<input type="checkbox" id="api-show-deprecated">
|
||||
Deprecated
|
||||
</label>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="apidocs">
|
||||
<div id="docs-main">
|
||||
<div class="content">
|
||||
<h1 class="file-heading">File: src/pixi/loaders/JsonLoader.js</h1>
|
||||
|
||||
<div class="file">
|
||||
<pre class="code prettyprint linenums">
|
||||
/**
|
||||
* @author Mat Groves http://matgroves.com/ @Doormat23
|
||||
*/
|
||||
|
||||
/**
|
||||
* The json file loader is used to load in JSON data and parsing it
|
||||
* When loaded this class will dispatch a "loaded" event
|
||||
* If load failed this class will dispatch a "error" event
|
||||
* @class JsonLoader
|
||||
* @extends EventTarget
|
||||
* @constructor
|
||||
* @param {String} url the url of the JSON file
|
||||
* @param {Boolean} crossorigin
|
||||
*/
|
||||
|
||||
PIXI.JsonLoader = function (url, crossorigin) {
|
||||
PIXI.EventTarget.call(this);
|
||||
this.url = url;
|
||||
this.baseUrl = url.replace(/[^\/]*$/, "");
|
||||
this.crossorigin = crossorigin;
|
||||
this.loaded = false;
|
||||
|
||||
};
|
||||
|
||||
// constructor
|
||||
PIXI.JsonLoader.constructor = PIXI.JsonLoader;
|
||||
|
||||
/**
|
||||
* This will begin loading the JSON file
|
||||
*/
|
||||
PIXI.JsonLoader.prototype.load = function () {
|
||||
this.ajaxRequest = new AjaxRequest();
|
||||
var scope = this;
|
||||
this.ajaxRequest.onreadystatechange = function () {
|
||||
scope.onJSONLoaded();
|
||||
};
|
||||
|
||||
this.ajaxRequest.open("GET", this.url, true);
|
||||
if (this.ajaxRequest.overrideMimeType) this.ajaxRequest.overrideMimeType("application/json");
|
||||
this.ajaxRequest.send(null);
|
||||
};
|
||||
|
||||
/**
|
||||
* Invoke when JSON file is loaded
|
||||
* @private
|
||||
*/
|
||||
PIXI.JsonLoader.prototype.onJSONLoaded = function () {
|
||||
if (this.ajaxRequest.readyState == 4) {
|
||||
if (this.ajaxRequest.status == 200 || window.location.href.indexOf("http") == -1) {
|
||||
this.json = JSON.parse(this.ajaxRequest.responseText);
|
||||
|
||||
if(this.json.frames)
|
||||
{
|
||||
// sprite sheet
|
||||
var scope = this;
|
||||
var textureUrl = this.baseUrl + this.json.meta.image;
|
||||
var image = new PIXI.ImageLoader(textureUrl, this.crossorigin);
|
||||
var frameData = this.json.frames;
|
||||
|
||||
this.texture = image.texture.baseTexture;
|
||||
image.addEventListener("loaded", function (event) {
|
||||
scope.onLoaded();
|
||||
});
|
||||
|
||||
for (var i in frameData) {
|
||||
var rect = frameData[i].frame;
|
||||
if (rect) {
|
||||
PIXI.TextureCache[i] = new PIXI.Texture(this.texture, {
|
||||
x: rect.x,
|
||||
y: rect.y,
|
||||
width: rect.w,
|
||||
height: rect.h
|
||||
});
|
||||
if (frameData[i].trimmed) {
|
||||
//var realSize = frameData[i].spriteSourceSize;
|
||||
PIXI.TextureCache[i].realSize = frameData[i].spriteSourceSize;
|
||||
PIXI.TextureCache[i].trim.x = 0; // (realSize.x / rect.w)
|
||||
// calculate the offset!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
image.load();
|
||||
|
||||
}
|
||||
else if(this.json.bones)
|
||||
{
|
||||
// spine animation
|
||||
var spineJsonParser = new spine.SkeletonJson();
|
||||
var skeletonData = spineJsonParser.readSkeletonData(this.json);
|
||||
PIXI.AnimCache[this.url] = skeletonData;
|
||||
this.onLoaded();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.onLoaded();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
this.onError();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Invoke when json file loaded
|
||||
* @private
|
||||
*/
|
||||
PIXI.JsonLoader.prototype.onLoaded = function () {
|
||||
this.loaded = true;
|
||||
this.dispatchEvent({
|
||||
type: "loaded",
|
||||
content: this
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Invoke when error occured
|
||||
* @private
|
||||
*/
|
||||
PIXI.JsonLoader.prototype.onError = function () {
|
||||
this.dispatchEvent({
|
||||
type: "error",
|
||||
content: this
|
||||
});
|
||||
};
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="../assets/vendor/prettify/prettify-min.js"></script>
|
||||
<script>prettyPrint();</script>
|
||||
<script src="../assets/js/yui-prettify.js"></script>
|
||||
<script src="../assets/../api.js"></script>
|
||||
<script src="../assets/js/api-filter.js"></script>
|
||||
<script src="../assets/js/api-list.js"></script>
|
||||
<script src="../assets/js/api-search.js"></script>
|
||||
<script src="../assets/js/apidocs.js"></script>
|
||||
</body>
|
||||
</html>
|
236
docs/files/src_pixi_loaders_SpineLoader.js.html
Normal file
236
docs/files/src_pixi_loaders_SpineLoader.js.html
Normal file
|
@ -0,0 +1,236 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>src/pixi/loaders/SpineLoader.js - Pixi.JS</title>
|
||||
<link rel="stylesheet" href="http://yui.yahooapis.com/3.8.0/build/cssgrids/cssgrids-min.css">
|
||||
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
|
||||
<link rel="stylesheet" href="../assets/css/main.css" id="site_styles">
|
||||
<link rel="shortcut icon" type="image/png" href="../assets/favicon.png">
|
||||
<script src="http://yui.yahooapis.com/combo?3.8.0/build/yui/yui-min.js"></script>
|
||||
</head>
|
||||
<body class="yui3-skin-sam">
|
||||
|
||||
<div id="doc">
|
||||
<div id="hd" class="yui3-g header">
|
||||
<div class="yui3-u-3-4">
|
||||
|
||||
<h1><img src="http://www.goodboydigital.com/pixijs/logo_small.png" title="Pixi.JS"></h1>
|
||||
|
||||
</div>
|
||||
<div class="yui3-u-1-4 version">
|
||||
<em>API Docs for: 1.0.0</em>
|
||||
</div>
|
||||
</div>
|
||||
<div id="bd" class="yui3-g">
|
||||
|
||||
<div class="yui3-u-1-4">
|
||||
<div id="docs-sidebar" class="sidebar apidocs">
|
||||
<div id="api-list">
|
||||
<h2 class="off-left">APIs</h2>
|
||||
<div id="api-tabview" class="tabview">
|
||||
<ul class="tabs">
|
||||
<li><a href="#api-classes">Classes</a></li>
|
||||
<li><a href="#api-modules">Modules</a></li>
|
||||
</ul>
|
||||
|
||||
<div id="api-tabview-filter">
|
||||
<input type="search" id="api-filter" placeholder="Type to filter APIs">
|
||||
</div>
|
||||
|
||||
<div id="api-tabview-panel">
|
||||
<ul id="api-classes" class="apis classes">
|
||||
|
||||
<li><a href="../classes/AssetLoader.html">AssetLoader</a></li>
|
||||
|
||||
<li><a href="../classes/BaseTexture.html">BaseTexture</a></li>
|
||||
|
||||
<li><a href="../classes/BitmapFontLoader.html">BitmapFontLoader</a></li>
|
||||
|
||||
<li><a href="../classes/BitmapText.html">BitmapText</a></li>
|
||||
|
||||
<li><a href="../classes/CanvasRenderer.html">CanvasRenderer</a></li>
|
||||
|
||||
<li><a href="../classes/CustomRenderable.html">CustomRenderable</a></li>
|
||||
|
||||
<li><a href="../classes/DisplayObject.html">DisplayObject</a></li>
|
||||
|
||||
<li><a href="../classes/DisplayObjectContainer.html">DisplayObjectContainer</a></li>
|
||||
|
||||
<li><a href="../classes/ImageLoader.html">ImageLoader</a></li>
|
||||
|
||||
<li><a href="../classes/InteractionData.html">InteractionData</a></li>
|
||||
|
||||
<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>
|
||||
|
||||
<li><a href="../classes/Stage.html">Stage</a></li>
|
||||
|
||||
<li><a href="../classes/Text.html">Text</a></li>
|
||||
|
||||
<li><a href="../classes/Texture.html">Texture</a></li>
|
||||
|
||||
<li><a href="../classes/TilingSprite.html">TilingSprite</a></li>
|
||||
|
||||
<li><a href="../classes/WebGLBatch.html">WebGLBatch</a></li>
|
||||
|
||||
<li><a href="../classes/WebGLRenderer.html">WebGLRenderer</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
<ul id="api-modules" class="apis modules">
|
||||
|
||||
<li><a href="../modules/PIXI.html">PIXI</a></li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="yui3-u-3-4">
|
||||
<div id="api-options">
|
||||
Show:
|
||||
<label for="api-show-inherited">
|
||||
<input type="checkbox" id="api-show-inherited" checked>
|
||||
Inherited
|
||||
</label>
|
||||
|
||||
<label for="api-show-protected">
|
||||
<input type="checkbox" id="api-show-protected">
|
||||
Protected
|
||||
</label>
|
||||
|
||||
<label for="api-show-private">
|
||||
<input type="checkbox" id="api-show-private">
|
||||
Private
|
||||
</label>
|
||||
<label for="api-show-deprecated">
|
||||
<input type="checkbox" id="api-show-deprecated">
|
||||
Deprecated
|
||||
</label>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="apidocs">
|
||||
<div id="docs-main">
|
||||
<div class="content">
|
||||
<h1 class="file-heading">File: src/pixi/loaders/SpineLoader.js</h1>
|
||||
|
||||
<div class="file">
|
||||
<pre class="code prettyprint linenums">
|
||||
/**
|
||||
* @author Mat Groves http://matgroves.com/ @Doormat23
|
||||
* based on pixi impact spine implementation made by Eemeli Kelokorpi (@ekelokorpi) https://github.com/ekelokorpi
|
||||
*
|
||||
* Awesome JS run time provided by EsotericSoftware
|
||||
* https://github.com/EsotericSoftware/spine-runtimes
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Spine loader is used to load in JSON spine data
|
||||
* To generate the data you need to use http://esotericsoftware.com/ and export the "JSON" format
|
||||
* Due to a clash of names You will need to change the extension of the spine file from *.json to *.anim for it to load
|
||||
* See example 12 (http://www.goodboydigital.com/pixijs/examples/12/) to see a working example and check out the source
|
||||
* You will need to generate a sprite sheet to accompany the spine data
|
||||
* When loaded this class will dispatch a "loaded" event
|
||||
* @class Spine
|
||||
* @constructor
|
||||
* @extends EventTarget
|
||||
* @param {String} url the url of the sprite sheet JSON file
|
||||
* @param {Boolean} crossorigin
|
||||
*/
|
||||
PIXI.SpineLoader = function(url, crossorigin)
|
||||
{
|
||||
PIXI.EventTarget.call(this);
|
||||
this.url = url;
|
||||
this.crossorigin = crossorigin;
|
||||
this.loaded = false;
|
||||
}
|
||||
|
||||
PIXI.SpineLoader.constructor = PIXI.SpineLoader;
|
||||
|
||||
PIXI.SpineLoader.prototype.load = function()
|
||||
{
|
||||
new PIXI.JsonLoader(this.url, this.crossorigin);
|
||||
jsonLoader.addEventListener("loaded", function (event) {
|
||||
scope.json = event.content.json;
|
||||
scope.onJSONLoaded();
|
||||
});
|
||||
jsonLoader.load();
|
||||
};
|
||||
|
||||
PIXI.SpineLoader.prototype.load = function () {
|
||||
|
||||
var scope = this;
|
||||
var jsonLoader = new PIXI.JsonLoader(this.url, this.crossorigin);
|
||||
jsonLoader.addEventListener("loaded", function (event) {
|
||||
scope.json = event.content.json;
|
||||
scope.onJSONLoaded();
|
||||
});
|
||||
jsonLoader.load();
|
||||
};
|
||||
|
||||
/**
|
||||
* Invoke when JSON file is loaded
|
||||
* @private
|
||||
*/
|
||||
PIXI.SpineLoader.prototype.onJSONLoaded = function (event) {
|
||||
|
||||
var spineJsonParser = new spine.SkeletonJson();
|
||||
|
||||
var skeletonData = spineJsonParser.readSkeletonData(this.json);
|
||||
|
||||
PIXI.AnimCache[this.url] = skeletonData;
|
||||
|
||||
this.onLoaded();
|
||||
};
|
||||
|
||||
|
||||
|
||||
PIXI.SpineLoader.prototype.onLoaded = function()
|
||||
{
|
||||
this.loaded = true;
|
||||
this.dispatchEvent({type: "loaded", content: this});
|
||||
};
|
||||
|
||||
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="../assets/vendor/prettify/prettify-min.js"></script>
|
||||
<script>prettyPrint();</script>
|
||||
<script src="../assets/js/yui-prettify.js"></script>
|
||||
<script src="../assets/../api.js"></script>
|
||||
<script src="../assets/js/api-filter.js"></script>
|
||||
<script src="../assets/js/api-list.js"></script>
|
||||
<script src="../assets/js/api-search.js"></script>
|
||||
<script src="../assets/js/apidocs.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -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>
|
||||
|
@ -151,8 +157,7 @@
|
|||
* @param {Boolean} crossorigin
|
||||
*/
|
||||
|
||||
PIXI.SpriteSheetLoader = function(url, crossorigin)
|
||||
{
|
||||
PIXI.SpriteSheetLoader = function (url, crossorigin) {
|
||||
/*
|
||||
* i use texture packer to load the assets..
|
||||
* http://www.codeandweb.com/texturepacker
|
||||
|
@ -172,50 +177,41 @@ PIXI.SpriteSheetLoader.constructor = PIXI.SpriteSheetLoader;
|
|||
/**
|
||||
* This will begin loading the JSON file
|
||||
*/
|
||||
PIXI.SpriteSheetLoader.prototype.load = function()
|
||||
{
|
||||
this.ajaxRequest = new AjaxRequest();
|
||||
PIXI.SpriteSheetLoader.prototype.load = function () {
|
||||
var scope = this;
|
||||
this.ajaxRequest.onreadystatechange = function()
|
||||
{
|
||||
var jsonLoader = new PIXI.JsonLoader(this.url, this.crossorigin);
|
||||
jsonLoader.addEventListener("loaded", function (event) {
|
||||
scope.json = event.content.json;
|
||||
scope.onJSONLoaded();
|
||||
};
|
||||
|
||||
this.ajaxRequest.open("GET", this.url, true);
|
||||
if (this.ajaxRequest.overrideMimeType) this.ajaxRequest.overrideMimeType("application/json");
|
||||
this.ajaxRequest.send(null)
|
||||
});
|
||||
jsonLoader.load();
|
||||
};
|
||||
|
||||
/**
|
||||
* Invoke when JSON file is loaded
|
||||
* @private
|
||||
*/
|
||||
PIXI.SpriteSheetLoader.prototype.onJSONLoaded = function()
|
||||
{
|
||||
if (this.ajaxRequest.readyState == 4)
|
||||
{
|
||||
if (this.ajaxRequest.status == 200 || window.location.href.indexOf("http") == -1)
|
||||
{
|
||||
var jsonData = eval("(" + this.ajaxRequest.responseText + ")");
|
||||
var textureUrl = this.baseUrl + jsonData.meta.image;
|
||||
|
||||
var image = new PIXI.ImageLoader(textureUrl, this.crossorigin);
|
||||
this.texture = image.texture.baseTexture;
|
||||
PIXI.SpriteSheetLoader.prototype.onJSONLoaded = function () {
|
||||
var scope = this;
|
||||
var textureUrl = this.baseUrl + this.json.meta.image;
|
||||
var image = new PIXI.ImageLoader(textureUrl, this.crossorigin);
|
||||
var frameData = this.json.frames;
|
||||
|
||||
this.texture = image.texture.baseTexture;
|
||||
image.addEventListener("loaded", function (event) {
|
||||
scope.onLoaded();
|
||||
});
|
||||
|
||||
var frameData = jsonData.frames;
|
||||
for (var i in frameData)
|
||||
{
|
||||
for (var i in frameData) {
|
||||
var rect = frameData[i].frame;
|
||||
if (rect)
|
||||
{
|
||||
PIXI.TextureCache[i] = new PIXI.Texture(this.texture, {x:rect.x, y:rect.y, width:rect.w, height:rect.h});
|
||||
|
||||
if(frameData[i].trimmed)
|
||||
{
|
||||
if (rect) {
|
||||
PIXI.TextureCache[i] = new PIXI.Texture(this.texture, {
|
||||
x: rect.x,
|
||||
y: rect.y,
|
||||
width: rect.w,
|
||||
height: rect.h
|
||||
});
|
||||
if (frameData[i].trimmed) {
|
||||
//var realSize = frameData[i].spriteSourceSize;
|
||||
PIXI.TextureCache[i].realSize = frameData[i].spriteSourceSize;
|
||||
PIXI.TextureCache[i].trim.x = 0; // (realSize.x / rect.w)
|
||||
|
@ -225,18 +221,17 @@ PIXI.SpriteSheetLoader.prototype.onJSONLoaded = function()
|
|||
}
|
||||
|
||||
image.load();
|
||||
}
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Invoke when all files are loaded (json and texture)
|
||||
* @private
|
||||
*/
|
||||
PIXI.SpriteSheetLoader.prototype.onLoaded = function()
|
||||
{
|
||||
this.dispatchEvent({type: "loaded", content: this});
|
||||
PIXI.SpriteSheetLoader.prototype.onLoaded = function () {
|
||||
this.dispatchEvent({
|
||||
type: "loaded",
|
||||
content: this
|
||||
});
|
||||
};
|
||||
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
@ -333,10 +339,13 @@ PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject)
|
|||
}
|
||||
|
||||
// render!
|
||||
if(displayObject.children)
|
||||
{
|
||||
for (var i=0; i < displayObject.children.length; i++)
|
||||
{
|
||||
this.renderDisplayObject(displayObject.children[i]);
|
||||
}
|
||||
}
|
||||
|
||||
this.context.setTransform(1,0,0,1,0,0);
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
@ -367,6 +373,7 @@ PIXI.WebGLBatch.prototype.split = function(sprite)
|
|||
//console.log(val + " SAME?");
|
||||
var batch = new PIXI.WebGLBatch(this.gl)//PIXI._getBatch(this.gl);
|
||||
batch.init(sprite);
|
||||
batch.texture = this.texture;
|
||||
batch.tail = this.tail;
|
||||
//console.log("id is " +batcheee.id)
|
||||
|
||||
|
@ -573,7 +580,6 @@ PIXI.WebGLBatch.prototype.update = function()
|
|||
tx = worldTransform[2];
|
||||
ty = worldTransform[5];
|
||||
|
||||
|
||||
this.verticies[index + 0 ] = a * w1 + c * h1 + tx;
|
||||
this.verticies[index + 1 ] = d * h1 + b * w1 + ty;
|
||||
|
||||
|
@ -659,6 +665,7 @@ PIXI.WebGLBatch.prototype.render = function(start, end)
|
|||
{
|
||||
this.refresh();
|
||||
this.dirty = false;
|
||||
|
||||
}
|
||||
|
||||
if (this.size == 0)return;
|
||||
|
|
|
@ -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>
|
||||
|
@ -165,6 +171,8 @@ PIXI.WebGLRenderGroup.prototype.setRenderable = function(displayObject)
|
|||
// has this changed??
|
||||
if(this.root)this.removeDisplayObjectAndChildren(this.root);
|
||||
|
||||
displayObject.worldVisible = displayObject.visible;
|
||||
|
||||
// soooooo //
|
||||
// to check if any batchs exist already??
|
||||
|
||||
|
@ -177,25 +185,21 @@ PIXI.WebGLRenderGroup.prototype.setRenderable = function(displayObject)
|
|||
|
||||
PIXI.WebGLRenderGroup.prototype.render = function(projectionMatrix)
|
||||
{
|
||||
//PIXI.WebGLRenderer.updateTextures();
|
||||
|
||||
PIXI.WebGLRenderer.updateTextures();
|
||||
|
||||
var gl = this.gl;
|
||||
|
||||
// set the flipped matrix..
|
||||
gl.uniformMatrix4fv(PIXI.shaderProgram.mvMatrixUniform, false, projectionMatrix);
|
||||
|
||||
|
||||
for (var i=0; i < this.toRemove.length; i++)
|
||||
{
|
||||
this.removeDisplayObjectAndChildren(this.toRemove[i]);
|
||||
};
|
||||
|
||||
this.toRemove = [];
|
||||
|
||||
// TODO remove this by replacing visible with getter setters..
|
||||
this.checkVisibility(this.root, this.root.visible);
|
||||
|
||||
// will render all the elements in the group
|
||||
var renderable;
|
||||
|
||||
|
||||
for (var i=0; i < this.batchs.length; i++)
|
||||
{
|
||||
renderable = this.batchs[i];
|
||||
|
@ -217,7 +221,7 @@ PIXI.WebGLRenderGroup.prototype.render = function(projectionMatrix)
|
|||
|
||||
PIXI.WebGLRenderGroup.prototype.renderSpecific = function(displayObject, projectionMatrix)
|
||||
{
|
||||
//PIXI.WebGLRenderer.updateTextures();
|
||||
PIXI.WebGLRenderer.updateTextures();
|
||||
|
||||
var gl = this.gl;
|
||||
this.checkVisibility(displayObject, displayObject.visible);
|
||||
|
@ -411,8 +415,9 @@ PIXI.WebGLRenderGroup.prototype.checkVisibility = function(displayObject, global
|
|||
child.textureChange = false;
|
||||
if(child.worldVisible)
|
||||
{
|
||||
this.removeDisplayObject(child)
|
||||
this.addDisplayObject(child)
|
||||
this.removeDisplayObject(child);
|
||||
this.addDisplayObject(child);
|
||||
//this.updateTexture(child);
|
||||
}
|
||||
// update texture!!
|
||||
}
|
||||
|
@ -424,6 +429,106 @@ PIXI.WebGLRenderGroup.prototype.checkVisibility = function(displayObject, global
|
|||
};
|
||||
}
|
||||
|
||||
PIXI.WebGLRenderGroup.prototype.updateTexture = function(displayObject)
|
||||
{
|
||||
// we know this exists..
|
||||
// is it in a batch..
|
||||
// check batch length
|
||||
if(displayObject.batch.length == 1)
|
||||
{
|
||||
// just one! this guy! so simply swap the texture
|
||||
displayObject.batch.texture = displayObject.texture.baseTexture;
|
||||
return;
|
||||
}
|
||||
|
||||
// early out!
|
||||
if(displayObject.batch.texture == displayObject.texture.baseTexture)return;
|
||||
|
||||
|
||||
if(displayObject.batch.head == displayObject)
|
||||
{
|
||||
//console.log("HEAD")
|
||||
var currentBatch = displayObject.batch;
|
||||
|
||||
var index = this.batchs.indexOf( currentBatch );
|
||||
var previousBatch = this.batchs[index-1];
|
||||
currentBatch.remove(displayObject);
|
||||
|
||||
if(previousBatch)
|
||||
{
|
||||
if(previousBatch.texture == displayObject.texture.baseTexture && previousBatch.blendMode == displayObject.blendMode)
|
||||
{
|
||||
previousBatch.insertAfter(displayObject, previousBatch.tail);
|
||||
}
|
||||
else
|
||||
{
|
||||
// add it before..
|
||||
var batch = PIXI.WebGLRenderer.getBatch();
|
||||
batch.init(displayObject);
|
||||
this.batchs.splice(index-1, 0, batch);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// we are 0!
|
||||
var batch = PIXI.WebGLRenderer.getBatch();
|
||||
batch.init(displayObject);
|
||||
this.batchs.splice(0, 0, batch);
|
||||
}
|
||||
|
||||
}
|
||||
else if(displayObject.batch.tail == displayObject)
|
||||
{
|
||||
var currentBatch = displayObject.batch;
|
||||
|
||||
var index = this.batchs.indexOf( currentBatch );
|
||||
var nextBatch = this.batchs[index+1];
|
||||
currentBatch.remove(displayObject);
|
||||
|
||||
if(nextBatch)
|
||||
{
|
||||
if(nextBatch.texture == displayObject.texture.baseTexture && nextBatch.blendMode == displayObject.blendMode)
|
||||
{
|
||||
nextBatch.insertBefore(displayObject, nextBatch.head);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// add it before..
|
||||
var batch = PIXI.WebGLRenderer.getBatch();
|
||||
batch.init(displayObject);
|
||||
this.batchs.splice(index+1, 0, batch);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// we are 0!
|
||||
var batch = PIXI.WebGLRenderer.getBatch();
|
||||
batch.init(displayObject);
|
||||
this.batchs.push(batch);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// console.log("MIDDLE")
|
||||
var currentBatch = displayObject.batch;
|
||||
|
||||
// split the batch into 2
|
||||
// AH! dont split on the current display object as the texture is wrong!
|
||||
var splitBatch = currentBatch.split(displayObject);
|
||||
|
||||
// now remove the display object
|
||||
splitBatch.remove(displayObject);
|
||||
|
||||
var batch = PIXI.WebGLRenderer.getBatch();
|
||||
var index = this.batchs.indexOf( currentBatch );
|
||||
batch.init(displayObject);
|
||||
this.batchs.splice(index+1, 0, batch, splitBatch);
|
||||
}
|
||||
}
|
||||
|
||||
PIXI.WebGLRenderGroup.prototype.addDisplayObject = function(displayObject)
|
||||
{
|
||||
// add a child to the render group..
|
||||
|
|
|
@ -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>
|
||||
|
@ -182,7 +188,7 @@ PIXI.WebGLRenderer = function(width, height, view, transparent)
|
|||
PIXI.gl = this.gl = this.view.getContext("experimental-webgl", {
|
||||
alpha: this.transparent,
|
||||
antialias:false, // SPEED UP??
|
||||
premultipliedAlpha:true
|
||||
premultipliedAlpha:false
|
||||
});
|
||||
}
|
||||
catch (e)
|
||||
|
@ -325,7 +331,7 @@ PIXI.WebGLRenderer.prototype.render = function(stage)
|
|||
|
||||
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
|
||||
|
||||
gl.clearColor(stage.backgroundColorSplit[0],stage.backgroundColorSplit[1],stage.backgroundColorSplit[2], this.transparent);
|
||||
gl.clearColor(stage.backgroundColorSplit[0],stage.backgroundColorSplit[1],stage.backgroundColorSplit[2], !this.transparent);
|
||||
gl.clear(gl.COLOR_BUFFER_BIT);
|
||||
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
@ -231,7 +237,7 @@ PIXI.BitmapText.prototype.updateText = function()
|
|||
{
|
||||
pos.x += charData.kerning[prevCharCode];
|
||||
}
|
||||
chars.push({line: line, charCode: charCode, position: new PIXI.Point(pos.x + charData.xOffset, pos.y + charData.yOffset)});
|
||||
chars.push({texture:charData.texture, line: line, charCode: charCode, position: new PIXI.Point(pos.x + charData.xOffset, pos.y + charData.yOffset)});
|
||||
pos.x += charData.xAdvance;
|
||||
|
||||
prevCharCode = charCode;
|
||||
|
@ -257,11 +263,11 @@ PIXI.BitmapText.prototype.updateText = function()
|
|||
|
||||
for(i = 0; i < chars.length; i++)
|
||||
{
|
||||
var char = PIXI.Sprite.fromFrame(chars[i].charCode);
|
||||
char.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
|
||||
char.position.y = chars[i].position.y * scale;
|
||||
char.scale.x = char.scale.y = scale;
|
||||
this.addChild(char);
|
||||
var c = new PIXI.Sprite(chars[i].texture)//PIXI.Sprite.fromFrame(chars[i].charCode);
|
||||
c.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
|
||||
c.position.y = chars[i].position.y * scale;
|
||||
c.scale.x = c.scale.y = scale;
|
||||
this.addChild(c);
|
||||
}
|
||||
|
||||
this.width = pos.x * scale;
|
||||
|
|
|
@ -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>
|
||||
|
@ -148,6 +154,8 @@
|
|||
* @param {String} [style.align="left"] An alignment of the multiline text ("left", "center" or "right")
|
||||
* @param {String} [style.stroke] A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00"
|
||||
* @param {Number} [style.strokeThickness=0] A number that represents the thickness of the stroke. Default is 0 (no stroke)
|
||||
* @param {Boolean} [style.wordWrap=false] Indicates if word wrap should be used
|
||||
* @param {Number} [style.wordWrapWidth=100] The width at which text will wrap
|
||||
*/
|
||||
PIXI.Text = function(text, style)
|
||||
{
|
||||
|
@ -173,8 +181,10 @@ PIXI.Text.prototype = Object.create(PIXI.Sprite.prototype);
|
|||
* @param {String} [style.font="bold 20pt Arial"] The style and size of the font
|
||||
* @param {Object} [style.fill="black"] A canvas fillstyle that will be used on the text eg "red", "#00FF00"
|
||||
* @param {String} [style.align="left"] An alignment of the multiline text ("left", "center" or "right")
|
||||
* @param {String} [style.stroke] A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00"
|
||||
* @param {String} [style.stroke="black"] A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00"
|
||||
* @param {Number} [style.strokeThickness=0] A number that represents the thickness of the stroke. Default is 0 (no stroke)
|
||||
* @param {Boolean} [style.wordWrap=false] Indicates if word wrap should be used
|
||||
* @param {Number} [style.wordWrapWidth=100] The width at which text will wrap
|
||||
*/
|
||||
PIXI.Text.prototype.setStyle = function(style)
|
||||
{
|
||||
|
@ -182,7 +192,10 @@ PIXI.Text.prototype.setStyle = function(style)
|
|||
style.font = style.font || "bold 20pt Arial";
|
||||
style.fill = style.fill || "black";
|
||||
style.align = style.align || "left";
|
||||
style.stroke = style.stroke || "black"; //provide a default, see: https://github.com/GoodBoyDigital/pixi.js/issues/136
|
||||
style.strokeThickness = style.strokeThickness || 0;
|
||||
style.wordWrap = style.wordWrap || false;
|
||||
style.wordWrapWidth = style.wordWrapWidth || 100;
|
||||
this.style = style;
|
||||
this.dirty = true;
|
||||
};
|
||||
|
@ -194,7 +207,7 @@ PIXI.Text.prototype.setStyle = function(style)
|
|||
*/
|
||||
PIXI.Sprite.prototype.setText = function(text)
|
||||
{
|
||||
this.text = text || " ";
|
||||
this.text = text.toString() || " ";
|
||||
this.dirty = true;
|
||||
};
|
||||
|
||||
|
@ -206,8 +219,14 @@ PIXI.Text.prototype.updateText = function()
|
|||
{
|
||||
this.context.font = this.style.font;
|
||||
|
||||
var outputText = this.text;
|
||||
|
||||
// word wrap
|
||||
// preserve original text
|
||||
if(this.style.wordWrap)outputText = this.wordWrap(this.text);
|
||||
|
||||
//split text into lines
|
||||
var lines = this.text.split(/(?:\r\n|\r|\n)/);
|
||||
var lines = outputText.split(/(?:\r\n|\r|\n)/);
|
||||
|
||||
//calculate text width
|
||||
var lineWidths = [];
|
||||
|
@ -309,7 +328,7 @@ PIXI.Text.prototype.determineFontHeight = function(fontStyle)
|
|||
var dummy = document.createElement("div");
|
||||
var dummyText = document.createTextNode("M");
|
||||
dummy.appendChild(dummyText);
|
||||
dummy.setAttribute("style", fontStyle);
|
||||
dummy.setAttribute("style", fontStyle + ';position:absolute;top:0;left:0');
|
||||
body.appendChild(dummy);
|
||||
|
||||
result = dummy.offsetHeight;
|
||||
|
@ -321,6 +340,57 @@ PIXI.Text.prototype.determineFontHeight = function(fontStyle)
|
|||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* A Text Object will apply wordwrap
|
||||
* @private
|
||||
*/
|
||||
PIXI.Text.prototype.wordWrap = function(text)
|
||||
{
|
||||
// search good wrap position
|
||||
var searchWrapPos = function(ctx, text, start, end, wrapWidth)
|
||||
{
|
||||
var p = Math.floor((end-start) / 2) + start;
|
||||
if(p == start) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(ctx.measureText(text.substring(0,p)).width <= wrapWidth)
|
||||
{
|
||||
if(ctx.measureText(text.substring(0,p+1)).width > wrapWidth)
|
||||
{
|
||||
return p;
|
||||
}
|
||||
else
|
||||
{
|
||||
return arguments.callee(ctx, text, p, end, wrapWidth);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return arguments.callee(ctx, text, start, p, wrapWidth);
|
||||
}
|
||||
};
|
||||
|
||||
var lineWrap = function(ctx, text, wrapWidth)
|
||||
{
|
||||
if(ctx.measureText(text).width <= wrapWidth || text.length < 1)
|
||||
{
|
||||
return text;
|
||||
}
|
||||
var pos = searchWrapPos(ctx, text, 0, text.length, wrapWidth);
|
||||
return text.substring(0, pos) + "\n" + arguments.callee(ctx, text.substring(pos), wrapWidth);
|
||||
};
|
||||
|
||||
var result = "";
|
||||
var lines = text.split("\n");
|
||||
for (var i = 0; i < lines.length; i++)
|
||||
{
|
||||
result += lineWrap(this.context, lines[i], this.style.wordWrapWidth) + "\n";
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
PIXI.Text.prototype.destroy = function(destroyTexture)
|
||||
{
|
||||
if(destroyTexture)
|
||||
|
|
|
@ -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>
|
||||
|
@ -224,7 +230,6 @@ PIXI.BaseTexture.constructor = PIXI.BaseTexture;
|
|||
|
||||
PIXI.BaseTexture.prototype.destroy = function()
|
||||
{
|
||||
|
||||
if(this.source instanceof Image)
|
||||
{
|
||||
this.source.src = null;
|
||||
|
@ -233,7 +238,6 @@ PIXI.BaseTexture.prototype.destroy = function()
|
|||
PIXI.texturesToDestroy.push(this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Helper function that returns a base texture based on an image url
|
||||
|
|
|
@ -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>
|
||||
|
@ -225,7 +231,7 @@ PIXI.RenderTexture.prototype.initCanvas = function()
|
|||
* This function will draw the display object to the texture.
|
||||
* @method render
|
||||
* @param displayObject {DisplayObject}
|
||||
* @param clear {Boolean} If true the texture will not be cleared before the displayObject is drawn
|
||||
* @param clear {Boolean} If true the texture will be cleared before the displayObject is drawn
|
||||
*/
|
||||
PIXI.RenderTexture.prototype.renderWebGL = function(displayObject, clear)
|
||||
{
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
@ -132,19 +138,38 @@
|
|||
|
||||
<div class="file">
|
||||
<pre class="code prettyprint linenums">
|
||||
/**
|
||||
* Provides requestAnimationFrame in a cross browser way.
|
||||
*/
|
||||
window.requestAnimFrame = (function() {
|
||||
return window.requestAnimationFrame ||
|
||||
window.webkitRequestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame ||
|
||||
window.oRequestAnimationFrame ||
|
||||
window.msRequestAnimationFrame ||
|
||||
function(/* function FrameRequestCallback */ callback, /* DOMElement Element */ element) {
|
||||
window.setTimeout(callback, 1000/60);
|
||||
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
|
||||
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
|
||||
|
||||
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
|
||||
|
||||
// MIT license
|
||||
|
||||
|
||||
var lastTime = 0;
|
||||
var vendors = ['ms', 'moz', 'webkit', 'o'];
|
||||
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
||||
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
|
||||
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
|
||||
|| window[vendors[x]+'CancelRequestAnimationFrame'];
|
||||
}
|
||||
|
||||
if (!window.requestAnimationFrame)
|
||||
window.requestAnimationFrame = function(callback, element) {
|
||||
var currTime = new Date().getTime();
|
||||
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
||||
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
|
||||
timeToCall);
|
||||
lastTime = currTime + timeToCall;
|
||||
return id;
|
||||
};
|
||||
})();
|
||||
|
||||
if (!window.cancelAnimationFrame)
|
||||
window.cancelAnimationFrame = function(id) {
|
||||
clearTimeout(id);
|
||||
};
|
||||
|
||||
window.requestAnimFrame = window.requestAnimationFrame;
|
||||
|
||||
function HEXtoRGB(hex) {
|
||||
return [(hex >> 16 & 0xFF) / 255, ( hex >> 8 & 0xFF) / 255, (hex & 0xFF)/ 255];
|
||||
|
@ -176,7 +201,7 @@ if (typeof Function.prototype.bind != 'function') {
|
|||
})();
|
||||
}
|
||||
|
||||
var AjaxRequest = function()
|
||||
var AjaxRequest = PIXI.AjaxRequest = function()
|
||||
{
|
||||
var activexmodes = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
@ -224,6 +230,12 @@
|
|||
</a>
|
||||
</li>
|
||||
|
||||
<li class="module-class">
|
||||
<a href="../classes/JsonLoader.html">
|
||||
JsonLoader
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li class="module-class">
|
||||
<a href="../classes/MovieClip.html">
|
||||
MovieClip
|
||||
|
@ -236,6 +248,12 @@
|
|||
</a>
|
||||
</li>
|
||||
|
||||
<li class="module-class">
|
||||
<a href="../classes/Polygon.html">
|
||||
Polygon
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li class="module-class">
|
||||
<a href="../classes/Rectangle.html">
|
||||
Rectangle
|
||||
|
@ -248,6 +266,12 @@
|
|||
</a>
|
||||
</li>
|
||||
|
||||
<li class="module-class">
|
||||
<a href="../classes/Spine.html">
|
||||
Spine
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li class="module-class">
|
||||
<a href="../classes/Sprite.html">
|
||||
Sprite
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* Copyright (c) 2012, Mat Groves
|
||||
* http://goodboydigital.com/
|
||||
*
|
||||
* Compiled: 2013-06-12
|
||||
* Compiled: 2013-06-19
|
||||
*
|
||||
* Pixi.JS is licensed under the MIT License.
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
|
@ -124,6 +124,37 @@ PIXI.Rectangle.prototype.clone = function()
|
|||
PIXI.Rectangle.constructor = PIXI.Rectangle;
|
||||
|
||||
|
||||
/**
|
||||
* @author Adrien Brault <adrien.brault@gmail.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class Polygon
|
||||
* @constructor
|
||||
* @param points {Array}
|
||||
*/
|
||||
PIXI.Polygon = function(points)
|
||||
{
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
/**
|
||||
* @method clone
|
||||
* @return a copy of the polygon
|
||||
*/
|
||||
PIXI.Polygon.clone = function()
|
||||
{
|
||||
var points = [];
|
||||
for (var i=0; i<this.points.length; i++) {
|
||||
points.push(this.points[i].clone());
|
||||
}
|
||||
|
||||
return new PIXI.Polygon(points);
|
||||
}
|
||||
|
||||
PIXI.Polygon.constructor = PIXI.Polygon;
|
||||
|
||||
|
||||
/**
|
||||
* @author Mat Groves http://matgroves.com/ @Doormat23
|
||||
*/
|
||||
|
@ -956,7 +987,7 @@ PIXI.Text.prototype = Object.create(PIXI.Sprite.prototype);
|
|||
* @param {String} [style.font="bold 20pt Arial"] The style and size of the font
|
||||
* @param {Object} [style.fill="black"] A canvas fillstyle that will be used on the text eg "red", "#00FF00"
|
||||
* @param {String} [style.align="left"] An alignment of the multiline text ("left", "center" or "right")
|
||||
* @param {String} [style.stroke] A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00"
|
||||
* @param {String} [style.stroke="black"] A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00"
|
||||
* @param {Number} [style.strokeThickness=0] A number that represents the thickness of the stroke. Default is 0 (no stroke)
|
||||
* @param {Boolean} [style.wordWrap=false] Indicates if word wrap should be used
|
||||
* @param {Number} [style.wordWrapWidth=100] The width at which text will wrap
|
||||
|
@ -967,6 +998,7 @@ PIXI.Text.prototype.setStyle = function(style)
|
|||
style.font = style.font || "bold 20pt Arial";
|
||||
style.fill = style.fill || "black";
|
||||
style.align = style.align || "left";
|
||||
style.stroke = style.stroke || "black"; //provide a default, see: https://github.com/GoodBoyDigital/pixi.js/issues/136
|
||||
style.strokeThickness = style.strokeThickness || 0;
|
||||
style.wordWrap = style.wordWrap || false;
|
||||
style.wordWrapWidth = style.wordWrapWidth || 100;
|
||||
|
@ -1102,7 +1134,7 @@ PIXI.Text.prototype.determineFontHeight = function(fontStyle)
|
|||
var dummy = document.createElement("div");
|
||||
var dummyText = document.createTextNode("M");
|
||||
dummy.appendChild(dummyText);
|
||||
dummy.setAttribute("style", fontStyle);
|
||||
dummy.setAttribute("style", fontStyle + ';position:absolute;top:0;left:0');
|
||||
body.appendChild(dummy);
|
||||
|
||||
result = dummy.offsetHeight;
|
||||
|
@ -1301,11 +1333,11 @@ PIXI.BitmapText.prototype.updateText = function()
|
|||
|
||||
for(i = 0; i < chars.length; i++)
|
||||
{
|
||||
var char = new PIXI.Sprite(chars[i].texture)//PIXI.Sprite.fromFrame(chars[i].charCode);
|
||||
char.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
|
||||
char.position.y = chars[i].position.y * scale;
|
||||
char.scale.x = char.scale.y = scale;
|
||||
this.addChild(char);
|
||||
var c = new PIXI.Sprite(chars[i].texture)//PIXI.Sprite.fromFrame(chars[i].charCode);
|
||||
c.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
|
||||
c.position.y = chars[i].position.y * scale;
|
||||
c.scale.x = c.scale.y = scale;
|
||||
this.addChild(c);
|
||||
}
|
||||
|
||||
this.width = pos.x * scale;
|
||||
|
@ -1397,6 +1429,7 @@ PIXI.InteractionManager.prototype.collectInteractiveSprite = function(displayObj
|
|||
{
|
||||
var child = children[i];
|
||||
|
||||
if(child.visible) {
|
||||
// push all interactive bits
|
||||
if(child.interactive)
|
||||
{
|
||||
|
@ -1420,6 +1453,7 @@ PIXI.InteractionManager.prototype.collectInteractiveSprite = function(displayObj
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PIXI.InteractionManager.prototype.setTarget = function(target)
|
||||
{
|
||||
|
@ -1525,8 +1559,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();
|
||||
|
||||
|
@ -1551,8 +1583,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??
|
||||
|
@ -1589,7 +1619,6 @@ PIXI.InteractionManager.prototype.onMouseDown = function(event)
|
|||
|
||||
PIXI.InteractionManager.prototype.onMouseUp = function(event)
|
||||
{
|
||||
event.preventDefault();
|
||||
var global = this.mouse.global;
|
||||
|
||||
|
||||
|
@ -1637,46 +1666,40 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
|
||||
if(!item.visible)return false;
|
||||
|
||||
if(item instanceof PIXI.Sprite)
|
||||
{
|
||||
var worldTransform = item.worldTransform;
|
||||
|
||||
var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2],
|
||||
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);
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
if(x > x1 && x < x1 + width)
|
||||
//a sprite or display object with a hit area defined
|
||||
if(item.hitArea)
|
||||
{
|
||||
var y1 = -height * item.anchor.y;
|
||||
var hitArea = item.hitArea;
|
||||
|
||||
if(y > y1 && y < y1 + height)
|
||||
{
|
||||
// set the target property if a hit is true!
|
||||
interactionData.target = item
|
||||
//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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
||||
//Rectangle hit area
|
||||
else {
|
||||
var x1 = hitArea.x;
|
||||
if(x > x1 && x < x1 + hitArea.width)
|
||||
{
|
||||
|
@ -1684,6 +1707,28 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
|
||||
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)
|
||||
{
|
||||
y1 = -height * item.anchor.y;
|
||||
|
||||
if(y > y1 && y < y1 + height)
|
||||
{
|
||||
// set the target property if a hit is true!
|
||||
interactionData.target = item
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1705,8 +1750,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;
|
||||
|
||||
|
@ -1730,7 +1773,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;
|
||||
|
@ -1772,9 +1814,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;
|
||||
|
||||
|
@ -1956,7 +1995,9 @@ PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor)
|
|||
{
|
||||
this.backgroundColor = backgroundColor || 0x000000;
|
||||
this.backgroundColorSplit = HEXtoRGB(this.backgroundColor);
|
||||
this.backgroundColorString = "#" + this.backgroundColor.toString(16);
|
||||
var hex = this.backgroundColor.toString(16);
|
||||
hex = "000000".substr(0, 6 - hex.length) + hex;
|
||||
this.backgroundColorString = "#" + hex;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2001,19 +2042,38 @@ PIXI.Stage.prototype.__removeChild = function(child)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides requestAnimationFrame in a cross browser way.
|
||||
*/
|
||||
window.requestAnimFrame = (function() {
|
||||
return window.requestAnimationFrame ||
|
||||
window.webkitRequestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame ||
|
||||
window.oRequestAnimationFrame ||
|
||||
window.msRequestAnimationFrame ||
|
||||
function(/* function FrameRequestCallback */ callback, /* DOMElement Element */ element) {
|
||||
window.setTimeout(callback, 1000/60);
|
||||
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
|
||||
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
|
||||
|
||||
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
|
||||
|
||||
// MIT license
|
||||
|
||||
|
||||
var lastTime = 0;
|
||||
var vendors = ['ms', 'moz', 'webkit', 'o'];
|
||||
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
||||
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
|
||||
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
|
||||
|| window[vendors[x]+'CancelRequestAnimationFrame'];
|
||||
}
|
||||
|
||||
if (!window.requestAnimationFrame)
|
||||
window.requestAnimationFrame = function(callback, element) {
|
||||
var currTime = new Date().getTime();
|
||||
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
||||
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
|
||||
timeToCall);
|
||||
lastTime = currTime + timeToCall;
|
||||
return id;
|
||||
};
|
||||
})();
|
||||
|
||||
if (!window.cancelAnimationFrame)
|
||||
window.cancelAnimationFrame = function(id) {
|
||||
clearTimeout(id);
|
||||
};
|
||||
|
||||
window.requestAnimFrame = window.requestAnimationFrame;
|
||||
|
||||
function HEXtoRGB(hex) {
|
||||
return [(hex >> 16 & 0xFF) / 255, ( hex >> 8 & 0xFF) / 255, (hex & 0xFF)/ 255];
|
||||
|
@ -2045,7 +2105,7 @@ if (typeof Function.prototype.bind != 'function') {
|
|||
})();
|
||||
}
|
||||
|
||||
var AjaxRequest = function()
|
||||
var AjaxRequest = PIXI.AjaxRequest = function()
|
||||
{
|
||||
var activexmodes = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE
|
||||
|
||||
|
@ -4488,10 +4548,13 @@ PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject)
|
|||
}
|
||||
|
||||
// render!
|
||||
if(displayObject.children)
|
||||
{
|
||||
for (var i=0; i < displayObject.children.length; i++)
|
||||
{
|
||||
this.renderDisplayObject(displayObject.children[i]);
|
||||
}
|
||||
}
|
||||
|
||||
this.context.setTransform(1,0,0,1,0,0);
|
||||
}
|
||||
|
@ -7439,7 +7502,7 @@ PIXI.BitmapFontLoader.prototype.onLoaded = function()
|
|||
* When loaded this class will dispatch a "loaded" event
|
||||
* @class Spine
|
||||
* @constructor
|
||||
* @extends
|
||||
* @extends EventTarget
|
||||
* @param {String} url the url of the sprite sheet JSON file
|
||||
* @param {Boolean} crossorigin
|
||||
*/
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* Copyright (c) 2012, Mat Groves
|
||||
* http://goodboydigital.com/
|
||||
*
|
||||
* Compiled: 2013-06-12
|
||||
* Compiled: 2013-06-19
|
||||
*
|
||||
* Pixi.JS is licensed under the MIT License.
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
|
@ -124,6 +124,37 @@ PIXI.Rectangle.prototype.clone = function()
|
|||
PIXI.Rectangle.constructor = PIXI.Rectangle;
|
||||
|
||||
|
||||
/**
|
||||
* @author Adrien Brault <adrien.brault@gmail.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class Polygon
|
||||
* @constructor
|
||||
* @param points {Array}
|
||||
*/
|
||||
PIXI.Polygon = function(points)
|
||||
{
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
/**
|
||||
* @method clone
|
||||
* @return a copy of the polygon
|
||||
*/
|
||||
PIXI.Polygon.clone = function()
|
||||
{
|
||||
var points = [];
|
||||
for (var i=0; i<this.points.length; i++) {
|
||||
points.push(this.points[i].clone());
|
||||
}
|
||||
|
||||
return new PIXI.Polygon(points);
|
||||
}
|
||||
|
||||
PIXI.Polygon.constructor = PIXI.Polygon;
|
||||
|
||||
|
||||
/**
|
||||
* @author Mat Groves http://matgroves.com/ @Doormat23
|
||||
*/
|
||||
|
@ -956,7 +987,7 @@ PIXI.Text.prototype = Object.create(PIXI.Sprite.prototype);
|
|||
* @param {String} [style.font="bold 20pt Arial"] The style and size of the font
|
||||
* @param {Object} [style.fill="black"] A canvas fillstyle that will be used on the text eg "red", "#00FF00"
|
||||
* @param {String} [style.align="left"] An alignment of the multiline text ("left", "center" or "right")
|
||||
* @param {String} [style.stroke] A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00"
|
||||
* @param {String} [style.stroke="black"] A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00"
|
||||
* @param {Number} [style.strokeThickness=0] A number that represents the thickness of the stroke. Default is 0 (no stroke)
|
||||
* @param {Boolean} [style.wordWrap=false] Indicates if word wrap should be used
|
||||
* @param {Number} [style.wordWrapWidth=100] The width at which text will wrap
|
||||
|
@ -967,6 +998,7 @@ PIXI.Text.prototype.setStyle = function(style)
|
|||
style.font = style.font || "bold 20pt Arial";
|
||||
style.fill = style.fill || "black";
|
||||
style.align = style.align || "left";
|
||||
style.stroke = style.stroke || "black"; //provide a default, see: https://github.com/GoodBoyDigital/pixi.js/issues/136
|
||||
style.strokeThickness = style.strokeThickness || 0;
|
||||
style.wordWrap = style.wordWrap || false;
|
||||
style.wordWrapWidth = style.wordWrapWidth || 100;
|
||||
|
@ -1102,7 +1134,7 @@ PIXI.Text.prototype.determineFontHeight = function(fontStyle)
|
|||
var dummy = document.createElement("div");
|
||||
var dummyText = document.createTextNode("M");
|
||||
dummy.appendChild(dummyText);
|
||||
dummy.setAttribute("style", fontStyle);
|
||||
dummy.setAttribute("style", fontStyle + ';position:absolute;top:0;left:0');
|
||||
body.appendChild(dummy);
|
||||
|
||||
result = dummy.offsetHeight;
|
||||
|
@ -1301,11 +1333,11 @@ PIXI.BitmapText.prototype.updateText = function()
|
|||
|
||||
for(i = 0; i < chars.length; i++)
|
||||
{
|
||||
var char = new PIXI.Sprite(chars[i].texture)//PIXI.Sprite.fromFrame(chars[i].charCode);
|
||||
char.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
|
||||
char.position.y = chars[i].position.y * scale;
|
||||
char.scale.x = char.scale.y = scale;
|
||||
this.addChild(char);
|
||||
var c = new PIXI.Sprite(chars[i].texture)//PIXI.Sprite.fromFrame(chars[i].charCode);
|
||||
c.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
|
||||
c.position.y = chars[i].position.y * scale;
|
||||
c.scale.x = c.scale.y = scale;
|
||||
this.addChild(c);
|
||||
}
|
||||
|
||||
this.width = pos.x * scale;
|
||||
|
@ -1397,6 +1429,7 @@ PIXI.InteractionManager.prototype.collectInteractiveSprite = function(displayObj
|
|||
{
|
||||
var child = children[i];
|
||||
|
||||
if(child.visible) {
|
||||
// push all interactive bits
|
||||
if(child.interactive)
|
||||
{
|
||||
|
@ -1420,6 +1453,7 @@ PIXI.InteractionManager.prototype.collectInteractiveSprite = function(displayObj
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PIXI.InteractionManager.prototype.setTarget = function(target)
|
||||
{
|
||||
|
@ -1525,8 +1559,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();
|
||||
|
||||
|
@ -1551,8 +1583,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??
|
||||
|
@ -1589,7 +1619,6 @@ PIXI.InteractionManager.prototype.onMouseDown = function(event)
|
|||
|
||||
PIXI.InteractionManager.prototype.onMouseUp = function(event)
|
||||
{
|
||||
event.preventDefault();
|
||||
var global = this.mouse.global;
|
||||
|
||||
|
||||
|
@ -1637,46 +1666,40 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
|
||||
if(!item.visible)return false;
|
||||
|
||||
if(item instanceof PIXI.Sprite)
|
||||
{
|
||||
var worldTransform = item.worldTransform;
|
||||
|
||||
var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2],
|
||||
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);
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
if(x > x1 && x < x1 + width)
|
||||
//a sprite or display object with a hit area defined
|
||||
if(item.hitArea)
|
||||
{
|
||||
var y1 = -height * item.anchor.y;
|
||||
var hitArea = item.hitArea;
|
||||
|
||||
if(y > y1 && y < y1 + height)
|
||||
{
|
||||
// set the target property if a hit is true!
|
||||
interactionData.target = item
|
||||
//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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
||||
//Rectangle hit area
|
||||
else {
|
||||
var x1 = hitArea.x;
|
||||
if(x > x1 && x < x1 + hitArea.width)
|
||||
{
|
||||
|
@ -1684,6 +1707,28 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
|
||||
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)
|
||||
{
|
||||
y1 = -height * item.anchor.y;
|
||||
|
||||
if(y > y1 && y < y1 + height)
|
||||
{
|
||||
// set the target property if a hit is true!
|
||||
interactionData.target = item
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1705,8 +1750,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;
|
||||
|
||||
|
@ -1730,7 +1773,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;
|
||||
|
@ -1772,9 +1814,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;
|
||||
|
||||
|
@ -1956,7 +1995,9 @@ PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor)
|
|||
{
|
||||
this.backgroundColor = backgroundColor || 0x000000;
|
||||
this.backgroundColorSplit = HEXtoRGB(this.backgroundColor);
|
||||
this.backgroundColorString = "#" + this.backgroundColor.toString(16);
|
||||
var hex = this.backgroundColor.toString(16);
|
||||
hex = "000000".substr(0, 6 - hex.length) + hex;
|
||||
this.backgroundColorString = "#" + hex;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2001,19 +2042,38 @@ PIXI.Stage.prototype.__removeChild = function(child)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides requestAnimationFrame in a cross browser way.
|
||||
*/
|
||||
window.requestAnimFrame = (function() {
|
||||
return window.requestAnimationFrame ||
|
||||
window.webkitRequestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame ||
|
||||
window.oRequestAnimationFrame ||
|
||||
window.msRequestAnimationFrame ||
|
||||
function(/* function FrameRequestCallback */ callback, /* DOMElement Element */ element) {
|
||||
window.setTimeout(callback, 1000/60);
|
||||
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
|
||||
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
|
||||
|
||||
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
|
||||
|
||||
// MIT license
|
||||
|
||||
|
||||
var lastTime = 0;
|
||||
var vendors = ['ms', 'moz', 'webkit', 'o'];
|
||||
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
||||
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
|
||||
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
|
||||
|| window[vendors[x]+'CancelRequestAnimationFrame'];
|
||||
}
|
||||
|
||||
if (!window.requestAnimationFrame)
|
||||
window.requestAnimationFrame = function(callback, element) {
|
||||
var currTime = new Date().getTime();
|
||||
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
||||
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
|
||||
timeToCall);
|
||||
lastTime = currTime + timeToCall;
|
||||
return id;
|
||||
};
|
||||
})();
|
||||
|
||||
if (!window.cancelAnimationFrame)
|
||||
window.cancelAnimationFrame = function(id) {
|
||||
clearTimeout(id);
|
||||
};
|
||||
|
||||
window.requestAnimFrame = window.requestAnimationFrame;
|
||||
|
||||
function HEXtoRGB(hex) {
|
||||
return [(hex >> 16 & 0xFF) / 255, ( hex >> 8 & 0xFF) / 255, (hex & 0xFF)/ 255];
|
||||
|
@ -2045,7 +2105,7 @@ if (typeof Function.prototype.bind != 'function') {
|
|||
})();
|
||||
}
|
||||
|
||||
var AjaxRequest = function()
|
||||
var AjaxRequest = PIXI.AjaxRequest = function()
|
||||
{
|
||||
var activexmodes = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE
|
||||
|
||||
|
@ -4488,10 +4548,13 @@ PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject)
|
|||
}
|
||||
|
||||
// render!
|
||||
if(displayObject.children)
|
||||
{
|
||||
for (var i=0; i < displayObject.children.length; i++)
|
||||
{
|
||||
this.renderDisplayObject(displayObject.children[i]);
|
||||
}
|
||||
}
|
||||
|
||||
this.context.setTransform(1,0,0,1,0,0);
|
||||
}
|
||||
|
@ -7439,7 +7502,7 @@ PIXI.BitmapFontLoader.prototype.onLoaded = function()
|
|||
* When loaded this class will dispatch a "loaded" event
|
||||
* @class Spine
|
||||
* @constructor
|
||||
* @extends
|
||||
* @extends EventTarget
|
||||
* @param {String} url the url of the sprite sheet JSON file
|
||||
* @param {Boolean} crossorigin
|
||||
*/
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* Copyright (c) 2012, Mat Groves
|
||||
* http://goodboydigital.com/
|
||||
*
|
||||
* Compiled: 2013-06-12
|
||||
* Compiled: 2013-06-19
|
||||
*
|
||||
* Pixi.JS is licensed under the MIT License.
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
|
@ -124,6 +124,37 @@ PIXI.Rectangle.prototype.clone = function()
|
|||
PIXI.Rectangle.constructor = PIXI.Rectangle;
|
||||
|
||||
|
||||
/**
|
||||
* @author Adrien Brault <adrien.brault@gmail.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class Polygon
|
||||
* @constructor
|
||||
* @param points {Array}
|
||||
*/
|
||||
PIXI.Polygon = function(points)
|
||||
{
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
/**
|
||||
* @method clone
|
||||
* @return a copy of the polygon
|
||||
*/
|
||||
PIXI.Polygon.clone = function()
|
||||
{
|
||||
var points = [];
|
||||
for (var i=0; i<this.points.length; i++) {
|
||||
points.push(this.points[i].clone());
|
||||
}
|
||||
|
||||
return new PIXI.Polygon(points);
|
||||
}
|
||||
|
||||
PIXI.Polygon.constructor = PIXI.Polygon;
|
||||
|
||||
|
||||
/**
|
||||
* @author Mat Groves http://matgroves.com/ @Doormat23
|
||||
*/
|
||||
|
@ -956,7 +987,7 @@ PIXI.Text.prototype = Object.create(PIXI.Sprite.prototype);
|
|||
* @param {String} [style.font="bold 20pt Arial"] The style and size of the font
|
||||
* @param {Object} [style.fill="black"] A canvas fillstyle that will be used on the text eg "red", "#00FF00"
|
||||
* @param {String} [style.align="left"] An alignment of the multiline text ("left", "center" or "right")
|
||||
* @param {String} [style.stroke] A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00"
|
||||
* @param {String} [style.stroke="black"] A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00"
|
||||
* @param {Number} [style.strokeThickness=0] A number that represents the thickness of the stroke. Default is 0 (no stroke)
|
||||
* @param {Boolean} [style.wordWrap=false] Indicates if word wrap should be used
|
||||
* @param {Number} [style.wordWrapWidth=100] The width at which text will wrap
|
||||
|
@ -967,6 +998,7 @@ PIXI.Text.prototype.setStyle = function(style)
|
|||
style.font = style.font || "bold 20pt Arial";
|
||||
style.fill = style.fill || "black";
|
||||
style.align = style.align || "left";
|
||||
style.stroke = style.stroke || "black"; //provide a default, see: https://github.com/GoodBoyDigital/pixi.js/issues/136
|
||||
style.strokeThickness = style.strokeThickness || 0;
|
||||
style.wordWrap = style.wordWrap || false;
|
||||
style.wordWrapWidth = style.wordWrapWidth || 100;
|
||||
|
@ -1102,7 +1134,7 @@ PIXI.Text.prototype.determineFontHeight = function(fontStyle)
|
|||
var dummy = document.createElement("div");
|
||||
var dummyText = document.createTextNode("M");
|
||||
dummy.appendChild(dummyText);
|
||||
dummy.setAttribute("style", fontStyle);
|
||||
dummy.setAttribute("style", fontStyle + ';position:absolute;top:0;left:0');
|
||||
body.appendChild(dummy);
|
||||
|
||||
result = dummy.offsetHeight;
|
||||
|
@ -1301,11 +1333,11 @@ PIXI.BitmapText.prototype.updateText = function()
|
|||
|
||||
for(i = 0; i < chars.length; i++)
|
||||
{
|
||||
var char = new PIXI.Sprite(chars[i].texture)//PIXI.Sprite.fromFrame(chars[i].charCode);
|
||||
char.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
|
||||
char.position.y = chars[i].position.y * scale;
|
||||
char.scale.x = char.scale.y = scale;
|
||||
this.addChild(char);
|
||||
var c = new PIXI.Sprite(chars[i].texture)//PIXI.Sprite.fromFrame(chars[i].charCode);
|
||||
c.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
|
||||
c.position.y = chars[i].position.y * scale;
|
||||
c.scale.x = c.scale.y = scale;
|
||||
this.addChild(c);
|
||||
}
|
||||
|
||||
this.width = pos.x * scale;
|
||||
|
@ -1397,6 +1429,7 @@ PIXI.InteractionManager.prototype.collectInteractiveSprite = function(displayObj
|
|||
{
|
||||
var child = children[i];
|
||||
|
||||
if(child.visible) {
|
||||
// push all interactive bits
|
||||
if(child.interactive)
|
||||
{
|
||||
|
@ -1420,6 +1453,7 @@ PIXI.InteractionManager.prototype.collectInteractiveSprite = function(displayObj
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PIXI.InteractionManager.prototype.setTarget = function(target)
|
||||
{
|
||||
|
@ -1525,8 +1559,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();
|
||||
|
||||
|
@ -1551,8 +1583,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??
|
||||
|
@ -1589,7 +1619,6 @@ PIXI.InteractionManager.prototype.onMouseDown = function(event)
|
|||
|
||||
PIXI.InteractionManager.prototype.onMouseUp = function(event)
|
||||
{
|
||||
event.preventDefault();
|
||||
var global = this.mouse.global;
|
||||
|
||||
|
||||
|
@ -1637,46 +1666,40 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
|
||||
if(!item.visible)return false;
|
||||
|
||||
if(item instanceof PIXI.Sprite)
|
||||
{
|
||||
var worldTransform = item.worldTransform;
|
||||
|
||||
var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2],
|
||||
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);
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
if(x > x1 && x < x1 + width)
|
||||
//a sprite or display object with a hit area defined
|
||||
if(item.hitArea)
|
||||
{
|
||||
var y1 = -height * item.anchor.y;
|
||||
var hitArea = item.hitArea;
|
||||
|
||||
if(y > y1 && y < y1 + height)
|
||||
{
|
||||
// set the target property if a hit is true!
|
||||
interactionData.target = item
|
||||
//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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
||||
//Rectangle hit area
|
||||
else {
|
||||
var x1 = hitArea.x;
|
||||
if(x > x1 && x < x1 + hitArea.width)
|
||||
{
|
||||
|
@ -1684,6 +1707,28 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
|
||||
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)
|
||||
{
|
||||
y1 = -height * item.anchor.y;
|
||||
|
||||
if(y > y1 && y < y1 + height)
|
||||
{
|
||||
// set the target property if a hit is true!
|
||||
interactionData.target = item
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1705,8 +1750,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;
|
||||
|
||||
|
@ -1730,7 +1773,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;
|
||||
|
@ -1772,9 +1814,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;
|
||||
|
||||
|
@ -1956,7 +1995,9 @@ PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor)
|
|||
{
|
||||
this.backgroundColor = backgroundColor || 0x000000;
|
||||
this.backgroundColorSplit = HEXtoRGB(this.backgroundColor);
|
||||
this.backgroundColorString = "#" + this.backgroundColor.toString(16);
|
||||
var hex = this.backgroundColor.toString(16);
|
||||
hex = "000000".substr(0, 6 - hex.length) + hex;
|
||||
this.backgroundColorString = "#" + hex;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2001,19 +2042,38 @@ PIXI.Stage.prototype.__removeChild = function(child)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides requestAnimationFrame in a cross browser way.
|
||||
*/
|
||||
window.requestAnimFrame = (function() {
|
||||
return window.requestAnimationFrame ||
|
||||
window.webkitRequestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame ||
|
||||
window.oRequestAnimationFrame ||
|
||||
window.msRequestAnimationFrame ||
|
||||
function(/* function FrameRequestCallback */ callback, /* DOMElement Element */ element) {
|
||||
window.setTimeout(callback, 1000/60);
|
||||
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
|
||||
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
|
||||
|
||||
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
|
||||
|
||||
// MIT license
|
||||
|
||||
|
||||
var lastTime = 0;
|
||||
var vendors = ['ms', 'moz', 'webkit', 'o'];
|
||||
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
||||
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
|
||||
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
|
||||
|| window[vendors[x]+'CancelRequestAnimationFrame'];
|
||||
}
|
||||
|
||||
if (!window.requestAnimationFrame)
|
||||
window.requestAnimationFrame = function(callback, element) {
|
||||
var currTime = new Date().getTime();
|
||||
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
||||
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
|
||||
timeToCall);
|
||||
lastTime = currTime + timeToCall;
|
||||
return id;
|
||||
};
|
||||
})();
|
||||
|
||||
if (!window.cancelAnimationFrame)
|
||||
window.cancelAnimationFrame = function(id) {
|
||||
clearTimeout(id);
|
||||
};
|
||||
|
||||
window.requestAnimFrame = window.requestAnimationFrame;
|
||||
|
||||
function HEXtoRGB(hex) {
|
||||
return [(hex >> 16 & 0xFF) / 255, ( hex >> 8 & 0xFF) / 255, (hex & 0xFF)/ 255];
|
||||
|
@ -2045,7 +2105,7 @@ if (typeof Function.prototype.bind != 'function') {
|
|||
})();
|
||||
}
|
||||
|
||||
var AjaxRequest = function()
|
||||
var AjaxRequest = PIXI.AjaxRequest = function()
|
||||
{
|
||||
var activexmodes = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE
|
||||
|
||||
|
@ -4488,10 +4548,13 @@ PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject)
|
|||
}
|
||||
|
||||
// render!
|
||||
if(displayObject.children)
|
||||
{
|
||||
for (var i=0; i < displayObject.children.length; i++)
|
||||
{
|
||||
this.renderDisplayObject(displayObject.children[i]);
|
||||
}
|
||||
}
|
||||
|
||||
this.context.setTransform(1,0,0,1,0,0);
|
||||
}
|
||||
|
@ -7439,7 +7502,7 @@ PIXI.BitmapFontLoader.prototype.onLoaded = function()
|
|||
* When loaded this class will dispatch a "loaded" event
|
||||
* @class Spine
|
||||
* @constructor
|
||||
* @extends
|
||||
* @extends EventTarget
|
||||
* @param {String} url the url of the sprite sheet JSON file
|
||||
* @param {Boolean} crossorigin
|
||||
*/
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* Copyright (c) 2012, Mat Groves
|
||||
* http://goodboydigital.com/
|
||||
*
|
||||
* Compiled: 2013-06-12
|
||||
* Compiled: 2013-06-19
|
||||
*
|
||||
* Pixi.JS is licensed under the MIT License.
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
|
@ -124,6 +124,37 @@ PIXI.Rectangle.prototype.clone = function()
|
|||
PIXI.Rectangle.constructor = PIXI.Rectangle;
|
||||
|
||||
|
||||
/**
|
||||
* @author Adrien Brault <adrien.brault@gmail.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class Polygon
|
||||
* @constructor
|
||||
* @param points {Array}
|
||||
*/
|
||||
PIXI.Polygon = function(points)
|
||||
{
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
/**
|
||||
* @method clone
|
||||
* @return a copy of the polygon
|
||||
*/
|
||||
PIXI.Polygon.clone = function()
|
||||
{
|
||||
var points = [];
|
||||
for (var i=0; i<this.points.length; i++) {
|
||||
points.push(this.points[i].clone());
|
||||
}
|
||||
|
||||
return new PIXI.Polygon(points);
|
||||
}
|
||||
|
||||
PIXI.Polygon.constructor = PIXI.Polygon;
|
||||
|
||||
|
||||
/**
|
||||
* @author Mat Groves http://matgroves.com/ @Doormat23
|
||||
*/
|
||||
|
@ -956,7 +987,7 @@ PIXI.Text.prototype = Object.create(PIXI.Sprite.prototype);
|
|||
* @param {String} [style.font="bold 20pt Arial"] The style and size of the font
|
||||
* @param {Object} [style.fill="black"] A canvas fillstyle that will be used on the text eg "red", "#00FF00"
|
||||
* @param {String} [style.align="left"] An alignment of the multiline text ("left", "center" or "right")
|
||||
* @param {String} [style.stroke] A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00"
|
||||
* @param {String} [style.stroke="black"] A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00"
|
||||
* @param {Number} [style.strokeThickness=0] A number that represents the thickness of the stroke. Default is 0 (no stroke)
|
||||
* @param {Boolean} [style.wordWrap=false] Indicates if word wrap should be used
|
||||
* @param {Number} [style.wordWrapWidth=100] The width at which text will wrap
|
||||
|
@ -967,6 +998,7 @@ PIXI.Text.prototype.setStyle = function(style)
|
|||
style.font = style.font || "bold 20pt Arial";
|
||||
style.fill = style.fill || "black";
|
||||
style.align = style.align || "left";
|
||||
style.stroke = style.stroke || "black"; //provide a default, see: https://github.com/GoodBoyDigital/pixi.js/issues/136
|
||||
style.strokeThickness = style.strokeThickness || 0;
|
||||
style.wordWrap = style.wordWrap || false;
|
||||
style.wordWrapWidth = style.wordWrapWidth || 100;
|
||||
|
@ -1102,7 +1134,7 @@ PIXI.Text.prototype.determineFontHeight = function(fontStyle)
|
|||
var dummy = document.createElement("div");
|
||||
var dummyText = document.createTextNode("M");
|
||||
dummy.appendChild(dummyText);
|
||||
dummy.setAttribute("style", fontStyle);
|
||||
dummy.setAttribute("style", fontStyle + ';position:absolute;top:0;left:0');
|
||||
body.appendChild(dummy);
|
||||
|
||||
result = dummy.offsetHeight;
|
||||
|
@ -1301,11 +1333,11 @@ PIXI.BitmapText.prototype.updateText = function()
|
|||
|
||||
for(i = 0; i < chars.length; i++)
|
||||
{
|
||||
var char = new PIXI.Sprite(chars[i].texture)//PIXI.Sprite.fromFrame(chars[i].charCode);
|
||||
char.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
|
||||
char.position.y = chars[i].position.y * scale;
|
||||
char.scale.x = char.scale.y = scale;
|
||||
this.addChild(char);
|
||||
var c = new PIXI.Sprite(chars[i].texture)//PIXI.Sprite.fromFrame(chars[i].charCode);
|
||||
c.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
|
||||
c.position.y = chars[i].position.y * scale;
|
||||
c.scale.x = c.scale.y = scale;
|
||||
this.addChild(c);
|
||||
}
|
||||
|
||||
this.width = pos.x * scale;
|
||||
|
@ -1397,6 +1429,7 @@ PIXI.InteractionManager.prototype.collectInteractiveSprite = function(displayObj
|
|||
{
|
||||
var child = children[i];
|
||||
|
||||
if(child.visible) {
|
||||
// push all interactive bits
|
||||
if(child.interactive)
|
||||
{
|
||||
|
@ -1420,6 +1453,7 @@ PIXI.InteractionManager.prototype.collectInteractiveSprite = function(displayObj
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PIXI.InteractionManager.prototype.setTarget = function(target)
|
||||
{
|
||||
|
@ -1525,8 +1559,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();
|
||||
|
||||
|
@ -1551,8 +1583,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??
|
||||
|
@ -1589,7 +1619,6 @@ PIXI.InteractionManager.prototype.onMouseDown = function(event)
|
|||
|
||||
PIXI.InteractionManager.prototype.onMouseUp = function(event)
|
||||
{
|
||||
event.preventDefault();
|
||||
var global = this.mouse.global;
|
||||
|
||||
|
||||
|
@ -1637,46 +1666,40 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
|
||||
if(!item.visible)return false;
|
||||
|
||||
if(item instanceof PIXI.Sprite)
|
||||
{
|
||||
var worldTransform = item.worldTransform;
|
||||
|
||||
var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2],
|
||||
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);
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
if(x > x1 && x < x1 + width)
|
||||
//a sprite or display object with a hit area defined
|
||||
if(item.hitArea)
|
||||
{
|
||||
var y1 = -height * item.anchor.y;
|
||||
var hitArea = item.hitArea;
|
||||
|
||||
if(y > y1 && y < y1 + height)
|
||||
{
|
||||
// set the target property if a hit is true!
|
||||
interactionData.target = item
|
||||
//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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
||||
//Rectangle hit area
|
||||
else {
|
||||
var x1 = hitArea.x;
|
||||
if(x > x1 && x < x1 + hitArea.width)
|
||||
{
|
||||
|
@ -1684,6 +1707,28 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
|
||||
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)
|
||||
{
|
||||
y1 = -height * item.anchor.y;
|
||||
|
||||
if(y > y1 && y < y1 + height)
|
||||
{
|
||||
// set the target property if a hit is true!
|
||||
interactionData.target = item
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1705,8 +1750,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;
|
||||
|
||||
|
@ -1730,7 +1773,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;
|
||||
|
@ -1772,9 +1814,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;
|
||||
|
||||
|
@ -1956,7 +1995,9 @@ PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor)
|
|||
{
|
||||
this.backgroundColor = backgroundColor || 0x000000;
|
||||
this.backgroundColorSplit = HEXtoRGB(this.backgroundColor);
|
||||
this.backgroundColorString = "#" + this.backgroundColor.toString(16);
|
||||
var hex = this.backgroundColor.toString(16);
|
||||
hex = "000000".substr(0, 6 - hex.length) + hex;
|
||||
this.backgroundColorString = "#" + hex;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2001,19 +2042,38 @@ PIXI.Stage.prototype.__removeChild = function(child)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides requestAnimationFrame in a cross browser way.
|
||||
*/
|
||||
window.requestAnimFrame = (function() {
|
||||
return window.requestAnimationFrame ||
|
||||
window.webkitRequestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame ||
|
||||
window.oRequestAnimationFrame ||
|
||||
window.msRequestAnimationFrame ||
|
||||
function(/* function FrameRequestCallback */ callback, /* DOMElement Element */ element) {
|
||||
window.setTimeout(callback, 1000/60);
|
||||
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
|
||||
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
|
||||
|
||||
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
|
||||
|
||||
// MIT license
|
||||
|
||||
|
||||
var lastTime = 0;
|
||||
var vendors = ['ms', 'moz', 'webkit', 'o'];
|
||||
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
||||
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
|
||||
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
|
||||
|| window[vendors[x]+'CancelRequestAnimationFrame'];
|
||||
}
|
||||
|
||||
if (!window.requestAnimationFrame)
|
||||
window.requestAnimationFrame = function(callback, element) {
|
||||
var currTime = new Date().getTime();
|
||||
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
||||
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
|
||||
timeToCall);
|
||||
lastTime = currTime + timeToCall;
|
||||
return id;
|
||||
};
|
||||
})();
|
||||
|
||||
if (!window.cancelAnimationFrame)
|
||||
window.cancelAnimationFrame = function(id) {
|
||||
clearTimeout(id);
|
||||
};
|
||||
|
||||
window.requestAnimFrame = window.requestAnimationFrame;
|
||||
|
||||
function HEXtoRGB(hex) {
|
||||
return [(hex >> 16 & 0xFF) / 255, ( hex >> 8 & 0xFF) / 255, (hex & 0xFF)/ 255];
|
||||
|
@ -2045,7 +2105,7 @@ if (typeof Function.prototype.bind != 'function') {
|
|||
})();
|
||||
}
|
||||
|
||||
var AjaxRequest = function()
|
||||
var AjaxRequest = PIXI.AjaxRequest = function()
|
||||
{
|
||||
var activexmodes = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE
|
||||
|
||||
|
@ -4488,10 +4548,13 @@ PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject)
|
|||
}
|
||||
|
||||
// render!
|
||||
if(displayObject.children)
|
||||
{
|
||||
for (var i=0; i < displayObject.children.length; i++)
|
||||
{
|
||||
this.renderDisplayObject(displayObject.children[i]);
|
||||
}
|
||||
}
|
||||
|
||||
this.context.setTransform(1,0,0,1,0,0);
|
||||
}
|
||||
|
@ -7439,7 +7502,7 @@ PIXI.BitmapFontLoader.prototype.onLoaded = function()
|
|||
* When loaded this class will dispatch a "loaded" event
|
||||
* @class Spine
|
||||
* @constructor
|
||||
* @extends
|
||||
* @extends EventTarget
|
||||
* @param {String} url the url of the sprite sheet JSON file
|
||||
* @param {Boolean} crossorigin
|
||||
*/
|
||||
|
|
64
examples/example 13 - Custom Renderer/index.html
Normal file
64
examples/example 13 - Custom Renderer/index.html
Normal file
|
@ -0,0 +1,64 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>pixi.js example 12 Spine</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
background-color: #000000;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
<script src="pixi.js"></script>
|
||||
<script src="../../bin/pixi.dev.js"></script>
|
||||
<script src="../../src/pixi/extras/CustomRenderable.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
|
||||
var renderer = new PIXI.CanvasRenderer(800, 600);
|
||||
renderer.view.id = 'canvas';
|
||||
document.body.appendChild(renderer.view);
|
||||
renderer.view.style.position = "absolute";
|
||||
|
||||
var stage = new PIXI.Stage(0xFFFFFF, true);
|
||||
|
||||
var container = new PIXI.DisplayObjectContainer();
|
||||
|
||||
stage.addChild(container);
|
||||
|
||||
|
||||
|
||||
var p2 = {};
|
||||
p2.Shape = function(){
|
||||
PIXI.CustomRenderable.apply(this);
|
||||
};
|
||||
p2.Shape.constructor = p2.Shape;
|
||||
p2.Shape.prototype = Object.create(PIXI.CustomRenderable.prototype);
|
||||
|
||||
p2.Circle = function(body, radius){
|
||||
p2.Shape.apply(this);
|
||||
};
|
||||
|
||||
p2.Circle.prototype.renderCanvas = function(renderer){
|
||||
//render stuff
|
||||
};
|
||||
|
||||
p2.Circle.prototype = Object.create(p2.Shape.prototype);
|
||||
|
||||
container.addChild(new p2.Circle());
|
||||
|
||||
requestAnimFrame(animate);
|
||||
|
||||
function animate() {
|
||||
|
||||
requestAnimFrame( animate );
|
||||
renderer.render(stage);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
7515
examples/example 13 - Custom Renderer/pixi.js
Normal file
7515
examples/example 13 - Custom Renderer/pixi.js
Normal file
File diff suppressed because it is too large
Load diff
|
@ -4,7 +4,7 @@
|
|||
* Copyright (c) 2012, Mat Groves
|
||||
* http://goodboydigital.com/
|
||||
*
|
||||
* Compiled: 2013-06-12
|
||||
* Compiled: 2013-06-19
|
||||
*
|
||||
* Pixi.JS is licensed under the MIT License.
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
|
@ -124,6 +124,37 @@ PIXI.Rectangle.prototype.clone = function()
|
|||
PIXI.Rectangle.constructor = PIXI.Rectangle;
|
||||
|
||||
|
||||
/**
|
||||
* @author Adrien Brault <adrien.brault@gmail.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class Polygon
|
||||
* @constructor
|
||||
* @param points {Array}
|
||||
*/
|
||||
PIXI.Polygon = function(points)
|
||||
{
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
/**
|
||||
* @method clone
|
||||
* @return a copy of the polygon
|
||||
*/
|
||||
PIXI.Polygon.clone = function()
|
||||
{
|
||||
var points = [];
|
||||
for (var i=0; i<this.points.length; i++) {
|
||||
points.push(this.points[i].clone());
|
||||
}
|
||||
|
||||
return new PIXI.Polygon(points);
|
||||
}
|
||||
|
||||
PIXI.Polygon.constructor = PIXI.Polygon;
|
||||
|
||||
|
||||
/**
|
||||
* @author Mat Groves http://matgroves.com/ @Doormat23
|
||||
*/
|
||||
|
@ -956,7 +987,7 @@ PIXI.Text.prototype = Object.create(PIXI.Sprite.prototype);
|
|||
* @param {String} [style.font="bold 20pt Arial"] The style and size of the font
|
||||
* @param {Object} [style.fill="black"] A canvas fillstyle that will be used on the text eg "red", "#00FF00"
|
||||
* @param {String} [style.align="left"] An alignment of the multiline text ("left", "center" or "right")
|
||||
* @param {String} [style.stroke] A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00"
|
||||
* @param {String} [style.stroke="black"] A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00"
|
||||
* @param {Number} [style.strokeThickness=0] A number that represents the thickness of the stroke. Default is 0 (no stroke)
|
||||
* @param {Boolean} [style.wordWrap=false] Indicates if word wrap should be used
|
||||
* @param {Number} [style.wordWrapWidth=100] The width at which text will wrap
|
||||
|
@ -967,6 +998,7 @@ PIXI.Text.prototype.setStyle = function(style)
|
|||
style.font = style.font || "bold 20pt Arial";
|
||||
style.fill = style.fill || "black";
|
||||
style.align = style.align || "left";
|
||||
style.stroke = style.stroke || "black"; //provide a default, see: https://github.com/GoodBoyDigital/pixi.js/issues/136
|
||||
style.strokeThickness = style.strokeThickness || 0;
|
||||
style.wordWrap = style.wordWrap || false;
|
||||
style.wordWrapWidth = style.wordWrapWidth || 100;
|
||||
|
@ -1102,7 +1134,7 @@ PIXI.Text.prototype.determineFontHeight = function(fontStyle)
|
|||
var dummy = document.createElement("div");
|
||||
var dummyText = document.createTextNode("M");
|
||||
dummy.appendChild(dummyText);
|
||||
dummy.setAttribute("style", fontStyle);
|
||||
dummy.setAttribute("style", fontStyle + ';position:absolute;top:0;left:0');
|
||||
body.appendChild(dummy);
|
||||
|
||||
result = dummy.offsetHeight;
|
||||
|
@ -1301,11 +1333,11 @@ PIXI.BitmapText.prototype.updateText = function()
|
|||
|
||||
for(i = 0; i < chars.length; i++)
|
||||
{
|
||||
var char = new PIXI.Sprite(chars[i].texture)//PIXI.Sprite.fromFrame(chars[i].charCode);
|
||||
char.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
|
||||
char.position.y = chars[i].position.y * scale;
|
||||
char.scale.x = char.scale.y = scale;
|
||||
this.addChild(char);
|
||||
var c = new PIXI.Sprite(chars[i].texture)//PIXI.Sprite.fromFrame(chars[i].charCode);
|
||||
c.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
|
||||
c.position.y = chars[i].position.y * scale;
|
||||
c.scale.x = c.scale.y = scale;
|
||||
this.addChild(c);
|
||||
}
|
||||
|
||||
this.width = pos.x * scale;
|
||||
|
@ -1397,6 +1429,7 @@ PIXI.InteractionManager.prototype.collectInteractiveSprite = function(displayObj
|
|||
{
|
||||
var child = children[i];
|
||||
|
||||
if(child.visible) {
|
||||
// push all interactive bits
|
||||
if(child.interactive)
|
||||
{
|
||||
|
@ -1420,6 +1453,7 @@ PIXI.InteractionManager.prototype.collectInteractiveSprite = function(displayObj
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PIXI.InteractionManager.prototype.setTarget = function(target)
|
||||
{
|
||||
|
@ -1525,8 +1559,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();
|
||||
|
||||
|
@ -1551,8 +1583,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??
|
||||
|
@ -1589,7 +1619,6 @@ PIXI.InteractionManager.prototype.onMouseDown = function(event)
|
|||
|
||||
PIXI.InteractionManager.prototype.onMouseUp = function(event)
|
||||
{
|
||||
event.preventDefault();
|
||||
var global = this.mouse.global;
|
||||
|
||||
|
||||
|
@ -1637,46 +1666,40 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
|
||||
if(!item.visible)return false;
|
||||
|
||||
if(item instanceof PIXI.Sprite)
|
||||
{
|
||||
var worldTransform = item.worldTransform;
|
||||
|
||||
var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2],
|
||||
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);
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
if(x > x1 && x < x1 + width)
|
||||
//a sprite or display object with a hit area defined
|
||||
if(item.hitArea)
|
||||
{
|
||||
var y1 = -height * item.anchor.y;
|
||||
var hitArea = item.hitArea;
|
||||
|
||||
if(y > y1 && y < y1 + height)
|
||||
{
|
||||
// set the target property if a hit is true!
|
||||
interactionData.target = item
|
||||
//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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
||||
//Rectangle hit area
|
||||
else {
|
||||
var x1 = hitArea.x;
|
||||
if(x > x1 && x < x1 + hitArea.width)
|
||||
{
|
||||
|
@ -1684,6 +1707,28 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
|
||||
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)
|
||||
{
|
||||
y1 = -height * item.anchor.y;
|
||||
|
||||
if(y > y1 && y < y1 + height)
|
||||
{
|
||||
// set the target property if a hit is true!
|
||||
interactionData.target = item
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1705,8 +1750,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;
|
||||
|
||||
|
@ -1730,7 +1773,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;
|
||||
|
@ -1772,9 +1814,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;
|
||||
|
||||
|
@ -1956,7 +1995,9 @@ PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor)
|
|||
{
|
||||
this.backgroundColor = backgroundColor || 0x000000;
|
||||
this.backgroundColorSplit = HEXtoRGB(this.backgroundColor);
|
||||
this.backgroundColorString = "#" + this.backgroundColor.toString(16);
|
||||
var hex = this.backgroundColor.toString(16);
|
||||
hex = "000000".substr(0, 6 - hex.length) + hex;
|
||||
this.backgroundColorString = "#" + hex;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2001,19 +2042,38 @@ PIXI.Stage.prototype.__removeChild = function(child)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides requestAnimationFrame in a cross browser way.
|
||||
*/
|
||||
window.requestAnimFrame = (function() {
|
||||
return window.requestAnimationFrame ||
|
||||
window.webkitRequestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame ||
|
||||
window.oRequestAnimationFrame ||
|
||||
window.msRequestAnimationFrame ||
|
||||
function(/* function FrameRequestCallback */ callback, /* DOMElement Element */ element) {
|
||||
window.setTimeout(callback, 1000/60);
|
||||
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
|
||||
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
|
||||
|
||||
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
|
||||
|
||||
// MIT license
|
||||
|
||||
|
||||
var lastTime = 0;
|
||||
var vendors = ['ms', 'moz', 'webkit', 'o'];
|
||||
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
||||
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
|
||||
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
|
||||
|| window[vendors[x]+'CancelRequestAnimationFrame'];
|
||||
}
|
||||
|
||||
if (!window.requestAnimationFrame)
|
||||
window.requestAnimationFrame = function(callback, element) {
|
||||
var currTime = new Date().getTime();
|
||||
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
||||
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
|
||||
timeToCall);
|
||||
lastTime = currTime + timeToCall;
|
||||
return id;
|
||||
};
|
||||
})();
|
||||
|
||||
if (!window.cancelAnimationFrame)
|
||||
window.cancelAnimationFrame = function(id) {
|
||||
clearTimeout(id);
|
||||
};
|
||||
|
||||
window.requestAnimFrame = window.requestAnimationFrame;
|
||||
|
||||
function HEXtoRGB(hex) {
|
||||
return [(hex >> 16 & 0xFF) / 255, ( hex >> 8 & 0xFF) / 255, (hex & 0xFF)/ 255];
|
||||
|
@ -2045,7 +2105,7 @@ if (typeof Function.prototype.bind != 'function') {
|
|||
})();
|
||||
}
|
||||
|
||||
var AjaxRequest = function()
|
||||
var AjaxRequest = PIXI.AjaxRequest = function()
|
||||
{
|
||||
var activexmodes = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE
|
||||
|
||||
|
@ -4488,10 +4548,13 @@ PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject)
|
|||
}
|
||||
|
||||
// render!
|
||||
if(displayObject.children)
|
||||
{
|
||||
for (var i=0; i < displayObject.children.length; i++)
|
||||
{
|
||||
this.renderDisplayObject(displayObject.children[i]);
|
||||
}
|
||||
}
|
||||
|
||||
this.context.setTransform(1,0,0,1,0,0);
|
||||
}
|
||||
|
@ -7439,7 +7502,7 @@ PIXI.BitmapFontLoader.prototype.onLoaded = function()
|
|||
* When loaded this class will dispatch a "loaded" event
|
||||
* @class Spine
|
||||
* @constructor
|
||||
* @extends
|
||||
* @extends EventTarget
|
||||
* @param {String} url the url of the sprite sheet JSON file
|
||||
* @param {Boolean} crossorigin
|
||||
*/
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* Copyright (c) 2012, Mat Groves
|
||||
* http://goodboydigital.com/
|
||||
*
|
||||
* Compiled: 2013-06-12
|
||||
* Compiled: 2013-06-19
|
||||
*
|
||||
* Pixi.JS is licensed under the MIT License.
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
|
@ -124,6 +124,37 @@ PIXI.Rectangle.prototype.clone = function()
|
|||
PIXI.Rectangle.constructor = PIXI.Rectangle;
|
||||
|
||||
|
||||
/**
|
||||
* @author Adrien Brault <adrien.brault@gmail.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class Polygon
|
||||
* @constructor
|
||||
* @param points {Array}
|
||||
*/
|
||||
PIXI.Polygon = function(points)
|
||||
{
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
/**
|
||||
* @method clone
|
||||
* @return a copy of the polygon
|
||||
*/
|
||||
PIXI.Polygon.clone = function()
|
||||
{
|
||||
var points = [];
|
||||
for (var i=0; i<this.points.length; i++) {
|
||||
points.push(this.points[i].clone());
|
||||
}
|
||||
|
||||
return new PIXI.Polygon(points);
|
||||
}
|
||||
|
||||
PIXI.Polygon.constructor = PIXI.Polygon;
|
||||
|
||||
|
||||
/**
|
||||
* @author Mat Groves http://matgroves.com/ @Doormat23
|
||||
*/
|
||||
|
@ -956,7 +987,7 @@ PIXI.Text.prototype = Object.create(PIXI.Sprite.prototype);
|
|||
* @param {String} [style.font="bold 20pt Arial"] The style and size of the font
|
||||
* @param {Object} [style.fill="black"] A canvas fillstyle that will be used on the text eg "red", "#00FF00"
|
||||
* @param {String} [style.align="left"] An alignment of the multiline text ("left", "center" or "right")
|
||||
* @param {String} [style.stroke] A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00"
|
||||
* @param {String} [style.stroke="black"] A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00"
|
||||
* @param {Number} [style.strokeThickness=0] A number that represents the thickness of the stroke. Default is 0 (no stroke)
|
||||
* @param {Boolean} [style.wordWrap=false] Indicates if word wrap should be used
|
||||
* @param {Number} [style.wordWrapWidth=100] The width at which text will wrap
|
||||
|
@ -967,6 +998,7 @@ PIXI.Text.prototype.setStyle = function(style)
|
|||
style.font = style.font || "bold 20pt Arial";
|
||||
style.fill = style.fill || "black";
|
||||
style.align = style.align || "left";
|
||||
style.stroke = style.stroke || "black"; //provide a default, see: https://github.com/GoodBoyDigital/pixi.js/issues/136
|
||||
style.strokeThickness = style.strokeThickness || 0;
|
||||
style.wordWrap = style.wordWrap || false;
|
||||
style.wordWrapWidth = style.wordWrapWidth || 100;
|
||||
|
@ -1102,7 +1134,7 @@ PIXI.Text.prototype.determineFontHeight = function(fontStyle)
|
|||
var dummy = document.createElement("div");
|
||||
var dummyText = document.createTextNode("M");
|
||||
dummy.appendChild(dummyText);
|
||||
dummy.setAttribute("style", fontStyle);
|
||||
dummy.setAttribute("style", fontStyle + ';position:absolute;top:0;left:0');
|
||||
body.appendChild(dummy);
|
||||
|
||||
result = dummy.offsetHeight;
|
||||
|
@ -1301,11 +1333,11 @@ PIXI.BitmapText.prototype.updateText = function()
|
|||
|
||||
for(i = 0; i < chars.length; i++)
|
||||
{
|
||||
var char = new PIXI.Sprite(chars[i].texture)//PIXI.Sprite.fromFrame(chars[i].charCode);
|
||||
char.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
|
||||
char.position.y = chars[i].position.y * scale;
|
||||
char.scale.x = char.scale.y = scale;
|
||||
this.addChild(char);
|
||||
var c = new PIXI.Sprite(chars[i].texture)//PIXI.Sprite.fromFrame(chars[i].charCode);
|
||||
c.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
|
||||
c.position.y = chars[i].position.y * scale;
|
||||
c.scale.x = c.scale.y = scale;
|
||||
this.addChild(c);
|
||||
}
|
||||
|
||||
this.width = pos.x * scale;
|
||||
|
@ -1397,6 +1429,7 @@ PIXI.InteractionManager.prototype.collectInteractiveSprite = function(displayObj
|
|||
{
|
||||
var child = children[i];
|
||||
|
||||
if(child.visible) {
|
||||
// push all interactive bits
|
||||
if(child.interactive)
|
||||
{
|
||||
|
@ -1420,6 +1453,7 @@ PIXI.InteractionManager.prototype.collectInteractiveSprite = function(displayObj
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PIXI.InteractionManager.prototype.setTarget = function(target)
|
||||
{
|
||||
|
@ -1525,8 +1559,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();
|
||||
|
||||
|
@ -1551,8 +1583,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??
|
||||
|
@ -1589,7 +1619,6 @@ PIXI.InteractionManager.prototype.onMouseDown = function(event)
|
|||
|
||||
PIXI.InteractionManager.prototype.onMouseUp = function(event)
|
||||
{
|
||||
event.preventDefault();
|
||||
var global = this.mouse.global;
|
||||
|
||||
|
||||
|
@ -1637,46 +1666,40 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
|
||||
if(!item.visible)return false;
|
||||
|
||||
if(item instanceof PIXI.Sprite)
|
||||
{
|
||||
var worldTransform = item.worldTransform;
|
||||
|
||||
var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2],
|
||||
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);
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
if(x > x1 && x < x1 + width)
|
||||
//a sprite or display object with a hit area defined
|
||||
if(item.hitArea)
|
||||
{
|
||||
var y1 = -height * item.anchor.y;
|
||||
var hitArea = item.hitArea;
|
||||
|
||||
if(y > y1 && y < y1 + height)
|
||||
{
|
||||
// set the target property if a hit is true!
|
||||
interactionData.target = item
|
||||
//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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
||||
//Rectangle hit area
|
||||
else {
|
||||
var x1 = hitArea.x;
|
||||
if(x > x1 && x < x1 + hitArea.width)
|
||||
{
|
||||
|
@ -1684,6 +1707,28 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
|
||||
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)
|
||||
{
|
||||
y1 = -height * item.anchor.y;
|
||||
|
||||
if(y > y1 && y < y1 + height)
|
||||
{
|
||||
// set the target property if a hit is true!
|
||||
interactionData.target = item
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1705,8 +1750,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;
|
||||
|
||||
|
@ -1730,7 +1773,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;
|
||||
|
@ -1772,9 +1814,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;
|
||||
|
||||
|
@ -1956,7 +1995,9 @@ PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor)
|
|||
{
|
||||
this.backgroundColor = backgroundColor || 0x000000;
|
||||
this.backgroundColorSplit = HEXtoRGB(this.backgroundColor);
|
||||
this.backgroundColorString = "#" + this.backgroundColor.toString(16);
|
||||
var hex = this.backgroundColor.toString(16);
|
||||
hex = "000000".substr(0, 6 - hex.length) + hex;
|
||||
this.backgroundColorString = "#" + hex;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2001,19 +2042,38 @@ PIXI.Stage.prototype.__removeChild = function(child)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides requestAnimationFrame in a cross browser way.
|
||||
*/
|
||||
window.requestAnimFrame = (function() {
|
||||
return window.requestAnimationFrame ||
|
||||
window.webkitRequestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame ||
|
||||
window.oRequestAnimationFrame ||
|
||||
window.msRequestAnimationFrame ||
|
||||
function(/* function FrameRequestCallback */ callback, /* DOMElement Element */ element) {
|
||||
window.setTimeout(callback, 1000/60);
|
||||
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
|
||||
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
|
||||
|
||||
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
|
||||
|
||||
// MIT license
|
||||
|
||||
|
||||
var lastTime = 0;
|
||||
var vendors = ['ms', 'moz', 'webkit', 'o'];
|
||||
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
||||
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
|
||||
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
|
||||
|| window[vendors[x]+'CancelRequestAnimationFrame'];
|
||||
}
|
||||
|
||||
if (!window.requestAnimationFrame)
|
||||
window.requestAnimationFrame = function(callback, element) {
|
||||
var currTime = new Date().getTime();
|
||||
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
||||
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
|
||||
timeToCall);
|
||||
lastTime = currTime + timeToCall;
|
||||
return id;
|
||||
};
|
||||
})();
|
||||
|
||||
if (!window.cancelAnimationFrame)
|
||||
window.cancelAnimationFrame = function(id) {
|
||||
clearTimeout(id);
|
||||
};
|
||||
|
||||
window.requestAnimFrame = window.requestAnimationFrame;
|
||||
|
||||
function HEXtoRGB(hex) {
|
||||
return [(hex >> 16 & 0xFF) / 255, ( hex >> 8 & 0xFF) / 255, (hex & 0xFF)/ 255];
|
||||
|
@ -2045,7 +2105,7 @@ if (typeof Function.prototype.bind != 'function') {
|
|||
})();
|
||||
}
|
||||
|
||||
var AjaxRequest = function()
|
||||
var AjaxRequest = PIXI.AjaxRequest = function()
|
||||
{
|
||||
var activexmodes = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE
|
||||
|
||||
|
@ -4488,10 +4548,13 @@ PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject)
|
|||
}
|
||||
|
||||
// render!
|
||||
if(displayObject.children)
|
||||
{
|
||||
for (var i=0; i < displayObject.children.length; i++)
|
||||
{
|
||||
this.renderDisplayObject(displayObject.children[i]);
|
||||
}
|
||||
}
|
||||
|
||||
this.context.setTransform(1,0,0,1,0,0);
|
||||
}
|
||||
|
@ -7439,7 +7502,7 @@ PIXI.BitmapFontLoader.prototype.onLoaded = function()
|
|||
* When loaded this class will dispatch a "loaded" event
|
||||
* @class Spine
|
||||
* @constructor
|
||||
* @extends
|
||||
* @extends EventTarget
|
||||
* @param {String} url the url of the sprite sheet JSON file
|
||||
* @param {Boolean} crossorigin
|
||||
*/
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* Copyright (c) 2012, Mat Groves
|
||||
* http://goodboydigital.com/
|
||||
*
|
||||
* Compiled: 2013-06-12
|
||||
* Compiled: 2013-06-19
|
||||
*
|
||||
* Pixi.JS is licensed under the MIT License.
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
|
@ -124,6 +124,37 @@ PIXI.Rectangle.prototype.clone = function()
|
|||
PIXI.Rectangle.constructor = PIXI.Rectangle;
|
||||
|
||||
|
||||
/**
|
||||
* @author Adrien Brault <adrien.brault@gmail.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class Polygon
|
||||
* @constructor
|
||||
* @param points {Array}
|
||||
*/
|
||||
PIXI.Polygon = function(points)
|
||||
{
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
/**
|
||||
* @method clone
|
||||
* @return a copy of the polygon
|
||||
*/
|
||||
PIXI.Polygon.clone = function()
|
||||
{
|
||||
var points = [];
|
||||
for (var i=0; i<this.points.length; i++) {
|
||||
points.push(this.points[i].clone());
|
||||
}
|
||||
|
||||
return new PIXI.Polygon(points);
|
||||
}
|
||||
|
||||
PIXI.Polygon.constructor = PIXI.Polygon;
|
||||
|
||||
|
||||
/**
|
||||
* @author Mat Groves http://matgroves.com/ @Doormat23
|
||||
*/
|
||||
|
@ -956,7 +987,7 @@ PIXI.Text.prototype = Object.create(PIXI.Sprite.prototype);
|
|||
* @param {String} [style.font="bold 20pt Arial"] The style and size of the font
|
||||
* @param {Object} [style.fill="black"] A canvas fillstyle that will be used on the text eg "red", "#00FF00"
|
||||
* @param {String} [style.align="left"] An alignment of the multiline text ("left", "center" or "right")
|
||||
* @param {String} [style.stroke] A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00"
|
||||
* @param {String} [style.stroke="black"] A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00"
|
||||
* @param {Number} [style.strokeThickness=0] A number that represents the thickness of the stroke. Default is 0 (no stroke)
|
||||
* @param {Boolean} [style.wordWrap=false] Indicates if word wrap should be used
|
||||
* @param {Number} [style.wordWrapWidth=100] The width at which text will wrap
|
||||
|
@ -967,6 +998,7 @@ PIXI.Text.prototype.setStyle = function(style)
|
|||
style.font = style.font || "bold 20pt Arial";
|
||||
style.fill = style.fill || "black";
|
||||
style.align = style.align || "left";
|
||||
style.stroke = style.stroke || "black"; //provide a default, see: https://github.com/GoodBoyDigital/pixi.js/issues/136
|
||||
style.strokeThickness = style.strokeThickness || 0;
|
||||
style.wordWrap = style.wordWrap || false;
|
||||
style.wordWrapWidth = style.wordWrapWidth || 100;
|
||||
|
@ -1102,7 +1134,7 @@ PIXI.Text.prototype.determineFontHeight = function(fontStyle)
|
|||
var dummy = document.createElement("div");
|
||||
var dummyText = document.createTextNode("M");
|
||||
dummy.appendChild(dummyText);
|
||||
dummy.setAttribute("style", fontStyle);
|
||||
dummy.setAttribute("style", fontStyle + ';position:absolute;top:0;left:0');
|
||||
body.appendChild(dummy);
|
||||
|
||||
result = dummy.offsetHeight;
|
||||
|
@ -1301,11 +1333,11 @@ PIXI.BitmapText.prototype.updateText = function()
|
|||
|
||||
for(i = 0; i < chars.length; i++)
|
||||
{
|
||||
var char = new PIXI.Sprite(chars[i].texture)//PIXI.Sprite.fromFrame(chars[i].charCode);
|
||||
char.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
|
||||
char.position.y = chars[i].position.y * scale;
|
||||
char.scale.x = char.scale.y = scale;
|
||||
this.addChild(char);
|
||||
var c = new PIXI.Sprite(chars[i].texture)//PIXI.Sprite.fromFrame(chars[i].charCode);
|
||||
c.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
|
||||
c.position.y = chars[i].position.y * scale;
|
||||
c.scale.x = c.scale.y = scale;
|
||||
this.addChild(c);
|
||||
}
|
||||
|
||||
this.width = pos.x * scale;
|
||||
|
@ -1397,6 +1429,7 @@ PIXI.InteractionManager.prototype.collectInteractiveSprite = function(displayObj
|
|||
{
|
||||
var child = children[i];
|
||||
|
||||
if(child.visible) {
|
||||
// push all interactive bits
|
||||
if(child.interactive)
|
||||
{
|
||||
|
@ -1420,6 +1453,7 @@ PIXI.InteractionManager.prototype.collectInteractiveSprite = function(displayObj
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PIXI.InteractionManager.prototype.setTarget = function(target)
|
||||
{
|
||||
|
@ -1525,8 +1559,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();
|
||||
|
||||
|
@ -1551,8 +1583,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??
|
||||
|
@ -1589,7 +1619,6 @@ PIXI.InteractionManager.prototype.onMouseDown = function(event)
|
|||
|
||||
PIXI.InteractionManager.prototype.onMouseUp = function(event)
|
||||
{
|
||||
event.preventDefault();
|
||||
var global = this.mouse.global;
|
||||
|
||||
|
||||
|
@ -1637,46 +1666,40 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
|
||||
if(!item.visible)return false;
|
||||
|
||||
if(item instanceof PIXI.Sprite)
|
||||
{
|
||||
var worldTransform = item.worldTransform;
|
||||
|
||||
var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2],
|
||||
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);
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
if(x > x1 && x < x1 + width)
|
||||
//a sprite or display object with a hit area defined
|
||||
if(item.hitArea)
|
||||
{
|
||||
var y1 = -height * item.anchor.y;
|
||||
var hitArea = item.hitArea;
|
||||
|
||||
if(y > y1 && y < y1 + height)
|
||||
{
|
||||
// set the target property if a hit is true!
|
||||
interactionData.target = item
|
||||
//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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
||||
//Rectangle hit area
|
||||
else {
|
||||
var x1 = hitArea.x;
|
||||
if(x > x1 && x < x1 + hitArea.width)
|
||||
{
|
||||
|
@ -1684,6 +1707,28 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
|
||||
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)
|
||||
{
|
||||
y1 = -height * item.anchor.y;
|
||||
|
||||
if(y > y1 && y < y1 + height)
|
||||
{
|
||||
// set the target property if a hit is true!
|
||||
interactionData.target = item
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1705,8 +1750,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;
|
||||
|
||||
|
@ -1730,7 +1773,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;
|
||||
|
@ -1772,9 +1814,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;
|
||||
|
||||
|
@ -1956,7 +1995,9 @@ PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor)
|
|||
{
|
||||
this.backgroundColor = backgroundColor || 0x000000;
|
||||
this.backgroundColorSplit = HEXtoRGB(this.backgroundColor);
|
||||
this.backgroundColorString = "#" + this.backgroundColor.toString(16);
|
||||
var hex = this.backgroundColor.toString(16);
|
||||
hex = "000000".substr(0, 6 - hex.length) + hex;
|
||||
this.backgroundColorString = "#" + hex;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2001,19 +2042,38 @@ PIXI.Stage.prototype.__removeChild = function(child)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides requestAnimationFrame in a cross browser way.
|
||||
*/
|
||||
window.requestAnimFrame = (function() {
|
||||
return window.requestAnimationFrame ||
|
||||
window.webkitRequestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame ||
|
||||
window.oRequestAnimationFrame ||
|
||||
window.msRequestAnimationFrame ||
|
||||
function(/* function FrameRequestCallback */ callback, /* DOMElement Element */ element) {
|
||||
window.setTimeout(callback, 1000/60);
|
||||
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
|
||||
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
|
||||
|
||||
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
|
||||
|
||||
// MIT license
|
||||
|
||||
|
||||
var lastTime = 0;
|
||||
var vendors = ['ms', 'moz', 'webkit', 'o'];
|
||||
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
||||
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
|
||||
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
|
||||
|| window[vendors[x]+'CancelRequestAnimationFrame'];
|
||||
}
|
||||
|
||||
if (!window.requestAnimationFrame)
|
||||
window.requestAnimationFrame = function(callback, element) {
|
||||
var currTime = new Date().getTime();
|
||||
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
||||
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
|
||||
timeToCall);
|
||||
lastTime = currTime + timeToCall;
|
||||
return id;
|
||||
};
|
||||
})();
|
||||
|
||||
if (!window.cancelAnimationFrame)
|
||||
window.cancelAnimationFrame = function(id) {
|
||||
clearTimeout(id);
|
||||
};
|
||||
|
||||
window.requestAnimFrame = window.requestAnimationFrame;
|
||||
|
||||
function HEXtoRGB(hex) {
|
||||
return [(hex >> 16 & 0xFF) / 255, ( hex >> 8 & 0xFF) / 255, (hex & 0xFF)/ 255];
|
||||
|
@ -2045,7 +2105,7 @@ if (typeof Function.prototype.bind != 'function') {
|
|||
})();
|
||||
}
|
||||
|
||||
var AjaxRequest = function()
|
||||
var AjaxRequest = PIXI.AjaxRequest = function()
|
||||
{
|
||||
var activexmodes = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE
|
||||
|
||||
|
@ -4488,10 +4548,13 @@ PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject)
|
|||
}
|
||||
|
||||
// render!
|
||||
if(displayObject.children)
|
||||
{
|
||||
for (var i=0; i < displayObject.children.length; i++)
|
||||
{
|
||||
this.renderDisplayObject(displayObject.children[i]);
|
||||
}
|
||||
}
|
||||
|
||||
this.context.setTransform(1,0,0,1,0,0);
|
||||
}
|
||||
|
@ -7439,7 +7502,7 @@ PIXI.BitmapFontLoader.prototype.onLoaded = function()
|
|||
* When loaded this class will dispatch a "loaded" event
|
||||
* @class Spine
|
||||
* @constructor
|
||||
* @extends
|
||||
* @extends EventTarget
|
||||
* @param {String} url the url of the sprite sheet JSON file
|
||||
* @param {Boolean} crossorigin
|
||||
*/
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* Copyright (c) 2012, Mat Groves
|
||||
* http://goodboydigital.com/
|
||||
*
|
||||
* Compiled: 2013-06-12
|
||||
* Compiled: 2013-06-19
|
||||
*
|
||||
* Pixi.JS is licensed under the MIT License.
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
|
@ -124,6 +124,37 @@ PIXI.Rectangle.prototype.clone = function()
|
|||
PIXI.Rectangle.constructor = PIXI.Rectangle;
|
||||
|
||||
|
||||
/**
|
||||
* @author Adrien Brault <adrien.brault@gmail.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class Polygon
|
||||
* @constructor
|
||||
* @param points {Array}
|
||||
*/
|
||||
PIXI.Polygon = function(points)
|
||||
{
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
/**
|
||||
* @method clone
|
||||
* @return a copy of the polygon
|
||||
*/
|
||||
PIXI.Polygon.clone = function()
|
||||
{
|
||||
var points = [];
|
||||
for (var i=0; i<this.points.length; i++) {
|
||||
points.push(this.points[i].clone());
|
||||
}
|
||||
|
||||
return new PIXI.Polygon(points);
|
||||
}
|
||||
|
||||
PIXI.Polygon.constructor = PIXI.Polygon;
|
||||
|
||||
|
||||
/**
|
||||
* @author Mat Groves http://matgroves.com/ @Doormat23
|
||||
*/
|
||||
|
@ -956,7 +987,7 @@ PIXI.Text.prototype = Object.create(PIXI.Sprite.prototype);
|
|||
* @param {String} [style.font="bold 20pt Arial"] The style and size of the font
|
||||
* @param {Object} [style.fill="black"] A canvas fillstyle that will be used on the text eg "red", "#00FF00"
|
||||
* @param {String} [style.align="left"] An alignment of the multiline text ("left", "center" or "right")
|
||||
* @param {String} [style.stroke] A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00"
|
||||
* @param {String} [style.stroke="black"] A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00"
|
||||
* @param {Number} [style.strokeThickness=0] A number that represents the thickness of the stroke. Default is 0 (no stroke)
|
||||
* @param {Boolean} [style.wordWrap=false] Indicates if word wrap should be used
|
||||
* @param {Number} [style.wordWrapWidth=100] The width at which text will wrap
|
||||
|
@ -967,6 +998,7 @@ PIXI.Text.prototype.setStyle = function(style)
|
|||
style.font = style.font || "bold 20pt Arial";
|
||||
style.fill = style.fill || "black";
|
||||
style.align = style.align || "left";
|
||||
style.stroke = style.stroke || "black"; //provide a default, see: https://github.com/GoodBoyDigital/pixi.js/issues/136
|
||||
style.strokeThickness = style.strokeThickness || 0;
|
||||
style.wordWrap = style.wordWrap || false;
|
||||
style.wordWrapWidth = style.wordWrapWidth || 100;
|
||||
|
@ -1102,7 +1134,7 @@ PIXI.Text.prototype.determineFontHeight = function(fontStyle)
|
|||
var dummy = document.createElement("div");
|
||||
var dummyText = document.createTextNode("M");
|
||||
dummy.appendChild(dummyText);
|
||||
dummy.setAttribute("style", fontStyle);
|
||||
dummy.setAttribute("style", fontStyle + ';position:absolute;top:0;left:0');
|
||||
body.appendChild(dummy);
|
||||
|
||||
result = dummy.offsetHeight;
|
||||
|
@ -1301,11 +1333,11 @@ PIXI.BitmapText.prototype.updateText = function()
|
|||
|
||||
for(i = 0; i < chars.length; i++)
|
||||
{
|
||||
var char = new PIXI.Sprite(chars[i].texture)//PIXI.Sprite.fromFrame(chars[i].charCode);
|
||||
char.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
|
||||
char.position.y = chars[i].position.y * scale;
|
||||
char.scale.x = char.scale.y = scale;
|
||||
this.addChild(char);
|
||||
var c = new PIXI.Sprite(chars[i].texture)//PIXI.Sprite.fromFrame(chars[i].charCode);
|
||||
c.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
|
||||
c.position.y = chars[i].position.y * scale;
|
||||
c.scale.x = c.scale.y = scale;
|
||||
this.addChild(c);
|
||||
}
|
||||
|
||||
this.width = pos.x * scale;
|
||||
|
@ -1397,6 +1429,7 @@ PIXI.InteractionManager.prototype.collectInteractiveSprite = function(displayObj
|
|||
{
|
||||
var child = children[i];
|
||||
|
||||
if(child.visible) {
|
||||
// push all interactive bits
|
||||
if(child.interactive)
|
||||
{
|
||||
|
@ -1420,6 +1453,7 @@ PIXI.InteractionManager.prototype.collectInteractiveSprite = function(displayObj
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PIXI.InteractionManager.prototype.setTarget = function(target)
|
||||
{
|
||||
|
@ -1525,8 +1559,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();
|
||||
|
||||
|
@ -1551,8 +1583,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??
|
||||
|
@ -1589,7 +1619,6 @@ PIXI.InteractionManager.prototype.onMouseDown = function(event)
|
|||
|
||||
PIXI.InteractionManager.prototype.onMouseUp = function(event)
|
||||
{
|
||||
event.preventDefault();
|
||||
var global = this.mouse.global;
|
||||
|
||||
|
||||
|
@ -1637,46 +1666,40 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
|
||||
if(!item.visible)return false;
|
||||
|
||||
if(item instanceof PIXI.Sprite)
|
||||
{
|
||||
var worldTransform = item.worldTransform;
|
||||
|
||||
var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2],
|
||||
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);
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
if(x > x1 && x < x1 + width)
|
||||
//a sprite or display object with a hit area defined
|
||||
if(item.hitArea)
|
||||
{
|
||||
var y1 = -height * item.anchor.y;
|
||||
var hitArea = item.hitArea;
|
||||
|
||||
if(y > y1 && y < y1 + height)
|
||||
{
|
||||
// set the target property if a hit is true!
|
||||
interactionData.target = item
|
||||
//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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
||||
//Rectangle hit area
|
||||
else {
|
||||
var x1 = hitArea.x;
|
||||
if(x > x1 && x < x1 + hitArea.width)
|
||||
{
|
||||
|
@ -1684,6 +1707,28 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
|
||||
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)
|
||||
{
|
||||
y1 = -height * item.anchor.y;
|
||||
|
||||
if(y > y1 && y < y1 + height)
|
||||
{
|
||||
// set the target property if a hit is true!
|
||||
interactionData.target = item
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1705,8 +1750,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;
|
||||
|
||||
|
@ -1730,7 +1773,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;
|
||||
|
@ -1772,9 +1814,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;
|
||||
|
||||
|
@ -1956,7 +1995,9 @@ PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor)
|
|||
{
|
||||
this.backgroundColor = backgroundColor || 0x000000;
|
||||
this.backgroundColorSplit = HEXtoRGB(this.backgroundColor);
|
||||
this.backgroundColorString = "#" + this.backgroundColor.toString(16);
|
||||
var hex = this.backgroundColor.toString(16);
|
||||
hex = "000000".substr(0, 6 - hex.length) + hex;
|
||||
this.backgroundColorString = "#" + hex;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2001,19 +2042,38 @@ PIXI.Stage.prototype.__removeChild = function(child)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides requestAnimationFrame in a cross browser way.
|
||||
*/
|
||||
window.requestAnimFrame = (function() {
|
||||
return window.requestAnimationFrame ||
|
||||
window.webkitRequestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame ||
|
||||
window.oRequestAnimationFrame ||
|
||||
window.msRequestAnimationFrame ||
|
||||
function(/* function FrameRequestCallback */ callback, /* DOMElement Element */ element) {
|
||||
window.setTimeout(callback, 1000/60);
|
||||
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
|
||||
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
|
||||
|
||||
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
|
||||
|
||||
// MIT license
|
||||
|
||||
|
||||
var lastTime = 0;
|
||||
var vendors = ['ms', 'moz', 'webkit', 'o'];
|
||||
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
||||
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
|
||||
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
|
||||
|| window[vendors[x]+'CancelRequestAnimationFrame'];
|
||||
}
|
||||
|
||||
if (!window.requestAnimationFrame)
|
||||
window.requestAnimationFrame = function(callback, element) {
|
||||
var currTime = new Date().getTime();
|
||||
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
||||
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
|
||||
timeToCall);
|
||||
lastTime = currTime + timeToCall;
|
||||
return id;
|
||||
};
|
||||
})();
|
||||
|
||||
if (!window.cancelAnimationFrame)
|
||||
window.cancelAnimationFrame = function(id) {
|
||||
clearTimeout(id);
|
||||
};
|
||||
|
||||
window.requestAnimFrame = window.requestAnimationFrame;
|
||||
|
||||
function HEXtoRGB(hex) {
|
||||
return [(hex >> 16 & 0xFF) / 255, ( hex >> 8 & 0xFF) / 255, (hex & 0xFF)/ 255];
|
||||
|
@ -2045,7 +2105,7 @@ if (typeof Function.prototype.bind != 'function') {
|
|||
})();
|
||||
}
|
||||
|
||||
var AjaxRequest = function()
|
||||
var AjaxRequest = PIXI.AjaxRequest = function()
|
||||
{
|
||||
var activexmodes = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE
|
||||
|
||||
|
@ -4488,10 +4548,13 @@ PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject)
|
|||
}
|
||||
|
||||
// render!
|
||||
if(displayObject.children)
|
||||
{
|
||||
for (var i=0; i < displayObject.children.length; i++)
|
||||
{
|
||||
this.renderDisplayObject(displayObject.children[i]);
|
||||
}
|
||||
}
|
||||
|
||||
this.context.setTransform(1,0,0,1,0,0);
|
||||
}
|
||||
|
@ -7439,7 +7502,7 @@ PIXI.BitmapFontLoader.prototype.onLoaded = function()
|
|||
* When loaded this class will dispatch a "loaded" event
|
||||
* @class Spine
|
||||
* @constructor
|
||||
* @extends
|
||||
* @extends EventTarget
|
||||
* @param {String} url the url of the sprite sheet JSON file
|
||||
* @param {Boolean} crossorigin
|
||||
*/
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* Copyright (c) 2012, Mat Groves
|
||||
* http://goodboydigital.com/
|
||||
*
|
||||
* Compiled: 2013-06-12
|
||||
* Compiled: 2013-06-19
|
||||
*
|
||||
* Pixi.JS is licensed under the MIT License.
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
|
@ -124,6 +124,37 @@ PIXI.Rectangle.prototype.clone = function()
|
|||
PIXI.Rectangle.constructor = PIXI.Rectangle;
|
||||
|
||||
|
||||
/**
|
||||
* @author Adrien Brault <adrien.brault@gmail.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class Polygon
|
||||
* @constructor
|
||||
* @param points {Array}
|
||||
*/
|
||||
PIXI.Polygon = function(points)
|
||||
{
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
/**
|
||||
* @method clone
|
||||
* @return a copy of the polygon
|
||||
*/
|
||||
PIXI.Polygon.clone = function()
|
||||
{
|
||||
var points = [];
|
||||
for (var i=0; i<this.points.length; i++) {
|
||||
points.push(this.points[i].clone());
|
||||
}
|
||||
|
||||
return new PIXI.Polygon(points);
|
||||
}
|
||||
|
||||
PIXI.Polygon.constructor = PIXI.Polygon;
|
||||
|
||||
|
||||
/**
|
||||
* @author Mat Groves http://matgroves.com/ @Doormat23
|
||||
*/
|
||||
|
@ -956,7 +987,7 @@ PIXI.Text.prototype = Object.create(PIXI.Sprite.prototype);
|
|||
* @param {String} [style.font="bold 20pt Arial"] The style and size of the font
|
||||
* @param {Object} [style.fill="black"] A canvas fillstyle that will be used on the text eg "red", "#00FF00"
|
||||
* @param {String} [style.align="left"] An alignment of the multiline text ("left", "center" or "right")
|
||||
* @param {String} [style.stroke] A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00"
|
||||
* @param {String} [style.stroke="black"] A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00"
|
||||
* @param {Number} [style.strokeThickness=0] A number that represents the thickness of the stroke. Default is 0 (no stroke)
|
||||
* @param {Boolean} [style.wordWrap=false] Indicates if word wrap should be used
|
||||
* @param {Number} [style.wordWrapWidth=100] The width at which text will wrap
|
||||
|
@ -967,6 +998,7 @@ PIXI.Text.prototype.setStyle = function(style)
|
|||
style.font = style.font || "bold 20pt Arial";
|
||||
style.fill = style.fill || "black";
|
||||
style.align = style.align || "left";
|
||||
style.stroke = style.stroke || "black"; //provide a default, see: https://github.com/GoodBoyDigital/pixi.js/issues/136
|
||||
style.strokeThickness = style.strokeThickness || 0;
|
||||
style.wordWrap = style.wordWrap || false;
|
||||
style.wordWrapWidth = style.wordWrapWidth || 100;
|
||||
|
@ -1102,7 +1134,7 @@ PIXI.Text.prototype.determineFontHeight = function(fontStyle)
|
|||
var dummy = document.createElement("div");
|
||||
var dummyText = document.createTextNode("M");
|
||||
dummy.appendChild(dummyText);
|
||||
dummy.setAttribute("style", fontStyle);
|
||||
dummy.setAttribute("style", fontStyle + ';position:absolute;top:0;left:0');
|
||||
body.appendChild(dummy);
|
||||
|
||||
result = dummy.offsetHeight;
|
||||
|
@ -1301,11 +1333,11 @@ PIXI.BitmapText.prototype.updateText = function()
|
|||
|
||||
for(i = 0; i < chars.length; i++)
|
||||
{
|
||||
var char = new PIXI.Sprite(chars[i].texture)//PIXI.Sprite.fromFrame(chars[i].charCode);
|
||||
char.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
|
||||
char.position.y = chars[i].position.y * scale;
|
||||
char.scale.x = char.scale.y = scale;
|
||||
this.addChild(char);
|
||||
var c = new PIXI.Sprite(chars[i].texture)//PIXI.Sprite.fromFrame(chars[i].charCode);
|
||||
c.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
|
||||
c.position.y = chars[i].position.y * scale;
|
||||
c.scale.x = c.scale.y = scale;
|
||||
this.addChild(c);
|
||||
}
|
||||
|
||||
this.width = pos.x * scale;
|
||||
|
@ -1397,6 +1429,7 @@ PIXI.InteractionManager.prototype.collectInteractiveSprite = function(displayObj
|
|||
{
|
||||
var child = children[i];
|
||||
|
||||
if(child.visible) {
|
||||
// push all interactive bits
|
||||
if(child.interactive)
|
||||
{
|
||||
|
@ -1420,6 +1453,7 @@ PIXI.InteractionManager.prototype.collectInteractiveSprite = function(displayObj
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PIXI.InteractionManager.prototype.setTarget = function(target)
|
||||
{
|
||||
|
@ -1525,8 +1559,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();
|
||||
|
||||
|
@ -1551,8 +1583,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??
|
||||
|
@ -1589,7 +1619,6 @@ PIXI.InteractionManager.prototype.onMouseDown = function(event)
|
|||
|
||||
PIXI.InteractionManager.prototype.onMouseUp = function(event)
|
||||
{
|
||||
event.preventDefault();
|
||||
var global = this.mouse.global;
|
||||
|
||||
|
||||
|
@ -1637,46 +1666,40 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
|
||||
if(!item.visible)return false;
|
||||
|
||||
if(item instanceof PIXI.Sprite)
|
||||
{
|
||||
var worldTransform = item.worldTransform;
|
||||
|
||||
var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2],
|
||||
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);
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
if(x > x1 && x < x1 + width)
|
||||
//a sprite or display object with a hit area defined
|
||||
if(item.hitArea)
|
||||
{
|
||||
var y1 = -height * item.anchor.y;
|
||||
var hitArea = item.hitArea;
|
||||
|
||||
if(y > y1 && y < y1 + height)
|
||||
{
|
||||
// set the target property if a hit is true!
|
||||
interactionData.target = item
|
||||
//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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
||||
//Rectangle hit area
|
||||
else {
|
||||
var x1 = hitArea.x;
|
||||
if(x > x1 && x < x1 + hitArea.width)
|
||||
{
|
||||
|
@ -1684,6 +1707,28 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
|
||||
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)
|
||||
{
|
||||
y1 = -height * item.anchor.y;
|
||||
|
||||
if(y > y1 && y < y1 + height)
|
||||
{
|
||||
// set the target property if a hit is true!
|
||||
interactionData.target = item
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1705,8 +1750,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;
|
||||
|
||||
|
@ -1730,7 +1773,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;
|
||||
|
@ -1772,9 +1814,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;
|
||||
|
||||
|
@ -1956,7 +1995,9 @@ PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor)
|
|||
{
|
||||
this.backgroundColor = backgroundColor || 0x000000;
|
||||
this.backgroundColorSplit = HEXtoRGB(this.backgroundColor);
|
||||
this.backgroundColorString = "#" + this.backgroundColor.toString(16);
|
||||
var hex = this.backgroundColor.toString(16);
|
||||
hex = "000000".substr(0, 6 - hex.length) + hex;
|
||||
this.backgroundColorString = "#" + hex;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2001,19 +2042,38 @@ PIXI.Stage.prototype.__removeChild = function(child)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides requestAnimationFrame in a cross browser way.
|
||||
*/
|
||||
window.requestAnimFrame = (function() {
|
||||
return window.requestAnimationFrame ||
|
||||
window.webkitRequestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame ||
|
||||
window.oRequestAnimationFrame ||
|
||||
window.msRequestAnimationFrame ||
|
||||
function(/* function FrameRequestCallback */ callback, /* DOMElement Element */ element) {
|
||||
window.setTimeout(callback, 1000/60);
|
||||
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
|
||||
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
|
||||
|
||||
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
|
||||
|
||||
// MIT license
|
||||
|
||||
|
||||
var lastTime = 0;
|
||||
var vendors = ['ms', 'moz', 'webkit', 'o'];
|
||||
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
||||
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
|
||||
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
|
||||
|| window[vendors[x]+'CancelRequestAnimationFrame'];
|
||||
}
|
||||
|
||||
if (!window.requestAnimationFrame)
|
||||
window.requestAnimationFrame = function(callback, element) {
|
||||
var currTime = new Date().getTime();
|
||||
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
||||
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
|
||||
timeToCall);
|
||||
lastTime = currTime + timeToCall;
|
||||
return id;
|
||||
};
|
||||
})();
|
||||
|
||||
if (!window.cancelAnimationFrame)
|
||||
window.cancelAnimationFrame = function(id) {
|
||||
clearTimeout(id);
|
||||
};
|
||||
|
||||
window.requestAnimFrame = window.requestAnimationFrame;
|
||||
|
||||
function HEXtoRGB(hex) {
|
||||
return [(hex >> 16 & 0xFF) / 255, ( hex >> 8 & 0xFF) / 255, (hex & 0xFF)/ 255];
|
||||
|
@ -2045,7 +2105,7 @@ if (typeof Function.prototype.bind != 'function') {
|
|||
})();
|
||||
}
|
||||
|
||||
var AjaxRequest = function()
|
||||
var AjaxRequest = PIXI.AjaxRequest = function()
|
||||
{
|
||||
var activexmodes = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE
|
||||
|
||||
|
@ -4488,10 +4548,13 @@ PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject)
|
|||
}
|
||||
|
||||
// render!
|
||||
if(displayObject.children)
|
||||
{
|
||||
for (var i=0; i < displayObject.children.length; i++)
|
||||
{
|
||||
this.renderDisplayObject(displayObject.children[i]);
|
||||
}
|
||||
}
|
||||
|
||||
this.context.setTransform(1,0,0,1,0,0);
|
||||
}
|
||||
|
@ -7439,7 +7502,7 @@ PIXI.BitmapFontLoader.prototype.onLoaded = function()
|
|||
* When loaded this class will dispatch a "loaded" event
|
||||
* @class Spine
|
||||
* @constructor
|
||||
* @extends
|
||||
* @extends EventTarget
|
||||
* @param {String} url the url of the sprite sheet JSON file
|
||||
* @param {Boolean} crossorigin
|
||||
*/
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* Copyright (c) 2012, Mat Groves
|
||||
* http://goodboydigital.com/
|
||||
*
|
||||
* Compiled: 2013-06-12
|
||||
* Compiled: 2013-06-19
|
||||
*
|
||||
* Pixi.JS is licensed under the MIT License.
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
|
@ -124,6 +124,37 @@ PIXI.Rectangle.prototype.clone = function()
|
|||
PIXI.Rectangle.constructor = PIXI.Rectangle;
|
||||
|
||||
|
||||
/**
|
||||
* @author Adrien Brault <adrien.brault@gmail.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class Polygon
|
||||
* @constructor
|
||||
* @param points {Array}
|
||||
*/
|
||||
PIXI.Polygon = function(points)
|
||||
{
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
/**
|
||||
* @method clone
|
||||
* @return a copy of the polygon
|
||||
*/
|
||||
PIXI.Polygon.clone = function()
|
||||
{
|
||||
var points = [];
|
||||
for (var i=0; i<this.points.length; i++) {
|
||||
points.push(this.points[i].clone());
|
||||
}
|
||||
|
||||
return new PIXI.Polygon(points);
|
||||
}
|
||||
|
||||
PIXI.Polygon.constructor = PIXI.Polygon;
|
||||
|
||||
|
||||
/**
|
||||
* @author Mat Groves http://matgroves.com/ @Doormat23
|
||||
*/
|
||||
|
@ -956,7 +987,7 @@ PIXI.Text.prototype = Object.create(PIXI.Sprite.prototype);
|
|||
* @param {String} [style.font="bold 20pt Arial"] The style and size of the font
|
||||
* @param {Object} [style.fill="black"] A canvas fillstyle that will be used on the text eg "red", "#00FF00"
|
||||
* @param {String} [style.align="left"] An alignment of the multiline text ("left", "center" or "right")
|
||||
* @param {String} [style.stroke] A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00"
|
||||
* @param {String} [style.stroke="black"] A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00"
|
||||
* @param {Number} [style.strokeThickness=0] A number that represents the thickness of the stroke. Default is 0 (no stroke)
|
||||
* @param {Boolean} [style.wordWrap=false] Indicates if word wrap should be used
|
||||
* @param {Number} [style.wordWrapWidth=100] The width at which text will wrap
|
||||
|
@ -967,6 +998,7 @@ PIXI.Text.prototype.setStyle = function(style)
|
|||
style.font = style.font || "bold 20pt Arial";
|
||||
style.fill = style.fill || "black";
|
||||
style.align = style.align || "left";
|
||||
style.stroke = style.stroke || "black"; //provide a default, see: https://github.com/GoodBoyDigital/pixi.js/issues/136
|
||||
style.strokeThickness = style.strokeThickness || 0;
|
||||
style.wordWrap = style.wordWrap || false;
|
||||
style.wordWrapWidth = style.wordWrapWidth || 100;
|
||||
|
@ -1102,7 +1134,7 @@ PIXI.Text.prototype.determineFontHeight = function(fontStyle)
|
|||
var dummy = document.createElement("div");
|
||||
var dummyText = document.createTextNode("M");
|
||||
dummy.appendChild(dummyText);
|
||||
dummy.setAttribute("style", fontStyle);
|
||||
dummy.setAttribute("style", fontStyle + ';position:absolute;top:0;left:0');
|
||||
body.appendChild(dummy);
|
||||
|
||||
result = dummy.offsetHeight;
|
||||
|
@ -1301,11 +1333,11 @@ PIXI.BitmapText.prototype.updateText = function()
|
|||
|
||||
for(i = 0; i < chars.length; i++)
|
||||
{
|
||||
var char = new PIXI.Sprite(chars[i].texture)//PIXI.Sprite.fromFrame(chars[i].charCode);
|
||||
char.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
|
||||
char.position.y = chars[i].position.y * scale;
|
||||
char.scale.x = char.scale.y = scale;
|
||||
this.addChild(char);
|
||||
var c = new PIXI.Sprite(chars[i].texture)//PIXI.Sprite.fromFrame(chars[i].charCode);
|
||||
c.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
|
||||
c.position.y = chars[i].position.y * scale;
|
||||
c.scale.x = c.scale.y = scale;
|
||||
this.addChild(c);
|
||||
}
|
||||
|
||||
this.width = pos.x * scale;
|
||||
|
@ -1397,6 +1429,7 @@ PIXI.InteractionManager.prototype.collectInteractiveSprite = function(displayObj
|
|||
{
|
||||
var child = children[i];
|
||||
|
||||
if(child.visible) {
|
||||
// push all interactive bits
|
||||
if(child.interactive)
|
||||
{
|
||||
|
@ -1420,6 +1453,7 @@ PIXI.InteractionManager.prototype.collectInteractiveSprite = function(displayObj
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PIXI.InteractionManager.prototype.setTarget = function(target)
|
||||
{
|
||||
|
@ -1525,8 +1559,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();
|
||||
|
||||
|
@ -1551,8 +1583,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??
|
||||
|
@ -1589,7 +1619,6 @@ PIXI.InteractionManager.prototype.onMouseDown = function(event)
|
|||
|
||||
PIXI.InteractionManager.prototype.onMouseUp = function(event)
|
||||
{
|
||||
event.preventDefault();
|
||||
var global = this.mouse.global;
|
||||
|
||||
|
||||
|
@ -1637,46 +1666,40 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
|
||||
if(!item.visible)return false;
|
||||
|
||||
if(item instanceof PIXI.Sprite)
|
||||
{
|
||||
var worldTransform = item.worldTransform;
|
||||
|
||||
var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2],
|
||||
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);
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
if(x > x1 && x < x1 + width)
|
||||
//a sprite or display object with a hit area defined
|
||||
if(item.hitArea)
|
||||
{
|
||||
var y1 = -height * item.anchor.y;
|
||||
var hitArea = item.hitArea;
|
||||
|
||||
if(y > y1 && y < y1 + height)
|
||||
{
|
||||
// set the target property if a hit is true!
|
||||
interactionData.target = item
|
||||
//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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
||||
//Rectangle hit area
|
||||
else {
|
||||
var x1 = hitArea.x;
|
||||
if(x > x1 && x < x1 + hitArea.width)
|
||||
{
|
||||
|
@ -1684,6 +1707,28 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
|
||||
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)
|
||||
{
|
||||
y1 = -height * item.anchor.y;
|
||||
|
||||
if(y > y1 && y < y1 + height)
|
||||
{
|
||||
// set the target property if a hit is true!
|
||||
interactionData.target = item
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1705,8 +1750,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;
|
||||
|
||||
|
@ -1730,7 +1773,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;
|
||||
|
@ -1772,9 +1814,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;
|
||||
|
||||
|
@ -1956,7 +1995,9 @@ PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor)
|
|||
{
|
||||
this.backgroundColor = backgroundColor || 0x000000;
|
||||
this.backgroundColorSplit = HEXtoRGB(this.backgroundColor);
|
||||
this.backgroundColorString = "#" + this.backgroundColor.toString(16);
|
||||
var hex = this.backgroundColor.toString(16);
|
||||
hex = "000000".substr(0, 6 - hex.length) + hex;
|
||||
this.backgroundColorString = "#" + hex;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2001,19 +2042,38 @@ PIXI.Stage.prototype.__removeChild = function(child)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides requestAnimationFrame in a cross browser way.
|
||||
*/
|
||||
window.requestAnimFrame = (function() {
|
||||
return window.requestAnimationFrame ||
|
||||
window.webkitRequestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame ||
|
||||
window.oRequestAnimationFrame ||
|
||||
window.msRequestAnimationFrame ||
|
||||
function(/* function FrameRequestCallback */ callback, /* DOMElement Element */ element) {
|
||||
window.setTimeout(callback, 1000/60);
|
||||
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
|
||||
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
|
||||
|
||||
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
|
||||
|
||||
// MIT license
|
||||
|
||||
|
||||
var lastTime = 0;
|
||||
var vendors = ['ms', 'moz', 'webkit', 'o'];
|
||||
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
||||
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
|
||||
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
|
||||
|| window[vendors[x]+'CancelRequestAnimationFrame'];
|
||||
}
|
||||
|
||||
if (!window.requestAnimationFrame)
|
||||
window.requestAnimationFrame = function(callback, element) {
|
||||
var currTime = new Date().getTime();
|
||||
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
||||
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
|
||||
timeToCall);
|
||||
lastTime = currTime + timeToCall;
|
||||
return id;
|
||||
};
|
||||
})();
|
||||
|
||||
if (!window.cancelAnimationFrame)
|
||||
window.cancelAnimationFrame = function(id) {
|
||||
clearTimeout(id);
|
||||
};
|
||||
|
||||
window.requestAnimFrame = window.requestAnimationFrame;
|
||||
|
||||
function HEXtoRGB(hex) {
|
||||
return [(hex >> 16 & 0xFF) / 255, ( hex >> 8 & 0xFF) / 255, (hex & 0xFF)/ 255];
|
||||
|
@ -2045,7 +2105,7 @@ if (typeof Function.prototype.bind != 'function') {
|
|||
})();
|
||||
}
|
||||
|
||||
var AjaxRequest = function()
|
||||
var AjaxRequest = PIXI.AjaxRequest = function()
|
||||
{
|
||||
var activexmodes = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE
|
||||
|
||||
|
@ -4488,10 +4548,13 @@ PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject)
|
|||
}
|
||||
|
||||
// render!
|
||||
if(displayObject.children)
|
||||
{
|
||||
for (var i=0; i < displayObject.children.length; i++)
|
||||
{
|
||||
this.renderDisplayObject(displayObject.children[i]);
|
||||
}
|
||||
}
|
||||
|
||||
this.context.setTransform(1,0,0,1,0,0);
|
||||
}
|
||||
|
@ -7439,7 +7502,7 @@ PIXI.BitmapFontLoader.prototype.onLoaded = function()
|
|||
* When loaded this class will dispatch a "loaded" event
|
||||
* @class Spine
|
||||
* @constructor
|
||||
* @extends
|
||||
* @extends EventTarget
|
||||
* @param {String} url the url of the sprite sheet JSON file
|
||||
* @param {Boolean} crossorigin
|
||||
*/
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* Copyright (c) 2012, Mat Groves
|
||||
* http://goodboydigital.com/
|
||||
*
|
||||
* Compiled: 2013-06-12
|
||||
* Compiled: 2013-06-19
|
||||
*
|
||||
* Pixi.JS is licensed under the MIT License.
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
|
@ -124,6 +124,37 @@ PIXI.Rectangle.prototype.clone = function()
|
|||
PIXI.Rectangle.constructor = PIXI.Rectangle;
|
||||
|
||||
|
||||
/**
|
||||
* @author Adrien Brault <adrien.brault@gmail.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class Polygon
|
||||
* @constructor
|
||||
* @param points {Array}
|
||||
*/
|
||||
PIXI.Polygon = function(points)
|
||||
{
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
/**
|
||||
* @method clone
|
||||
* @return a copy of the polygon
|
||||
*/
|
||||
PIXI.Polygon.clone = function()
|
||||
{
|
||||
var points = [];
|
||||
for (var i=0; i<this.points.length; i++) {
|
||||
points.push(this.points[i].clone());
|
||||
}
|
||||
|
||||
return new PIXI.Polygon(points);
|
||||
}
|
||||
|
||||
PIXI.Polygon.constructor = PIXI.Polygon;
|
||||
|
||||
|
||||
/**
|
||||
* @author Mat Groves http://matgroves.com/ @Doormat23
|
||||
*/
|
||||
|
@ -956,7 +987,7 @@ PIXI.Text.prototype = Object.create(PIXI.Sprite.prototype);
|
|||
* @param {String} [style.font="bold 20pt Arial"] The style and size of the font
|
||||
* @param {Object} [style.fill="black"] A canvas fillstyle that will be used on the text eg "red", "#00FF00"
|
||||
* @param {String} [style.align="left"] An alignment of the multiline text ("left", "center" or "right")
|
||||
* @param {String} [style.stroke] A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00"
|
||||
* @param {String} [style.stroke="black"] A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00"
|
||||
* @param {Number} [style.strokeThickness=0] A number that represents the thickness of the stroke. Default is 0 (no stroke)
|
||||
* @param {Boolean} [style.wordWrap=false] Indicates if word wrap should be used
|
||||
* @param {Number} [style.wordWrapWidth=100] The width at which text will wrap
|
||||
|
@ -967,6 +998,7 @@ PIXI.Text.prototype.setStyle = function(style)
|
|||
style.font = style.font || "bold 20pt Arial";
|
||||
style.fill = style.fill || "black";
|
||||
style.align = style.align || "left";
|
||||
style.stroke = style.stroke || "black"; //provide a default, see: https://github.com/GoodBoyDigital/pixi.js/issues/136
|
||||
style.strokeThickness = style.strokeThickness || 0;
|
||||
style.wordWrap = style.wordWrap || false;
|
||||
style.wordWrapWidth = style.wordWrapWidth || 100;
|
||||
|
@ -1102,7 +1134,7 @@ PIXI.Text.prototype.determineFontHeight = function(fontStyle)
|
|||
var dummy = document.createElement("div");
|
||||
var dummyText = document.createTextNode("M");
|
||||
dummy.appendChild(dummyText);
|
||||
dummy.setAttribute("style", fontStyle);
|
||||
dummy.setAttribute("style", fontStyle + ';position:absolute;top:0;left:0');
|
||||
body.appendChild(dummy);
|
||||
|
||||
result = dummy.offsetHeight;
|
||||
|
@ -1301,11 +1333,11 @@ PIXI.BitmapText.prototype.updateText = function()
|
|||
|
||||
for(i = 0; i < chars.length; i++)
|
||||
{
|
||||
var char = new PIXI.Sprite(chars[i].texture)//PIXI.Sprite.fromFrame(chars[i].charCode);
|
||||
char.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
|
||||
char.position.y = chars[i].position.y * scale;
|
||||
char.scale.x = char.scale.y = scale;
|
||||
this.addChild(char);
|
||||
var c = new PIXI.Sprite(chars[i].texture)//PIXI.Sprite.fromFrame(chars[i].charCode);
|
||||
c.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
|
||||
c.position.y = chars[i].position.y * scale;
|
||||
c.scale.x = c.scale.y = scale;
|
||||
this.addChild(c);
|
||||
}
|
||||
|
||||
this.width = pos.x * scale;
|
||||
|
@ -1397,6 +1429,7 @@ PIXI.InteractionManager.prototype.collectInteractiveSprite = function(displayObj
|
|||
{
|
||||
var child = children[i];
|
||||
|
||||
if(child.visible) {
|
||||
// push all interactive bits
|
||||
if(child.interactive)
|
||||
{
|
||||
|
@ -1420,6 +1453,7 @@ PIXI.InteractionManager.prototype.collectInteractiveSprite = function(displayObj
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PIXI.InteractionManager.prototype.setTarget = function(target)
|
||||
{
|
||||
|
@ -1525,8 +1559,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();
|
||||
|
||||
|
@ -1551,8 +1583,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??
|
||||
|
@ -1589,7 +1619,6 @@ PIXI.InteractionManager.prototype.onMouseDown = function(event)
|
|||
|
||||
PIXI.InteractionManager.prototype.onMouseUp = function(event)
|
||||
{
|
||||
event.preventDefault();
|
||||
var global = this.mouse.global;
|
||||
|
||||
|
||||
|
@ -1637,46 +1666,40 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
|
||||
if(!item.visible)return false;
|
||||
|
||||
if(item instanceof PIXI.Sprite)
|
||||
{
|
||||
var worldTransform = item.worldTransform;
|
||||
|
||||
var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2],
|
||||
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);
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
if(x > x1 && x < x1 + width)
|
||||
//a sprite or display object with a hit area defined
|
||||
if(item.hitArea)
|
||||
{
|
||||
var y1 = -height * item.anchor.y;
|
||||
var hitArea = item.hitArea;
|
||||
|
||||
if(y > y1 && y < y1 + height)
|
||||
{
|
||||
// set the target property if a hit is true!
|
||||
interactionData.target = item
|
||||
//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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
||||
//Rectangle hit area
|
||||
else {
|
||||
var x1 = hitArea.x;
|
||||
if(x > x1 && x < x1 + hitArea.width)
|
||||
{
|
||||
|
@ -1684,6 +1707,28 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
|
||||
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)
|
||||
{
|
||||
y1 = -height * item.anchor.y;
|
||||
|
||||
if(y > y1 && y < y1 + height)
|
||||
{
|
||||
// set the target property if a hit is true!
|
||||
interactionData.target = item
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1705,8 +1750,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;
|
||||
|
||||
|
@ -1730,7 +1773,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;
|
||||
|
@ -1772,9 +1814,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;
|
||||
|
||||
|
@ -1956,7 +1995,9 @@ PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor)
|
|||
{
|
||||
this.backgroundColor = backgroundColor || 0x000000;
|
||||
this.backgroundColorSplit = HEXtoRGB(this.backgroundColor);
|
||||
this.backgroundColorString = "#" + this.backgroundColor.toString(16);
|
||||
var hex = this.backgroundColor.toString(16);
|
||||
hex = "000000".substr(0, 6 - hex.length) + hex;
|
||||
this.backgroundColorString = "#" + hex;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2001,19 +2042,38 @@ PIXI.Stage.prototype.__removeChild = function(child)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides requestAnimationFrame in a cross browser way.
|
||||
*/
|
||||
window.requestAnimFrame = (function() {
|
||||
return window.requestAnimationFrame ||
|
||||
window.webkitRequestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame ||
|
||||
window.oRequestAnimationFrame ||
|
||||
window.msRequestAnimationFrame ||
|
||||
function(/* function FrameRequestCallback */ callback, /* DOMElement Element */ element) {
|
||||
window.setTimeout(callback, 1000/60);
|
||||
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
|
||||
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
|
||||
|
||||
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
|
||||
|
||||
// MIT license
|
||||
|
||||
|
||||
var lastTime = 0;
|
||||
var vendors = ['ms', 'moz', 'webkit', 'o'];
|
||||
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
||||
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
|
||||
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
|
||||
|| window[vendors[x]+'CancelRequestAnimationFrame'];
|
||||
}
|
||||
|
||||
if (!window.requestAnimationFrame)
|
||||
window.requestAnimationFrame = function(callback, element) {
|
||||
var currTime = new Date().getTime();
|
||||
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
||||
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
|
||||
timeToCall);
|
||||
lastTime = currTime + timeToCall;
|
||||
return id;
|
||||
};
|
||||
})();
|
||||
|
||||
if (!window.cancelAnimationFrame)
|
||||
window.cancelAnimationFrame = function(id) {
|
||||
clearTimeout(id);
|
||||
};
|
||||
|
||||
window.requestAnimFrame = window.requestAnimationFrame;
|
||||
|
||||
function HEXtoRGB(hex) {
|
||||
return [(hex >> 16 & 0xFF) / 255, ( hex >> 8 & 0xFF) / 255, (hex & 0xFF)/ 255];
|
||||
|
@ -2045,7 +2105,7 @@ if (typeof Function.prototype.bind != 'function') {
|
|||
})();
|
||||
}
|
||||
|
||||
var AjaxRequest = function()
|
||||
var AjaxRequest = PIXI.AjaxRequest = function()
|
||||
{
|
||||
var activexmodes = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE
|
||||
|
||||
|
@ -4488,10 +4548,13 @@ PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject)
|
|||
}
|
||||
|
||||
// render!
|
||||
if(displayObject.children)
|
||||
{
|
||||
for (var i=0; i < displayObject.children.length; i++)
|
||||
{
|
||||
this.renderDisplayObject(displayObject.children[i]);
|
||||
}
|
||||
}
|
||||
|
||||
this.context.setTransform(1,0,0,1,0,0);
|
||||
}
|
||||
|
@ -7439,7 +7502,7 @@ PIXI.BitmapFontLoader.prototype.onLoaded = function()
|
|||
* When loaded this class will dispatch a "loaded" event
|
||||
* @class Spine
|
||||
* @constructor
|
||||
* @extends
|
||||
* @extends EventTarget
|
||||
* @param {String} url the url of the sprite sheet JSON file
|
||||
* @param {Boolean} crossorigin
|
||||
*/
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* Copyright (c) 2012, Mat Groves
|
||||
* http://goodboydigital.com/
|
||||
*
|
||||
* Compiled: 2013-06-12
|
||||
* Compiled: 2013-06-19
|
||||
*
|
||||
* Pixi.JS is licensed under the MIT License.
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
|
@ -124,6 +124,37 @@ PIXI.Rectangle.prototype.clone = function()
|
|||
PIXI.Rectangle.constructor = PIXI.Rectangle;
|
||||
|
||||
|
||||
/**
|
||||
* @author Adrien Brault <adrien.brault@gmail.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
* @class Polygon
|
||||
* @constructor
|
||||
* @param points {Array}
|
||||
*/
|
||||
PIXI.Polygon = function(points)
|
||||
{
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
/**
|
||||
* @method clone
|
||||
* @return a copy of the polygon
|
||||
*/
|
||||
PIXI.Polygon.clone = function()
|
||||
{
|
||||
var points = [];
|
||||
for (var i=0; i<this.points.length; i++) {
|
||||
points.push(this.points[i].clone());
|
||||
}
|
||||
|
||||
return new PIXI.Polygon(points);
|
||||
}
|
||||
|
||||
PIXI.Polygon.constructor = PIXI.Polygon;
|
||||
|
||||
|
||||
/**
|
||||
* @author Mat Groves http://matgroves.com/ @Doormat23
|
||||
*/
|
||||
|
@ -956,7 +987,7 @@ PIXI.Text.prototype = Object.create(PIXI.Sprite.prototype);
|
|||
* @param {String} [style.font="bold 20pt Arial"] The style and size of the font
|
||||
* @param {Object} [style.fill="black"] A canvas fillstyle that will be used on the text eg "red", "#00FF00"
|
||||
* @param {String} [style.align="left"] An alignment of the multiline text ("left", "center" or "right")
|
||||
* @param {String} [style.stroke] A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00"
|
||||
* @param {String} [style.stroke="black"] A canvas fillstyle that will be used on the text stroke eg "blue", "#FCFF00"
|
||||
* @param {Number} [style.strokeThickness=0] A number that represents the thickness of the stroke. Default is 0 (no stroke)
|
||||
* @param {Boolean} [style.wordWrap=false] Indicates if word wrap should be used
|
||||
* @param {Number} [style.wordWrapWidth=100] The width at which text will wrap
|
||||
|
@ -967,6 +998,7 @@ PIXI.Text.prototype.setStyle = function(style)
|
|||
style.font = style.font || "bold 20pt Arial";
|
||||
style.fill = style.fill || "black";
|
||||
style.align = style.align || "left";
|
||||
style.stroke = style.stroke || "black"; //provide a default, see: https://github.com/GoodBoyDigital/pixi.js/issues/136
|
||||
style.strokeThickness = style.strokeThickness || 0;
|
||||
style.wordWrap = style.wordWrap || false;
|
||||
style.wordWrapWidth = style.wordWrapWidth || 100;
|
||||
|
@ -1102,7 +1134,7 @@ PIXI.Text.prototype.determineFontHeight = function(fontStyle)
|
|||
var dummy = document.createElement("div");
|
||||
var dummyText = document.createTextNode("M");
|
||||
dummy.appendChild(dummyText);
|
||||
dummy.setAttribute("style", fontStyle);
|
||||
dummy.setAttribute("style", fontStyle + ';position:absolute;top:0;left:0');
|
||||
body.appendChild(dummy);
|
||||
|
||||
result = dummy.offsetHeight;
|
||||
|
@ -1301,11 +1333,11 @@ PIXI.BitmapText.prototype.updateText = function()
|
|||
|
||||
for(i = 0; i < chars.length; i++)
|
||||
{
|
||||
var char = new PIXI.Sprite(chars[i].texture)//PIXI.Sprite.fromFrame(chars[i].charCode);
|
||||
char.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
|
||||
char.position.y = chars[i].position.y * scale;
|
||||
char.scale.x = char.scale.y = scale;
|
||||
this.addChild(char);
|
||||
var c = new PIXI.Sprite(chars[i].texture)//PIXI.Sprite.fromFrame(chars[i].charCode);
|
||||
c.position.x = (chars[i].position.x + lineAlignOffsets[chars[i].line]) * scale;
|
||||
c.position.y = chars[i].position.y * scale;
|
||||
c.scale.x = c.scale.y = scale;
|
||||
this.addChild(c);
|
||||
}
|
||||
|
||||
this.width = pos.x * scale;
|
||||
|
@ -1397,6 +1429,7 @@ PIXI.InteractionManager.prototype.collectInteractiveSprite = function(displayObj
|
|||
{
|
||||
var child = children[i];
|
||||
|
||||
if(child.visible) {
|
||||
// push all interactive bits
|
||||
if(child.interactive)
|
||||
{
|
||||
|
@ -1420,6 +1453,7 @@ PIXI.InteractionManager.prototype.collectInteractiveSprite = function(displayObj
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PIXI.InteractionManager.prototype.setTarget = function(target)
|
||||
{
|
||||
|
@ -1525,8 +1559,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();
|
||||
|
||||
|
@ -1551,8 +1583,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??
|
||||
|
@ -1589,7 +1619,6 @@ PIXI.InteractionManager.prototype.onMouseDown = function(event)
|
|||
|
||||
PIXI.InteractionManager.prototype.onMouseUp = function(event)
|
||||
{
|
||||
event.preventDefault();
|
||||
var global = this.mouse.global;
|
||||
|
||||
|
||||
|
@ -1637,46 +1666,40 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
|
||||
if(!item.visible)return false;
|
||||
|
||||
if(item instanceof PIXI.Sprite)
|
||||
{
|
||||
var worldTransform = item.worldTransform;
|
||||
|
||||
var a00 = worldTransform[0], a01 = worldTransform[1], a02 = worldTransform[2],
|
||||
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);
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
if(x > x1 && x < x1 + width)
|
||||
//a sprite or display object with a hit area defined
|
||||
if(item.hitArea)
|
||||
{
|
||||
var y1 = -height * item.anchor.y;
|
||||
var hitArea = item.hitArea;
|
||||
|
||||
if(y > y1 && y < y1 + height)
|
||||
{
|
||||
// set the target property if a hit is true!
|
||||
interactionData.target = item
|
||||
//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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
||||
//Rectangle hit area
|
||||
else {
|
||||
var x1 = hitArea.x;
|
||||
if(x > x1 && x < x1 + hitArea.width)
|
||||
{
|
||||
|
@ -1684,6 +1707,28 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
|
||||
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)
|
||||
{
|
||||
y1 = -height * item.anchor.y;
|
||||
|
||||
if(y > y1 && y < y1 + height)
|
||||
{
|
||||
// set the target property if a hit is true!
|
||||
interactionData.target = item
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1705,8 +1750,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;
|
||||
|
||||
|
@ -1730,7 +1773,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;
|
||||
|
@ -1772,9 +1814,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;
|
||||
|
||||
|
@ -1956,7 +1995,9 @@ PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor)
|
|||
{
|
||||
this.backgroundColor = backgroundColor || 0x000000;
|
||||
this.backgroundColorSplit = HEXtoRGB(this.backgroundColor);
|
||||
this.backgroundColorString = "#" + this.backgroundColor.toString(16);
|
||||
var hex = this.backgroundColor.toString(16);
|
||||
hex = "000000".substr(0, 6 - hex.length) + hex;
|
||||
this.backgroundColorString = "#" + hex;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2001,19 +2042,38 @@ PIXI.Stage.prototype.__removeChild = function(child)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides requestAnimationFrame in a cross browser way.
|
||||
*/
|
||||
window.requestAnimFrame = (function() {
|
||||
return window.requestAnimationFrame ||
|
||||
window.webkitRequestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame ||
|
||||
window.oRequestAnimationFrame ||
|
||||
window.msRequestAnimationFrame ||
|
||||
function(/* function FrameRequestCallback */ callback, /* DOMElement Element */ element) {
|
||||
window.setTimeout(callback, 1000/60);
|
||||
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
|
||||
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
|
||||
|
||||
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
|
||||
|
||||
// MIT license
|
||||
|
||||
|
||||
var lastTime = 0;
|
||||
var vendors = ['ms', 'moz', 'webkit', 'o'];
|
||||
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
||||
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
|
||||
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
|
||||
|| window[vendors[x]+'CancelRequestAnimationFrame'];
|
||||
}
|
||||
|
||||
if (!window.requestAnimationFrame)
|
||||
window.requestAnimationFrame = function(callback, element) {
|
||||
var currTime = new Date().getTime();
|
||||
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
||||
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
|
||||
timeToCall);
|
||||
lastTime = currTime + timeToCall;
|
||||
return id;
|
||||
};
|
||||
})();
|
||||
|
||||
if (!window.cancelAnimationFrame)
|
||||
window.cancelAnimationFrame = function(id) {
|
||||
clearTimeout(id);
|
||||
};
|
||||
|
||||
window.requestAnimFrame = window.requestAnimationFrame;
|
||||
|
||||
function HEXtoRGB(hex) {
|
||||
return [(hex >> 16 & 0xFF) / 255, ( hex >> 8 & 0xFF) / 255, (hex & 0xFF)/ 255];
|
||||
|
@ -2045,7 +2105,7 @@ if (typeof Function.prototype.bind != 'function') {
|
|||
})();
|
||||
}
|
||||
|
||||
var AjaxRequest = function()
|
||||
var AjaxRequest = PIXI.AjaxRequest = function()
|
||||
{
|
||||
var activexmodes = ["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"] //activeX versions to check for in IE
|
||||
|
||||
|
@ -4488,10 +4548,13 @@ PIXI.CanvasRenderer.prototype.renderDisplayObject = function(displayObject)
|
|||
}
|
||||
|
||||
// render!
|
||||
if(displayObject.children)
|
||||
{
|
||||
for (var i=0; i < displayObject.children.length; i++)
|
||||
{
|
||||
this.renderDisplayObject(displayObject.children[i]);
|
||||
}
|
||||
}
|
||||
|
||||
this.context.setTransform(1,0,0,1,0,0);
|
||||
}
|
||||
|
@ -7439,7 +7502,7 @@ PIXI.BitmapFontLoader.prototype.onLoaded = function()
|
|||
* When loaded this class will dispatch a "loaded" event
|
||||
* @class Spine
|
||||
* @constructor
|
||||
* @extends
|
||||
* @extends EventTarget
|
||||
* @param {String} url the url of the sprite sheet JSON file
|
||||
* @param {Boolean} crossorigin
|
||||
*/
|
||||
|
|
|
@ -26,6 +26,5 @@ PIXI.Polygon.clone = function()
|
|||
return new PIXI.Polygon(points);
|
||||
}
|
||||
|
||||
// constructor
|
||||
PIXI.Polygon.constructor = PIXI.Polygon;
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* See example 12 (http://www.goodboydigital.com/pixijs/examples/12/) to see a working example and check out the source
|
||||
* @class Spine
|
||||
* @constructor
|
||||
* @extends
|
||||
* @extends DisplayObjectContainer
|
||||
* @param {String} url the url of the spine anim file to be used
|
||||
*/
|
||||
PIXI.Spine = function(url)
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
* When loaded this class will dispatch a "loaded" event
|
||||
* @class Spine
|
||||
* @constructor
|
||||
* @extends
|
||||
* @extends EventTarget
|
||||
* @param {String} url the url of the sprite sheet JSON file
|
||||
* @param {Boolean} crossorigin
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue