Squashed commit of the following (jshint):
commit 09d68fb83686b82a2cbac0d99abcc7e0899d6724 Author: Dr. Kibitz <info@drkibitz.com> Date: Tue Sep 10 13:14:22 2013 -0700 ignore W069 just in 4 methods commit 931afab48f374194a808bedac4e31dd9c20d2ae4 Author: Dr. Kibitz <info@drkibitz.com> Date: Tue Sep 10 13:14:03 2013 -0700 fix for warning W055 commit 43ad62a89a1c83e8da85dd9f9bb6e8a7c0acd59d Author: Dr. Kibitz <info@drkibitz.com> Date: Tue Sep 10 13:13:46 2013 -0700 rename HEXtoRGB to hex2rgb commit adc2a1e83823061709dbf1d4b037bebeddc7281c Author: Dr. Kibitz <info@drkibitz.com> Date: Tue Sep 10 13:13:02 2013 -0700 Changed some jshint settings commit 0d8eb1ef71332b076a0f9bd565633c92395ed5ec Author: Dr. Kibitz <info@drkibitz.com> Date: Sun Sep 1 16:16:53 2013 -0700 unittest-refactor branch compatible jshint setup commit 3e91e79dab7c34dbb60bf364124d2ef7df93ec6d Author: Dr. Kibitz <info@drkibitz.com> Date: Sun Sep 1 11:15:34 2013 -0700 Final progress, jshint passed commit c0f3750a06616195cf76149091dce4a1da7717ab Author: Dr. Kibitz <info@drkibitz.com> Date: Sun Sep 1 10:31:36 2013 -0700 More progress commit b2118949bb47cbeffaf53d2cb1a978c8f9ffdf49 Author: Dr. Kibitz <info@drkibitz.com> Date: Sun Sep 1 02:38:10 2013 -0700 jshint progress
This commit is contained in:
parent
56df185471
commit
67d0c577d3
41 changed files with 5776 additions and 5733 deletions
72
.jshintrc
Normal file
72
.jshintrc
Normal file
|
@ -0,0 +1,72 @@
|
|||
{
|
||||
"passfail" : false,
|
||||
"maxerr" : 0,
|
||||
"browser" : true,
|
||||
|
||||
"node" : false,
|
||||
"rhino" : false,
|
||||
"couch" : false,
|
||||
"wsh" : false,
|
||||
|
||||
"jquery" : false,
|
||||
"prototypejs" : false,
|
||||
"mootools" : false,
|
||||
"dojo" : false,
|
||||
"predef" : [
|
||||
"_",
|
||||
"google",
|
||||
"jasmine",
|
||||
"describe",
|
||||
"xdescribe",
|
||||
"it",
|
||||
"xit",
|
||||
"beforeEach",
|
||||
"afterEach",
|
||||
"expect",
|
||||
"spyOn",
|
||||
"runs",
|
||||
"waits",
|
||||
"waitsFor",
|
||||
"Benchmark",
|
||||
"Backbone",
|
||||
"Modernizr"
|
||||
],
|
||||
|
||||
"debug" : false,
|
||||
"devel" : false,
|
||||
|
||||
"es5" : false,
|
||||
"strict" : false,
|
||||
"globalstrict" : false,
|
||||
|
||||
"smarttabs" : true,
|
||||
"asi" : true,
|
||||
"laxbreak" : false,
|
||||
"bitwise" : false,
|
||||
"boss" : false,
|
||||
"curly" : false,
|
||||
"eqeqeq" : false,
|
||||
"eqnull" : true,
|
||||
"evil" : false,
|
||||
"expr" : false,
|
||||
"forin" : false,
|
||||
"immed" : true,
|
||||
"latedef" : true,
|
||||
"loopfunc" : false,
|
||||
"noarg" : true,
|
||||
"regexp" : true,
|
||||
"regexdash" : false,
|
||||
"scripturl" : true,
|
||||
"shadow" : false,
|
||||
"supernew" : false,
|
||||
"undef" : false,
|
||||
|
||||
"newcap" : true,
|
||||
"noempty" : true,
|
||||
"nonew" : false,
|
||||
"nomen" : false,
|
||||
"onevar" : false,
|
||||
"plusplus" : false,
|
||||
"sub" : false,
|
||||
"trailing" : true
|
||||
}
|
26
Gruntfile.js
26
Gruntfile.js
|
@ -93,11 +93,24 @@ module.exports = function(grunt) {
|
|||
}
|
||||
},
|
||||
jshint: {
|
||||
beforeconcat: srcFiles,
|
||||
test: ['<%= files.testBlob %>'],
|
||||
beforeconcat: {
|
||||
src: srcFiles,
|
||||
options: {
|
||||
asi: true,
|
||||
smarttabs: true
|
||||
jshintrc: '.jshintrc',
|
||||
ignores: ['<%= dirs.src %>/{Intro,Outro}.js']
|
||||
}
|
||||
},
|
||||
afterconcat: {
|
||||
src: '<%= files.build %>',
|
||||
options: {
|
||||
jshintrc: '.jshintrc',
|
||||
}
|
||||
},
|
||||
test: {
|
||||
src: ['<%= files.testBlob %>'],
|
||||
options: {
|
||||
expr: true
|
||||
}
|
||||
}
|
||||
},
|
||||
uglify: {
|
||||
|
@ -182,8 +195,9 @@ module.exports = function(grunt) {
|
|||
}
|
||||
)
|
||||
|
||||
grunt.registerTask('default', ['concat', 'uglify', 'distribute']);
|
||||
grunt.registerTask('build', ['concat', 'uglify', 'distribute']);
|
||||
grunt.registerTask('lintconcat', ['jshint:beforeconcat', 'concat', 'jshint:afterconcat']);
|
||||
grunt.registerTask('default', ['lintconcat', 'uglify', 'distribute']);
|
||||
grunt.registerTask('build', ['lintconcat', 'uglify', 'distribute']);
|
||||
grunt.registerTask('test', ['build', 'connect:qunit', 'qunit']);
|
||||
grunt.registerTask('docs', ['yuidoc']);
|
||||
|
||||
|
|
|
@ -62,7 +62,6 @@ PIXI.InteractionManager = function(stage)
|
|||
this.onTouchEnd = this.onTouchEnd.bind(this);
|
||||
this.onTouchMove = this.onTouchMove.bind(this);
|
||||
|
||||
|
||||
this.last = 0;
|
||||
}
|
||||
|
||||
|
@ -80,10 +79,9 @@ PIXI.InteractionManager.prototype.constructor = PIXI.InteractionManager;
|
|||
PIXI.InteractionManager.prototype.collectInteractiveSprite = function(displayObject, iParent)
|
||||
{
|
||||
var children = displayObject.children;
|
||||
var length = children.length;
|
||||
|
||||
/// make an interaction tree... {item.__interactiveParent}
|
||||
for (var i = length-1; i >= 0; i--)
|
||||
for (var i = children.length - 1; i >= 0; i--)
|
||||
{
|
||||
var child = children[i];
|
||||
|
||||
|
@ -198,10 +196,12 @@ PIXI.InteractionManager.prototype.update = function()
|
|||
var now = Date.now();
|
||||
var diff = now - this.last;
|
||||
diff = (diff * 30) / 1000;
|
||||
if(diff < 1)return;
|
||||
if (diff < 1) return;
|
||||
this.last = now;
|
||||
//
|
||||
|
||||
var i, l;
|
||||
|
||||
// ok.. so mouse events??
|
||||
// yes for now :)
|
||||
// OPTIMSE - how often to check??
|
||||
|
@ -209,15 +209,13 @@ PIXI.InteractionManager.prototype.update = function()
|
|||
{
|
||||
this.dirty = false;
|
||||
|
||||
var len = this.interactiveItems.length;
|
||||
|
||||
for (var i=0; i < len; i++) {
|
||||
for (i = 0, l = this.interactiveItems.length; i < l; i++) {
|
||||
this.interactiveItems[i].interactiveChildren = false;
|
||||
}
|
||||
|
||||
this.interactiveItems = [];
|
||||
|
||||
if(this.stage.interactive)this.interactiveItems.push(this.stage);
|
||||
if (this.stage.interactive) this.interactiveItems.push(this.stage);
|
||||
// go through and collect all the objects that are interactive..
|
||||
this.collectInteractiveSprite(this.stage, this.stage);
|
||||
}
|
||||
|
@ -227,7 +225,9 @@ PIXI.InteractionManager.prototype.update = function()
|
|||
|
||||
this.interactionDOMElement.style.cursor = "default";
|
||||
|
||||
for (var i = 0; i < length; i++)
|
||||
|
||||
// loop through interactive objects!
|
||||
for (i = 0, l = this.interactiveItems.length; i < l; i++)
|
||||
{
|
||||
var item = this.interactiveItems[i];
|
||||
|
||||
|
@ -288,16 +288,10 @@ PIXI.InteractionManager.prototype.onMouseMove = function(event)
|
|||
this.mouse.global.x = (event.clientX - rect.left) * (this.target.width / rect.width);
|
||||
this.mouse.global.y = (event.clientY - rect.top) * ( this.target.height / rect.height);
|
||||
|
||||
var length = this.interactiveItems.length;
|
||||
var global = this.mouse.global;
|
||||
|
||||
|
||||
for (var i = 0; i < length; i++)
|
||||
for (var i = 0, l = this.interactiveItems.length; i < l; i++)
|
||||
{
|
||||
var item = this.interactiveItems[i];
|
||||
|
||||
if(item.mousemove)
|
||||
{
|
||||
if (item.mousemove) {
|
||||
//call the function!
|
||||
item.mousemove(this.mouse);
|
||||
}
|
||||
|
@ -319,15 +313,12 @@ PIXI.InteractionManager.prototype.onMouseDown = function(event)
|
|||
// hit test each item! ->
|
||||
// get interactive items under point??
|
||||
//stage.__i
|
||||
var length = this.interactiveItems.length;
|
||||
var global = this.mouse.global;
|
||||
|
||||
var index = 0;
|
||||
var parent = this.stage;
|
||||
|
||||
// while
|
||||
// hit test
|
||||
for (var i = 0; i < length; i++)
|
||||
for (var i = 0, l = this.interactiveItems.length; i < l; i++)
|
||||
{
|
||||
var item = this.interactiveItems[i];
|
||||
|
||||
|
@ -356,7 +347,7 @@ PIXI.InteractionManager.prototype.onMouseOut = function(event)
|
|||
|
||||
this.interactionDOMElement.style.cursor = "default";
|
||||
|
||||
for (var i = 0; i < length; i++)
|
||||
for (var i = 0, l = this.interactiveItems.length; i < l; i++)
|
||||
{
|
||||
var item = this.interactiveItems[i];
|
||||
|
||||
|
@ -380,13 +371,9 @@ PIXI.InteractionManager.prototype.onMouseUp = function(event)
|
|||
{
|
||||
this.mouse.originalEvent = event || window.event; //IE uses window.event
|
||||
|
||||
var global = this.mouse.global;
|
||||
|
||||
|
||||
var length = this.interactiveItems.length;
|
||||
var up = false;
|
||||
|
||||
for (var i = 0; i < length; i++)
|
||||
for (var i = 0, l = this.interactiveItems.length; i < l; i++)
|
||||
{
|
||||
var item = this.interactiveItems[i];
|
||||
|
||||
|
@ -477,9 +464,7 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
}
|
||||
}
|
||||
|
||||
var length = item.children.length;
|
||||
|
||||
for (var i = 0; i < length; i++)
|
||||
for (var i = 0, l = item.children.length; i < l; i++)
|
||||
{
|
||||
var tempItem = item.children[i];
|
||||
var hit = this.hitTest(tempItem, interactionData);
|
||||
|
@ -503,25 +488,25 @@ PIXI.InteractionManager.prototype.hitTest = function(item, interactionData)
|
|||
*/
|
||||
PIXI.InteractionManager.prototype.onTouchMove = function(event)
|
||||
{
|
||||
var rect = this.interactionDOMElement.getBoundingClientRect();
|
||||
var changedTouches = event.changedTouches;
|
||||
var rect = this.interactionDOMElement.getBoundingClientRect(),
|
||||
changedTouches = event.changedTouches,
|
||||
i, l, touchEvent, touchData, item;
|
||||
|
||||
for (var i=0; i < changedTouches.length; i++)
|
||||
for (i = 0, l = changedTouches.length; i < l; i++)
|
||||
{
|
||||
var touchEvent = changedTouches[i];
|
||||
var touchData = this.touchs[touchEvent.identifier];
|
||||
touchEvent = changedTouches[i];
|
||||
touchData = this.touchs[touchEvent.identifier];
|
||||
touchData.originalEvent = event || window.event;
|
||||
|
||||
// update the touch position
|
||||
touchData.global.x = (touchEvent.clientX - rect.left) * (this.target.width / rect.width);
|
||||
touchData.global.y = (touchEvent.clientY - rect.top) * (this.target.height / rect.height);
|
||||
}
|
||||
|
||||
var length = this.interactiveItems.length;
|
||||
for (var i = 0; i < length; i++)
|
||||
for (ii = 0, ll = this.interactiveItems.length; ii < ll; ii++)
|
||||
{
|
||||
var item = this.interactiveItems[i];
|
||||
if(item.touchmove)item.touchmove(touchData);
|
||||
item = this.interactiveItems[i];
|
||||
if (item.touchmove) item.touchmove(touchData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -534,15 +519,15 @@ PIXI.InteractionManager.prototype.onTouchMove = function(event)
|
|||
*/
|
||||
PIXI.InteractionManager.prototype.onTouchStart = function(event)
|
||||
{
|
||||
var rect = this.interactionDOMElement.getBoundingClientRect();
|
||||
var rect = this.interactionDOMElement.getBoundingClientRect(),
|
||||
changedTouches = event.changedTouches;
|
||||
|
||||
var changedTouches = event.changedTouches;
|
||||
for (var i=0; i < changedTouches.length; i++)
|
||||
for (var i = 0, l = changedTouches.length; i < l; i++)
|
||||
{
|
||||
var touchEvent = changedTouches[i];
|
||||
|
||||
var touchData = this.pool.pop();
|
||||
if(!touchData)touchData = new PIXI.InteractionData();
|
||||
if (!touchData) touchData = new PIXI.InteractionData();
|
||||
|
||||
touchData.originalEvent = event || window.event;
|
||||
|
||||
|
@ -550,20 +535,18 @@ PIXI.InteractionManager.prototype.onTouchStart = function(event)
|
|||
touchData.global.x = (touchEvent.clientX - rect.left) * (this.target.width / rect.width);
|
||||
touchData.global.y = (touchEvent.clientY - rect.top) * (this.target.height / rect.height);
|
||||
|
||||
var length = this.interactiveItems.length;
|
||||
|
||||
for (var j = 0; j < length; j++)
|
||||
for (var ii = 0, ll = this.interactiveItems.length; ii < ll; ii++)
|
||||
{
|
||||
var item = this.interactiveItems[j];
|
||||
var item = this.interactiveItems[ii];
|
||||
|
||||
if(item.touchstart || item.tap)
|
||||
if (item.touchstart || item.tap)
|
||||
{
|
||||
item.__hit = this.hitTest(item, touchData);
|
||||
|
||||
if(item.__hit)
|
||||
if (item.__hit)
|
||||
{
|
||||
//call the function!
|
||||
if(item.touchstart)item.touchstart(touchData);
|
||||
if (item.touchstart) item.touchstart(touchData);
|
||||
item.__isDown = true;
|
||||
item.__touchData = touchData;
|
||||
|
||||
|
@ -584,10 +567,10 @@ PIXI.InteractionManager.prototype.onTouchStart = function(event)
|
|||
PIXI.InteractionManager.prototype.onTouchEnd = function(event)
|
||||
{
|
||||
//this.mouse.originalEvent = event || window.event; //IE uses window.event
|
||||
var rect = this.interactionDOMElement.getBoundingClientRect();
|
||||
var changedTouches = event.changedTouches;
|
||||
var rect = this.interactionDOMElement.getBoundingClientRect(),
|
||||
changedTouches = event.changedTouches;
|
||||
|
||||
for (var i=0; i < changedTouches.length; i++)
|
||||
for (var i = 0, l = changedTouches.length; i < l; i++)
|
||||
{
|
||||
var touchEvent = changedTouches[i];
|
||||
var touchData = this.touchs[touchEvent.identifier];
|
||||
|
@ -595,10 +578,9 @@ PIXI.InteractionManager.prototype.onTouchEnd = function(event)
|
|||
touchData.global.x = (touchEvent.clientX - rect.left) * (this.target.width / rect.width);
|
||||
touchData.global.y = (touchEvent.clientY - rect.top) * (this.target.height / rect.height);
|
||||
|
||||
var length = this.interactiveItems.length;
|
||||
for (var j = 0; j < length; j++)
|
||||
for (var ii = 0, ll = this.interactiveItems.length; ii < ll; ii++)
|
||||
{
|
||||
var item = this.interactiveItems[j];
|
||||
var item = this.interactiveItems[ii];
|
||||
var itemTouchData = item.__touchData; // <-- Here!
|
||||
item.__hit = this.hitTest(item, touchData);
|
||||
|
||||
|
@ -632,11 +614,6 @@ PIXI.InteractionManager.prototype.onTouchEnd = function(event)
|
|||
}
|
||||
|
||||
item.__touchData = null;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
// remove the touch..
|
||||
|
@ -670,7 +647,7 @@ PIXI.InteractionData = function()
|
|||
* @property target
|
||||
* @type Sprite
|
||||
*/
|
||||
this.target;
|
||||
this.target = null;
|
||||
|
||||
/**
|
||||
* When passed to an event handler, this will be the original DOM Event that was captured
|
||||
|
@ -678,7 +655,7 @@ PIXI.InteractionData = function()
|
|||
* @property originalEvent
|
||||
* @type Event
|
||||
*/
|
||||
this.originalEvent;
|
||||
this.originalEvent = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -329,11 +329,8 @@ PIXI.DisplayObject.prototype.addFilter = function(mask)
|
|||
/*
|
||||
* insert start
|
||||
*/
|
||||
|
||||
var childFirst = start
|
||||
var childLast = start
|
||||
var nextObject;
|
||||
var previousObject;
|
||||
var childFirst, childLast, nextObject, previousObject;
|
||||
childFirst = childLast = start;
|
||||
|
||||
previousObject = this.first._iPrev;
|
||||
|
||||
|
@ -360,10 +357,8 @@ PIXI.DisplayObject.prototype.addFilter = function(mask)
|
|||
/*
|
||||
* insert end filter
|
||||
*/
|
||||
var childFirst = end
|
||||
var childLast = end
|
||||
var nextObject = null;
|
||||
var previousObject = null;
|
||||
childFirst = childLast = end
|
||||
nextObject = previousObject = null;
|
||||
|
||||
previousObject = this.last;
|
||||
nextObject = previousObject._iNext;
|
||||
|
@ -413,24 +408,22 @@ PIXI.DisplayObject.prototype.removeFilter = function()
|
|||
this.filter = false;
|
||||
|
||||
// modify the list..
|
||||
var startBlock = this.first;
|
||||
var startBlock = this.first,
|
||||
lastBlock = this.last,
|
||||
nextObject = startBlock._iNext,
|
||||
previousObject = startBlock._iPrev;
|
||||
|
||||
var nextObject = startBlock._iNext;
|
||||
var previousObject = startBlock._iPrev;
|
||||
|
||||
if(nextObject)nextObject._iPrev = previousObject;
|
||||
if(previousObject)previousObject._iNext = nextObject;
|
||||
if (nextObject) nextObject._iPrev = previousObject;
|
||||
if (previousObject) previousObject._iNext = nextObject;
|
||||
|
||||
this.first = startBlock._iNext;
|
||||
|
||||
|
||||
// remove the end filter
|
||||
var lastBlock = this.last;
|
||||
nextObject = lastBlock._iNext;
|
||||
previousObject = lastBlock._iPrev;
|
||||
|
||||
var nextObject = lastBlock._iNext;
|
||||
var previousObject = lastBlock._iPrev;
|
||||
|
||||
if(nextObject)nextObject._iPrev = previousObject;
|
||||
if (nextObject) nextObject._iPrev = previousObject;
|
||||
previousObject._iNext = nextObject;
|
||||
|
||||
// this is always true too!
|
||||
|
|
|
@ -49,14 +49,11 @@ Object.defineProperty(PIXI.DisplayObjectContainer.prototype, 'visible', {
|
|||
*/
|
||||
PIXI.DisplayObjectContainer.prototype.addChild = function(child)
|
||||
{
|
||||
if(child.parent != undefined)
|
||||
{
|
||||
|
||||
if (child.parent) {
|
||||
//// COULD BE THIS???
|
||||
child.parent.removeChild(child);
|
||||
// return;
|
||||
}
|
||||
|
||||
child.parent = this;
|
||||
|
||||
this.children.push(child);
|
||||
|
@ -140,8 +137,7 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
|
|||
{
|
||||
if(index >= 0 && index <= this.children.length)
|
||||
{
|
||||
if(child.parent != undefined)
|
||||
{
|
||||
if (child.parent) {
|
||||
child.parent.removeChild(child);
|
||||
}
|
||||
child.parent = this;
|
||||
|
@ -164,7 +160,7 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
|
|||
var nextObject;
|
||||
var previousObject;
|
||||
|
||||
if(index == this.children.length)
|
||||
if(index === this.children.length)
|
||||
{
|
||||
previousObject = this.last;
|
||||
var updateLast = this;
|
||||
|
@ -178,7 +174,7 @@ PIXI.DisplayObjectContainer.prototype.addChildAt = function(child, index)
|
|||
updateLast = updateLast.parent;
|
||||
}
|
||||
}
|
||||
else if(index == 0)
|
||||
else if(!index)
|
||||
{
|
||||
previousObject = this;
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ PIXI.Stage.prototype.updateTransform = function()
|
|||
PIXI.Stage.prototype.setBackgroundColor = function(backgroundColor)
|
||||
{
|
||||
this.backgroundColor = backgroundColor || 0x000000;
|
||||
this.backgroundColorSplit = HEXtoRGB(this.backgroundColor);
|
||||
this.backgroundColorSplit = hex2rgb(this.backgroundColor);
|
||||
var hex = this.backgroundColor.toString(16);
|
||||
hex = "000000".substr(0, 6 - hex.length) + hex;
|
||||
this.backgroundColorString = "#" + hex;
|
||||
|
|
|
@ -44,7 +44,6 @@ PIXI.Rope.prototype.refresh = function()
|
|||
var lastPoint = points[0];
|
||||
var nextPoint;
|
||||
var perp = {x:0, y:0};
|
||||
var point = points[0];
|
||||
|
||||
this.count-=0.2;
|
||||
|
||||
|
@ -60,15 +59,16 @@ PIXI.Rope.prototype.refresh = function()
|
|||
indices[0] = 0;
|
||||
indices[1] = 1;
|
||||
|
||||
var total = points.length;
|
||||
var total = points.length,
|
||||
point, index, amount;
|
||||
|
||||
for (var i = 1; i < total; i++)
|
||||
{
|
||||
|
||||
var point = points[i];
|
||||
var index = i * 4;
|
||||
point = points[i];
|
||||
index = i * 4;
|
||||
// time to do some smart drawing!
|
||||
var amount = i/(total-1)
|
||||
amount = i/(total-1)
|
||||
|
||||
if(i%2)
|
||||
{
|
||||
|
@ -106,28 +106,26 @@ PIXI.Rope.prototype.updateTransform = function()
|
|||
var points = this.points;
|
||||
if(points.length < 1)return;
|
||||
|
||||
var verticies = this.verticies
|
||||
|
||||
var lastPoint = points[0];
|
||||
var nextPoint;
|
||||
var perp = {x:0, y:0};
|
||||
var point = points[0];
|
||||
|
||||
this.count-=0.2;
|
||||
|
||||
verticies[0] = point.x + perp.x
|
||||
verticies[1] = point.y + perp.y //+ 200
|
||||
verticies[2] = point.x - perp.x
|
||||
verticies[3] = point.y - perp.y//+200
|
||||
var verticies = this.verticies;
|
||||
verticies[0] = lastPoint.x + perp.x
|
||||
verticies[1] = lastPoint.y + perp.y //+ 200
|
||||
verticies[2] = lastPoint.x - perp.x
|
||||
verticies[3] = lastPoint.y - perp.y//+200
|
||||
// time to do some smart drawing!
|
||||
|
||||
var total = points.length;
|
||||
var total = points.length,
|
||||
point, index, ratio, perpLength, num;
|
||||
|
||||
for (var i = 1; i < total; i++)
|
||||
{
|
||||
|
||||
var point = points[i];
|
||||
var index = i * 4;
|
||||
point = points[i];
|
||||
index = i * 4;
|
||||
|
||||
if(i < points.length-1)
|
||||
{
|
||||
|
@ -135,17 +133,17 @@ PIXI.Rope.prototype.updateTransform = function()
|
|||
}
|
||||
else
|
||||
{
|
||||
nextPoint = point
|
||||
nextPoint = point;
|
||||
}
|
||||
|
||||
perp.y = -(nextPoint.x - lastPoint.x);
|
||||
perp.x = nextPoint.y - lastPoint.y;
|
||||
|
||||
var ratio = (1 - (i / (total-1))) * 10;
|
||||
ratio = (1 - (i / (total-1))) * 10;
|
||||
if(ratio > 1)ratio = 1;
|
||||
|
||||
var perpLength = Math.sqrt(perp.x * perp.x + perp.y * perp.y);
|
||||
var num = this.texture.height/2//(20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio;
|
||||
perpLength = Math.sqrt(perp.x * perp.x + perp.y * perp.y);
|
||||
num = this.texture.height/2//(20 + Math.abs(Math.sin((i + this.count) * 0.3) * 50) )* ratio;
|
||||
perp.x /= perpLength;
|
||||
perp.y /= perpLength;
|
||||
|
||||
|
|
|
@ -7,122 +7,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* A class that enables the you to import and run your spine animations in pixi.
|
||||
* Spine animation data needs to be loaded using the PIXI.AssetLoader or PIXI.SpineLoader before it can be used by this class
|
||||
* See example 12 (http://www.goodboydigital.com/pixijs/examples/12/) to see a working example and check out the source
|
||||
*
|
||||
* @class Spine
|
||||
* @extends DisplayObjectContainer
|
||||
* @constructor
|
||||
* @param url {String} The url of the spine anim file to be used
|
||||
*/
|
||||
PIXI.Spine = function (url) {
|
||||
PIXI.DisplayObjectContainer.call(this);
|
||||
|
||||
this.spineData = PIXI.AnimCache[url];
|
||||
|
||||
if (!this.spineData) {
|
||||
throw new Error("Spine data must be preloaded using PIXI.SpineLoader or PIXI.AssetLoader: " + url);
|
||||
}
|
||||
|
||||
this.skeleton = new spine.Skeleton(this.spineData);
|
||||
this.skeleton.updateWorldTransform();
|
||||
|
||||
this.stateData = new spine.AnimationStateData(this.spineData);
|
||||
this.state = new spine.AnimationState(this.stateData);
|
||||
|
||||
this.slotContainers = [];
|
||||
|
||||
for (var i = 0, n = this.skeleton.drawOrder.length; i < n; i++) {
|
||||
var slot = this.skeleton.drawOrder[i];
|
||||
var attachment = slot.attachment;
|
||||
var slotContainer = new PIXI.DisplayObjectContainer();
|
||||
this.slotContainers.push(slotContainer);
|
||||
this.addChild(slotContainer);
|
||||
if (!(attachment instanceof spine.RegionAttachment)) {
|
||||
continue;
|
||||
}
|
||||
var spriteName = attachment.rendererObject.name;
|
||||
var sprite = this.createSprite(slot, attachment.rendererObject);
|
||||
slot.currentSprite = sprite;
|
||||
slot.currentSpriteName = spriteName;
|
||||
slotContainer.addChild(sprite);
|
||||
}
|
||||
};
|
||||
|
||||
PIXI.Spine.prototype = Object.create(PIXI.DisplayObjectContainer.prototype);
|
||||
PIXI.Spine.prototype.constructor = PIXI.Spine;
|
||||
|
||||
/*
|
||||
* Updates the object transform for rendering
|
||||
*
|
||||
* @method updateTransform
|
||||
* @private
|
||||
*/
|
||||
PIXI.Spine.prototype.updateTransform = function () {
|
||||
this.lastTime = this.lastTime || Date.now();
|
||||
var timeDelta = (Date.now() - this.lastTime) * 0.001;
|
||||
this.lastTime = Date.now();
|
||||
this.state.update(timeDelta);
|
||||
this.state.apply(this.skeleton);
|
||||
this.skeleton.updateWorldTransform();
|
||||
|
||||
var drawOrder = this.skeleton.drawOrder;
|
||||
for (var i = 0, n = drawOrder.length; i < n; i++) {
|
||||
var slot = drawOrder[i];
|
||||
var attachment = slot.attachment;
|
||||
var slotContainer = this.slotContainers[i];
|
||||
if (!(attachment instanceof spine.RegionAttachment)) {
|
||||
slotContainer.visible = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (attachment.rendererObject) {
|
||||
if (!slot.currentSpriteName || slot.currentSpriteName != attachment.name) {
|
||||
var spriteName = attachment.rendererObject.name;
|
||||
if (slot.currentSprite !== undefined) {
|
||||
slot.currentSprite.visible = false;
|
||||
}
|
||||
slot.sprites = slot.sprites || {};
|
||||
if (slot.sprites[spriteName] !== undefined) {
|
||||
slot.sprites[spriteName].visible = true;
|
||||
} else {
|
||||
var sprite = this.createSprite(slot, attachment.rendererObject);
|
||||
slotContainer.addChild(sprite);
|
||||
}
|
||||
slot.currentSprite = slot.sprites[spriteName];
|
||||
slot.currentSpriteName = spriteName;
|
||||
}
|
||||
}
|
||||
slotContainer.visible = true;
|
||||
|
||||
var bone = slot.bone;
|
||||
|
||||
slotContainer.position.x = bone.worldX + attachment.x * bone.m00 + attachment.y * bone.m01;
|
||||
slotContainer.position.y = bone.worldY + attachment.x * bone.m10 + attachment.y * bone.m11;
|
||||
slotContainer.scale.x = bone.worldScaleX;
|
||||
slotContainer.scale.y = bone.worldScaleY;
|
||||
|
||||
slotContainer.rotation = -(slot.bone.worldRotation * Math.PI / 180);
|
||||
}
|
||||
|
||||
PIXI.DisplayObjectContainer.prototype.updateTransform.call(this);
|
||||
};
|
||||
|
||||
|
||||
PIXI.Spine.prototype.createSprite = function (slot, descriptor) {
|
||||
var name = PIXI.TextureCache[descriptor.name] ? descriptor.name : descriptor.name + ".png";
|
||||
var sprite = new PIXI.Sprite(PIXI.Texture.fromFrame(name));
|
||||
sprite.scale = descriptor.scale;
|
||||
sprite.rotation = descriptor.rotation;
|
||||
sprite.anchor.x = sprite.anchor.y = 0.5;
|
||||
|
||||
slot.sprites = slot.sprites || {};
|
||||
slot.sprites[descriptor.name] = sprite;
|
||||
return sprite;
|
||||
};
|
||||
|
||||
/*
|
||||
* Awesome JS run time provided by EsotericSoftware
|
||||
*
|
||||
|
@ -262,7 +146,7 @@ spine.Skin.prototype = {
|
|||
_attachAll: function (skeleton, oldSkin) {
|
||||
for (var key in oldSkin.attachments) {
|
||||
var colon = key.indexOf(":");
|
||||
var slotIndex = parseInt(key.substring(0, colon));
|
||||
var slotIndex = parseInt(key.substring(0, colon), 10);
|
||||
var name = key.substring(colon + 1);
|
||||
var slot = skeleton.slots[slotIndex];
|
||||
if (slot.attachment && slot.attachment.name == name) {
|
||||
|
@ -280,13 +164,13 @@ spine.Animation = function (name, timelines, duration) {
|
|||
};
|
||||
spine.Animation.prototype = {
|
||||
apply: function (skeleton, time, loop) {
|
||||
if (loop && this.duration != 0) time %= this.duration;
|
||||
if (loop && this.duration) time %= this.duration;
|
||||
var timelines = this.timelines;
|
||||
for (var i = 0, n = timelines.length; i < n; i++)
|
||||
timelines[i].apply(skeleton, time, 1);
|
||||
},
|
||||
mix: function (skeleton, time, loop, alpha) {
|
||||
if (loop && this.duration != 0) time %= this.duration;
|
||||
if (loop && this.duration) time %= this.duration;
|
||||
var timelines = this.timelines;
|
||||
for (var i = 0, n = timelines.length; i < n; i++)
|
||||
timelines[i].apply(skeleton, time, alpha);
|
||||
|
@ -296,7 +180,7 @@ spine.Animation.prototype = {
|
|||
spine.binarySearch = function (values, target, step) {
|
||||
var low = 0;
|
||||
var high = Math.floor(values.length / step) - 2;
|
||||
if (high == 0) return step;
|
||||
if (!high) return step;
|
||||
var current = high >>> 1;
|
||||
while (true) {
|
||||
if (values[(current + 1) * step] <= target)
|
||||
|
@ -368,7 +252,7 @@ spine.Curves.prototype = {
|
|||
var lastY = y - dfy;
|
||||
return lastY + (y - lastY) * (percent - lastX) / (x - lastX);
|
||||
}
|
||||
if (i == 0) break;
|
||||
if (!i) break;
|
||||
i--;
|
||||
dfx += ddfx;
|
||||
dfy += ddfy;
|
||||
|
@ -397,13 +281,15 @@ spine.RotateTimeline.prototype = {
|
|||
this.frames[frameIndex + 1] = angle;
|
||||
},
|
||||
apply: function (skeleton, time, alpha) {
|
||||
var frames = this.frames;
|
||||
var frames = this.frames,
|
||||
amount;
|
||||
|
||||
if (time < frames[0]) return; // Time is before first frame.
|
||||
|
||||
var bone = skeleton.bones[this.boneIndex];
|
||||
|
||||
if (time >= frames[frames.length - 2]) { // Time is after last frame.
|
||||
var amount = bone.data.rotation + frames[frames.length - 1] - bone.rotation;
|
||||
amount = bone.data.rotation + frames[frames.length - 1] - bone.rotation;
|
||||
while (amount > 180)
|
||||
amount -= 360;
|
||||
while (amount < -180)
|
||||
|
@ -419,7 +305,7 @@ spine.RotateTimeline.prototype = {
|
|||
var percent = 1 - (time - frameTime) / (frames[frameIndex - 2/*LAST_FRAME_TIME*/] - frameTime);
|
||||
percent = this.curves.getCurvePercent(frameIndex / 2 - 1, percent);
|
||||
|
||||
var amount = frames[frameIndex + 1/*FRAME_VALUE*/] - lastFrameValue;
|
||||
amount = frames[frameIndex + 1/*FRAME_VALUE*/] - lastFrameValue;
|
||||
while (amount > 180)
|
||||
amount -= 360;
|
||||
while (amount < -180)
|
||||
|
@ -672,7 +558,7 @@ spine.Skeleton = function (skeletonData) {
|
|||
|
||||
this.slots = [];
|
||||
this.drawOrder = [];
|
||||
for (var i = 0, n = skeletonData.slots.length; i < n; i++) {
|
||||
for (i = 0, n = skeletonData.slots.length; i < n; i++) {
|
||||
var slotData = skeletonData.slots[i];
|
||||
var bone = this.bones[skeletonData.bones.indexOf(slotData.boneData)];
|
||||
var slot = new spine.Slot(slotData, this, bone);
|
||||
|
@ -711,7 +597,7 @@ spine.Skeleton.prototype = {
|
|||
},
|
||||
/** @return May return null. */
|
||||
getRootBone: function () {
|
||||
return this.bones.length == 0 ? null : this.bones[0];
|
||||
return this.bones.length ? this.bones[0] : null;
|
||||
},
|
||||
/** @return May be null. */
|
||||
findBone: function (boneName) {
|
||||
|
@ -983,7 +869,7 @@ spine.AnimationState.prototype = {
|
|||
entry.loop = loop;
|
||||
|
||||
if (!delay || delay <= 0) {
|
||||
var previousAnimation = this.queue.length == 0 ? this.current : this.queue[this.queue.length - 1].animation;
|
||||
var previousAnimation = this.queue.length ? this.queue[this.queue.length - 1].animation : this.current;
|
||||
if (previousAnimation != null)
|
||||
delay = previousAnimation.duration - this.data.getMix(previousAnimation, animation) + (delay || 0);
|
||||
else
|
||||
|
@ -1005,7 +891,9 @@ spine.SkeletonJson = function (attachmentLoader) {
|
|||
spine.SkeletonJson.prototype = {
|
||||
scale: 1,
|
||||
readSkeletonData: function (root) {
|
||||
var skeletonData = new spine.SkeletonData();
|
||||
/*jshint -W069*/
|
||||
var skeletonData = new spine.SkeletonData(),
|
||||
boneData;
|
||||
|
||||
// Bones.
|
||||
var bones = root["bones"];
|
||||
|
@ -1016,7 +904,7 @@ spine.SkeletonJson.prototype = {
|
|||
parent = skeletonData.findBone(boneMap["parent"]);
|
||||
if (!parent) throw "Parent bone not found: " + boneMap["parent"];
|
||||
}
|
||||
var boneData = new spine.BoneData(boneMap["name"], parent);
|
||||
boneData = new spine.BoneData(boneMap["name"], parent);
|
||||
boneData.length = (boneMap["length"] || 0) * this.scale;
|
||||
boneData.x = (boneMap["x"] || 0) * this.scale;
|
||||
boneData.y = (boneMap["y"] || 0) * this.scale;
|
||||
|
@ -1028,9 +916,9 @@ spine.SkeletonJson.prototype = {
|
|||
|
||||
// Slots.
|
||||
var slots = root["slots"];
|
||||
for (var i = 0, n = slots.length; i < n; i++) {
|
||||
for (i = 0, n = slots.length; i < n; i++) {
|
||||
var slotMap = slots[i];
|
||||
var boneData = skeletonData.findBone(slotMap["bone"]);
|
||||
boneData = skeletonData.findBone(slotMap["bone"]);
|
||||
if (!boneData) throw "Slot bone not found: " + slotMap["bone"];
|
||||
var slotData = new spine.SlotData(slotMap["name"], boneData);
|
||||
|
||||
|
@ -1077,6 +965,7 @@ spine.SkeletonJson.prototype = {
|
|||
return skeletonData;
|
||||
},
|
||||
readAttachment: function (skin, name, map) {
|
||||
/*jshint -W069*/
|
||||
name = map["name"] || name;
|
||||
|
||||
var type = spine.AttachmentType[map["type"] || "region"];
|
||||
|
@ -1105,8 +994,11 @@ spine.SkeletonJson.prototype = {
|
|||
},
|
||||
|
||||
readAnimation: function (name, map, skeletonData) {
|
||||
/*jshint -W069*/
|
||||
var timelines = [];
|
||||
var duration = 0;
|
||||
var frameIndex, timeline, timelineName, valueMap, values,
|
||||
i, n;
|
||||
|
||||
var bones = map["bones"];
|
||||
for (var boneName in bones) {
|
||||
|
@ -1115,16 +1007,16 @@ spine.SkeletonJson.prototype = {
|
|||
if (boneIndex == -1) throw "Bone not found: " + boneName;
|
||||
var boneMap = bones[boneName];
|
||||
|
||||
for (var timelineName in boneMap) {
|
||||
for (timelineName in boneMap) {
|
||||
if (!boneMap.hasOwnProperty(timelineName)) continue;
|
||||
var values = boneMap[timelineName];
|
||||
values = boneMap[timelineName];
|
||||
if (timelineName == "rotate") {
|
||||
var timeline = new spine.RotateTimeline(values.length);
|
||||
timeline = new spine.RotateTimeline(values.length);
|
||||
timeline.boneIndex = boneIndex;
|
||||
|
||||
var frameIndex = 0;
|
||||
for (var i = 0, n = values.length; i < n; i++) {
|
||||
var valueMap = values[i];
|
||||
frameIndex = 0;
|
||||
for (i = 0, n = values.length; i < n; i++) {
|
||||
valueMap = values[i];
|
||||
timeline.setFrame(frameIndex, valueMap["time"], valueMap["angle"]);
|
||||
spine.SkeletonJson.readCurve(timeline, frameIndex, valueMap);
|
||||
frameIndex++;
|
||||
|
@ -1133,7 +1025,6 @@ spine.SkeletonJson.prototype = {
|
|||
duration = Math.max(duration, timeline.frames[timeline.getFrameCount() * 2 - 2]);
|
||||
|
||||
} else if (timelineName == "translate" || timelineName == "scale") {
|
||||
var timeline;
|
||||
var timelineScale = 1;
|
||||
if (timelineName == "scale")
|
||||
timeline = new spine.ScaleTimeline(values.length);
|
||||
|
@ -1143,9 +1034,9 @@ spine.SkeletonJson.prototype = {
|
|||
}
|
||||
timeline.boneIndex = boneIndex;
|
||||
|
||||
var frameIndex = 0;
|
||||
for (var i = 0, n = values.length; i < n; i++) {
|
||||
var valueMap = values[i];
|
||||
frameIndex = 0;
|
||||
for (i = 0, n = values.length; i < n; i++) {
|
||||
valueMap = values[i];
|
||||
var x = (valueMap["x"] || 0) * timelineScale;
|
||||
var y = (valueMap["y"] || 0) * timelineScale;
|
||||
timeline.setFrame(frameIndex, valueMap["time"], x, y);
|
||||
|
@ -1165,16 +1056,16 @@ spine.SkeletonJson.prototype = {
|
|||
var slotMap = slots[slotName];
|
||||
var slotIndex = skeletonData.findSlotIndex(slotName);
|
||||
|
||||
for (var timelineName in slotMap) {
|
||||
for (timelineName in slotMap) {
|
||||
if (!slotMap.hasOwnProperty(timelineName)) continue;
|
||||
var values = slotMap[timelineName];
|
||||
values = slotMap[timelineName];
|
||||
if (timelineName == "color") {
|
||||
var timeline = new spine.ColorTimeline(values.length);
|
||||
timeline = new spine.ColorTimeline(values.length);
|
||||
timeline.slotIndex = slotIndex;
|
||||
|
||||
var frameIndex = 0;
|
||||
for (var i = 0, n = values.length; i < n; i++) {
|
||||
var valueMap = values[i];
|
||||
frameIndex = 0;
|
||||
for (i = 0, n = values.length; i < n; i++) {
|
||||
valueMap = values[i];
|
||||
var color = valueMap["color"];
|
||||
var r = spine.SkeletonJson.toColor(color, 0);
|
||||
var g = spine.SkeletonJson.toColor(color, 1);
|
||||
|
@ -1188,12 +1079,12 @@ spine.SkeletonJson.prototype = {
|
|||
duration = Math.max(duration, timeline.frames[timeline.getFrameCount() * 5 - 5]);
|
||||
|
||||
} else if (timelineName == "attachment") {
|
||||
var timeline = new spine.AttachmentTimeline(values.length);
|
||||
timeline = new spine.AttachmentTimeline(values.length);
|
||||
timeline.slotIndex = slotIndex;
|
||||
|
||||
var frameIndex = 0;
|
||||
for (var i = 0, n = values.length; i < n; i++) {
|
||||
var valueMap = values[i];
|
||||
frameIndex = 0;
|
||||
for (i = 0, n = values.length; i < n; i++) {
|
||||
valueMap = values[i];
|
||||
timeline.setFrame(frameIndex++, valueMap["time"], valueMap["name"]);
|
||||
}
|
||||
timelines.push(timeline);
|
||||
|
@ -1207,6 +1098,7 @@ spine.SkeletonJson.prototype = {
|
|||
}
|
||||
};
|
||||
spine.SkeletonJson.readCurve = function (timeline, frameIndex, valueMap) {
|
||||
/*jshint -W069*/
|
||||
var curve = valueMap["curve"];
|
||||
if (!curve) return;
|
||||
if (curve == "stepped")
|
||||
|
@ -1232,7 +1124,7 @@ spine.Atlas = function (atlasText, textureLoader) {
|
|||
var line = reader.readLine();
|
||||
if (line == null) break;
|
||||
line = reader.trim(line);
|
||||
if (line.length == 0)
|
||||
if (!line.length)
|
||||
page = null;
|
||||
else if (!page) {
|
||||
page = new spine.AtlasPage();
|
||||
|
@ -1266,12 +1158,12 @@ spine.Atlas = function (atlasText, textureLoader) {
|
|||
region.rotate = reader.readValue() == "true";
|
||||
|
||||
reader.readTuple(tuple);
|
||||
var x = parseInt(tuple[0]);
|
||||
var y = parseInt(tuple[1]);
|
||||
var x = parseInt(tuple[0], 10);
|
||||
var y = parseInt(tuple[1], 10);
|
||||
|
||||
reader.readTuple(tuple);
|
||||
var width = parseInt(tuple[0]);
|
||||
var height = parseInt(tuple[1]);
|
||||
var width = parseInt(tuple[0], 10);
|
||||
var height = parseInt(tuple[1], 10);
|
||||
|
||||
region.u = x / page.width;
|
||||
region.v = y / page.height;
|
||||
|
@ -1288,23 +1180,23 @@ spine.Atlas = function (atlasText, textureLoader) {
|
|||
region.height = Math.abs(height);
|
||||
|
||||
if (reader.readTuple(tuple) == 4) { // split is optional
|
||||
region.splits = [parseInt(tuple[0]), parseInt(tuple[1]), parseInt(tuple[2]), parseInt(tuple[3])];
|
||||
region.splits = [parseInt(tuple[0], 10), parseInt(tuple[1], 10), parseInt(tuple[2], 10), parseInt(tuple[3], 10)];
|
||||
|
||||
if (reader.readTuple(tuple) == 4) { // pad is optional, but only present with splits
|
||||
region.pads = [parseInt(tuple[0]), parseInt(tuple[1]), parseInt(tuple[2]), parseInt(tuple[3])];
|
||||
region.pads = [parseInt(tuple[0], 10), parseInt(tuple[1], 10), parseInt(tuple[2], 10), parseInt(tuple[3], 10)];
|
||||
|
||||
reader.readTuple(tuple);
|
||||
}
|
||||
}
|
||||
|
||||
region.originalWidth = parseInt(tuple[0]);
|
||||
region.originalHeight = parseInt(tuple[1]);
|
||||
region.originalWidth = parseInt(tuple[0], 10);
|
||||
region.originalHeight = parseInt(tuple[1], 10);
|
||||
|
||||
reader.readTuple(tuple);
|
||||
region.offsetX = parseInt(tuple[0]);
|
||||
region.offsetY = parseInt(tuple[1]);
|
||||
region.offsetX = parseInt(tuple[0], 10);
|
||||
region.offsetY = parseInt(tuple[1], 10);
|
||||
|
||||
region.index = parseInt(reader.readValue());
|
||||
region.index = parseInt(reader.readValue(), 10);
|
||||
|
||||
this.regions.push(region);
|
||||
}
|
||||
|
@ -1421,7 +1313,7 @@ spine.AtlasReader.prototype = {
|
|||
for (; i < 3; i++) {
|
||||
var comma = line.indexOf(",", lastMatch);
|
||||
if (comma == -1) {
|
||||
if (i == 0) throw "Invalid line: " + line;
|
||||
if (!i) throw "Invalid line: " + line;
|
||||
break;
|
||||
}
|
||||
tuple[i] = this.trim(line.substr(lastMatch, comma - lastMatch));
|
||||
|
@ -1456,5 +1348,122 @@ spine.AtlasAttachmentLoader.prototype = {
|
|||
}
|
||||
}
|
||||
|
||||
PIXI.AnimCache = {};
|
||||
spine.Bone.yDown = true;
|
||||
PIXI.AnimCache = {};
|
||||
|
||||
/**
|
||||
* A class that enables the you to import and run your spine animations in pixi.
|
||||
* Spine animation data needs to be loaded using the PIXI.AssetLoader or PIXI.SpineLoader before it can be used by this class
|
||||
* See example 12 (http://www.goodboydigital.com/pixijs/examples/12/) to see a working example and check out the source
|
||||
*
|
||||
* @class Spine
|
||||
* @extends DisplayObjectContainer
|
||||
* @constructor
|
||||
* @param url {String} The url of the spine anim file to be used
|
||||
*/
|
||||
PIXI.Spine = function (url) {
|
||||
PIXI.DisplayObjectContainer.call(this);
|
||||
|
||||
this.spineData = PIXI.AnimCache[url];
|
||||
|
||||
if (!this.spineData) {
|
||||
throw new Error("Spine data must be preloaded using PIXI.SpineLoader or PIXI.AssetLoader: " + url);
|
||||
}
|
||||
|
||||
this.skeleton = new spine.Skeleton(this.spineData);
|
||||
this.skeleton.updateWorldTransform();
|
||||
|
||||
this.stateData = new spine.AnimationStateData(this.spineData);
|
||||
this.state = new spine.AnimationState(this.stateData);
|
||||
|
||||
this.slotContainers = [];
|
||||
|
||||
for (var i = 0, n = this.skeleton.drawOrder.length; i < n; i++) {
|
||||
var slot = this.skeleton.drawOrder[i];
|
||||
var attachment = slot.attachment;
|
||||
var slotContainer = new PIXI.DisplayObjectContainer();
|
||||
this.slotContainers.push(slotContainer);
|
||||
this.addChild(slotContainer);
|
||||
if (!(attachment instanceof spine.RegionAttachment)) {
|
||||
continue;
|
||||
}
|
||||
var spriteName = attachment.rendererObject.name;
|
||||
var sprite = this.createSprite(slot, attachment.rendererObject);
|
||||
slot.currentSprite = sprite;
|
||||
slot.currentSpriteName = spriteName;
|
||||
slotContainer.addChild(sprite);
|
||||
}
|
||||
};
|
||||
|
||||
PIXI.Spine.prototype = Object.create(PIXI.DisplayObjectContainer.prototype);
|
||||
PIXI.Spine.prototype.constructor = PIXI.Spine;
|
||||
|
||||
/*
|
||||
* Updates the object transform for rendering
|
||||
*
|
||||
* @method updateTransform
|
||||
* @private
|
||||
*/
|
||||
PIXI.Spine.prototype.updateTransform = function () {
|
||||
this.lastTime = this.lastTime || Date.now();
|
||||
var timeDelta = (Date.now() - this.lastTime) * 0.001;
|
||||
this.lastTime = Date.now();
|
||||
this.state.update(timeDelta);
|
||||
this.state.apply(this.skeleton);
|
||||
this.skeleton.updateWorldTransform();
|
||||
|
||||
var drawOrder = this.skeleton.drawOrder;
|
||||
for (var i = 0, n = drawOrder.length; i < n; i++) {
|
||||
var slot = drawOrder[i];
|
||||
var attachment = slot.attachment;
|
||||
var slotContainer = this.slotContainers[i];
|
||||
if (!(attachment instanceof spine.RegionAttachment)) {
|
||||
slotContainer.visible = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (attachment.rendererObject) {
|
||||
if (!slot.currentSpriteName || slot.currentSpriteName != attachment.name) {
|
||||
var spriteName = attachment.rendererObject.name;
|
||||
if (slot.currentSprite !== undefined) {
|
||||
slot.currentSprite.visible = false;
|
||||
}
|
||||
slot.sprites = slot.sprites || {};
|
||||
if (slot.sprites[spriteName] !== undefined) {
|
||||
slot.sprites[spriteName].visible = true;
|
||||
} else {
|
||||
var sprite = this.createSprite(slot, attachment.rendererObject);
|
||||
slotContainer.addChild(sprite);
|
||||
}
|
||||
slot.currentSprite = slot.sprites[spriteName];
|
||||
slot.currentSpriteName = spriteName;
|
||||
}
|
||||
}
|
||||
slotContainer.visible = true;
|
||||
|
||||
var bone = slot.bone;
|
||||
|
||||
slotContainer.position.x = bone.worldX + attachment.x * bone.m00 + attachment.y * bone.m01;
|
||||
slotContainer.position.y = bone.worldY + attachment.x * bone.m10 + attachment.y * bone.m11;
|
||||
slotContainer.scale.x = bone.worldScaleX;
|
||||
slotContainer.scale.y = bone.worldScaleY;
|
||||
|
||||
slotContainer.rotation = -(slot.bone.worldRotation * Math.PI / 180);
|
||||
}
|
||||
|
||||
PIXI.DisplayObjectContainer.prototype.updateTransform.call(this);
|
||||
};
|
||||
|
||||
|
||||
PIXI.Spine.prototype.createSprite = function (slot, descriptor) {
|
||||
var name = PIXI.TextureCache[descriptor.name] ? descriptor.name : descriptor.name + ".png";
|
||||
var sprite = new PIXI.Sprite(PIXI.Texture.fromFrame(name));
|
||||
sprite.scale = descriptor.scale;
|
||||
sprite.rotation = descriptor.rotation;
|
||||
sprite.anchor.x = sprite.anchor.y = 0.5;
|
||||
|
||||
slot.sprites = slot.sprites || {};
|
||||
slot.sprites[descriptor.name] = sprite;
|
||||
return sprite;
|
||||
};
|
||||
|
||||
|
|
|
@ -80,23 +80,24 @@ PIXI.AssetLoader.prototype.load = function()
|
|||
{
|
||||
var scope = this;
|
||||
|
||||
function onLoad() {
|
||||
scope.onAssetLoaded();
|
||||
}
|
||||
|
||||
this.loadCount = this.assetURLs.length;
|
||||
|
||||
for (var i=0; i < this.assetURLs.length; i++)
|
||||
for (var i = 0, l = this.assetURLs.length; i < l; i++)
|
||||
{
|
||||
var fileName = this.assetURLs[i];
|
||||
var fileType = fileName.split(".").pop().toLowerCase();
|
||||
|
||||
var loaderClass = this.loadersByType[fileType];
|
||||
if(!loaderClass)
|
||||
var Constructor = this.loadersByType[fileType];
|
||||
if(!Constructor)
|
||||
throw new Error(fileType + " is an unsupported file type");
|
||||
|
||||
var loader = new loaderClass(fileName, this.crossorigin);
|
||||
var loader = new Constructor(fileName, this.crossorigin);
|
||||
|
||||
loader.addEventListener("loaded", function()
|
||||
{
|
||||
scope.onAssetLoaded();
|
||||
});
|
||||
loader.addEventListener("loaded", onLoad);
|
||||
loader.load();
|
||||
}
|
||||
};
|
||||
|
@ -111,9 +112,9 @@ PIXI.AssetLoader.prototype.onAssetLoaded = function()
|
|||
{
|
||||
this.loadCount--;
|
||||
this.dispatchEvent({type: "onProgress", content: this});
|
||||
if(this.onProgress) this.onProgress();
|
||||
if (this.onProgress) this.onProgress();
|
||||
|
||||
if(this.loadCount == 0)
|
||||
if (!this.loadCount)
|
||||
{
|
||||
this.dispatchEvent({type: "onComplete", content: this});
|
||||
if(this.onComplete) this.onComplete();
|
||||
|
|
|
@ -75,11 +75,11 @@ PIXI.Graphics.prototype.constructor = PIXI.Graphics;
|
|||
*/
|
||||
PIXI.Graphics.prototype.lineStyle = function(lineWidth, color, alpha)
|
||||
{
|
||||
if(this.currentPath.points.length == 0)this.graphicsData.pop();
|
||||
if (!this.currentPath.points.length) this.graphicsData.pop();
|
||||
|
||||
this.lineWidth = lineWidth || 0;
|
||||
this.lineColor = color || 0;
|
||||
this.lineAlpha = (alpha == undefined) ? 1 : alpha;
|
||||
this.lineAlpha = (arguments.length < 3) ? 1 : alpha;
|
||||
|
||||
this.currentPath = {lineWidth:this.lineWidth, lineColor:this.lineColor, lineAlpha:this.lineAlpha,
|
||||
fillColor:this.fillColor, fillAlpha:this.fillAlpha, fill:this.filling, points:[], type:PIXI.Graphics.POLY};
|
||||
|
@ -96,7 +96,7 @@ PIXI.Graphics.prototype.lineStyle = function(lineWidth, color, alpha)
|
|||
*/
|
||||
PIXI.Graphics.prototype.moveTo = function(x, y)
|
||||
{
|
||||
if(this.currentPath.points.length == 0)this.graphicsData.pop();
|
||||
if (!this.currentPath.points.length) this.graphicsData.pop();
|
||||
|
||||
this.currentPath = this.currentPath = {lineWidth:this.lineWidth, lineColor:this.lineColor, lineAlpha:this.lineAlpha,
|
||||
fillColor:this.fillColor, fillAlpha:this.fillAlpha, fill:this.filling, points:[], type:PIXI.Graphics.POLY};
|
||||
|
@ -132,7 +132,7 @@ PIXI.Graphics.prototype.beginFill = function(color, alpha)
|
|||
{
|
||||
this.filling = true;
|
||||
this.fillColor = color || 0;
|
||||
this.fillAlpha = (alpha == undefined) ? 1 : alpha;
|
||||
this.fillAlpha = (arguments.length < 2) ? 1 : alpha;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -157,7 +157,7 @@ PIXI.Graphics.prototype.endFill = function()
|
|||
*/
|
||||
PIXI.Graphics.prototype.drawRect = function( x, y, width, height )
|
||||
{
|
||||
if(this.currentPath.points.length == 0)this.graphicsData.pop();
|
||||
if (!this.currentPath.points.length) this.graphicsData.pop();
|
||||
|
||||
this.currentPath = {lineWidth:this.lineWidth, lineColor:this.lineColor, lineAlpha:this.lineAlpha,
|
||||
fillColor:this.fillColor, fillAlpha:this.fillAlpha, fill:this.filling,
|
||||
|
@ -177,7 +177,7 @@ PIXI.Graphics.prototype.drawRect = function( x, y, width, height )
|
|||
*/
|
||||
PIXI.Graphics.prototype.drawCircle = function( x, y, radius)
|
||||
{
|
||||
if(this.currentPath.points.length == 0)this.graphicsData.pop();
|
||||
if (!this.currentPath.points.length) this.graphicsData.pop();
|
||||
|
||||
this.currentPath = {lineWidth:this.lineWidth, lineColor:this.lineColor, lineAlpha:this.lineAlpha,
|
||||
fillColor:this.fillColor, fillAlpha:this.fillAlpha, fill:this.filling,
|
||||
|
@ -198,7 +198,7 @@ PIXI.Graphics.prototype.drawCircle = function( x, y, radius)
|
|||
*/
|
||||
PIXI.Graphics.prototype.drawElipse = function( x, y, width, height)
|
||||
{
|
||||
if(this.currentPath.points.length == 0)this.graphicsData.pop();
|
||||
if (!this.currentPath.points.length) this.graphicsData.pop();
|
||||
|
||||
this.currentPath = {lineWidth:this.lineWidth, lineColor:this.lineColor, lineAlpha:this.lineAlpha,
|
||||
fillColor:this.fillColor, fillAlpha:this.fillAlpha, fill:this.filling,
|
||||
|
|
|
@ -116,7 +116,7 @@ PIXI.CanvasGraphics.renderGraphics = function(graphics, context)
|
|||
|
||||
context.beginPath();
|
||||
|
||||
var kappa = .5522848,
|
||||
var kappa = 0.5522848,
|
||||
ox = (w / 2) * kappa, // control point offset horizontal
|
||||
oy = (h / 2) * kappa, // control point offset vertical
|
||||
xe = x + w, // x-end
|
||||
|
@ -145,7 +145,7 @@ PIXI.CanvasGraphics.renderGraphics = function(graphics, context)
|
|||
}
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -217,7 +217,7 @@ PIXI.CanvasGraphics.renderGraphicsMask = function(graphics, context)
|
|||
|
||||
context.beginPath();
|
||||
|
||||
var kappa = .5522848,
|
||||
var kappa = 0.5522848,
|
||||
ox = (w / 2) * kappa, // control point offset horizontal
|
||||
oy = (h / 2) * kappa, // control point offset vertical
|
||||
xe = x + w, // x-end
|
||||
|
@ -233,6 +233,5 @@ PIXI.CanvasGraphics.renderGraphicsMask = function(graphics, context)
|
|||
context.closePath();
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -267,7 +267,7 @@ PIXI.CanvasRenderer.prototype.renderStripFlat = function(strip)
|
|||
context.lineTo(x1, y1);
|
||||
context.lineTo(x2, y2);
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
context.fillStyle = "#FF0000";
|
||||
context.fill();
|
||||
|
@ -365,6 +365,6 @@ PIXI.CanvasRenderer.prototype.renderStrip = function(strip)
|
|||
|
||||
context.drawImage(strip.texture.baseTexture.source, 0, 0);
|
||||
context.restore();
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,14 +9,7 @@ PIXI._batchs = [];
|
|||
*/
|
||||
PIXI._getBatch = function(gl)
|
||||
{
|
||||
if(PIXI._batchs.length == 0)
|
||||
{
|
||||
return new PIXI.WebGLBatch(gl);
|
||||
}
|
||||
else
|
||||
{
|
||||
return PIXI._batchs.pop();
|
||||
}
|
||||
return PIXI._batchs.length ? new PIXI.WebGLBatch(gl) : PIXI._batchs.pop();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,10 +26,10 @@ PIXI._returnBatch = function(batch)
|
|||
*/
|
||||
PIXI._restoreBatchs = function(gl)
|
||||
{
|
||||
for (var i=0; i < PIXI._batchs.length; i++)
|
||||
for (var i = 0, l = PIXI._batchs.length; i < l; i++)
|
||||
{
|
||||
PIXI._batchs[i].restoreLostContext(gl);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -81,10 +74,9 @@ PIXI.WebGLBatch.prototype.clean = function()
|
|||
this.colors = [];
|
||||
this.dynamicSize = 1;
|
||||
this.texture = null;
|
||||
this.last = null;
|
||||
this.size = 0;
|
||||
this.head;
|
||||
this.tail;
|
||||
this.head = null;
|
||||
this.tail = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -189,7 +181,7 @@ PIXI.WebGLBatch.prototype.remove = function(sprite)
|
|||
{
|
||||
this.size--;
|
||||
|
||||
if(this.size == 0)
|
||||
if (!this.size)
|
||||
{
|
||||
sprite.batch = null;
|
||||
sprite.__prev = null;
|
||||
|
@ -326,9 +318,8 @@ PIXI.WebGLBatch.prototype.growBatch = function()
|
|||
this.dirtyColors = true;
|
||||
|
||||
this.indices = new Uint16Array(this.dynamicSize * 6);
|
||||
var length = this.indices.length/6;
|
||||
|
||||
for (var i=0; i < length; i++)
|
||||
for (var i = 0, l = this.indices.length/6; i < l; i++)
|
||||
{
|
||||
var index2 = i * 6;
|
||||
var index3 = i * 4;
|
||||
|
@ -338,7 +329,7 @@ PIXI.WebGLBatch.prototype.growBatch = function()
|
|||
this.indices[index2 + 3] = index3 + 0;
|
||||
this.indices[index2 + 4] = index3 + 2;
|
||||
this.indices[index2 + 5] = index3 + 3;
|
||||
};
|
||||
}
|
||||
|
||||
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
|
||||
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, this.indices, gl.STATIC_DRAW);
|
||||
|
@ -521,7 +512,7 @@ PIXI.WebGLBatch.prototype.render = function(start, end)
|
|||
{
|
||||
start = start || 0;
|
||||
|
||||
if(end == undefined)end = this.size;
|
||||
if (arguments.length < 2) end = this.size;
|
||||
|
||||
if(this.dirty)
|
||||
{
|
||||
|
@ -529,7 +520,7 @@ PIXI.WebGLBatch.prototype.render = function(start, end)
|
|||
this.dirty = false;
|
||||
}
|
||||
|
||||
if (this.size == 0)return;
|
||||
if (!this.size) return;
|
||||
|
||||
this.update();
|
||||
var gl = this.gl;
|
||||
|
|
|
@ -117,7 +117,7 @@ PIXI.WebGLGraphics.updateGraphics = function(graphics)
|
|||
{
|
||||
PIXI.WebGLGraphics.buildCircle(data, graphics._webGL);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
graphics._webGL.lastIndex = graphics.graphicsData.length;
|
||||
|
||||
|
@ -157,7 +157,7 @@ PIXI.WebGLGraphics.buildRectangle = function(graphicsData, webGLData)
|
|||
|
||||
if(graphicsData.fill)
|
||||
{
|
||||
var color = HEXtoRGB(graphicsData.fillColor);
|
||||
var color = hex2rgb(graphicsData.fillColor);
|
||||
var alpha = graphicsData.fillAlpha;
|
||||
|
||||
var r = color[0] * alpha;
|
||||
|
@ -221,10 +221,11 @@ PIXI.WebGLGraphics.buildCircle = function(graphicsData, webGLData)
|
|||
|
||||
var totalSegs = 40;
|
||||
var seg = (Math.PI * 2) / totalSegs ;
|
||||
var i;
|
||||
|
||||
if(graphicsData.fill)
|
||||
if (graphicsData.fill)
|
||||
{
|
||||
var color = HEXtoRGB(graphicsData.fillColor);
|
||||
var color = hex2rgb(graphicsData.fillColor);
|
||||
var alpha = graphicsData.fillAlpha;
|
||||
|
||||
var r = color[0] * alpha;
|
||||
|
@ -238,7 +239,7 @@ PIXI.WebGLGraphics.buildCircle = function(graphicsData, webGLData)
|
|||
|
||||
indices.push(vecPos);
|
||||
|
||||
for (var i=0; i < totalSegs + 1 ; i++)
|
||||
for (i = 0; i < totalSegs + 1 ; i++)
|
||||
{
|
||||
verts.push(x,y, r, g, b, alpha);
|
||||
|
||||
|
@ -247,20 +248,20 @@ PIXI.WebGLGraphics.buildCircle = function(graphicsData, webGLData)
|
|||
r, g, b, alpha);
|
||||
|
||||
indices.push(vecPos++, vecPos++);
|
||||
};
|
||||
}
|
||||
|
||||
indices.push(vecPos-1);
|
||||
}
|
||||
|
||||
if(graphicsData.lineWidth)
|
||||
if (graphicsData.lineWidth)
|
||||
{
|
||||
graphicsData.points = [];
|
||||
|
||||
for (var i=0; i < totalSegs + 1; i++)
|
||||
for (i = 0; i < totalSegs + 1; i++)
|
||||
{
|
||||
graphicsData.points.push(x + Math.sin(seg * i) * width,
|
||||
y + Math.cos(seg * i) * height)
|
||||
};
|
||||
}
|
||||
|
||||
PIXI.WebGLGraphics.buildLine(graphicsData, webGLData);
|
||||
}
|
||||
|
@ -282,14 +283,14 @@ PIXI.WebGLGraphics.buildLine = function(graphicsData, webGLData)
|
|||
|
||||
var wrap = true;
|
||||
var points = graphicsData.points;
|
||||
if(points.length == 0)return;
|
||||
if (points.length === 0) return;
|
||||
|
||||
// get first and last point.. figure out the middle!
|
||||
var firstPoint = new PIXI.Point( points[0], points[1] );
|
||||
var lastPoint = new PIXI.Point( points[points.length - 2], points[points.length - 1] );
|
||||
|
||||
// if the first point is the last point - goona have issues :)
|
||||
if(firstPoint.x == lastPoint.x && firstPoint.y == lastPoint.y)
|
||||
if (firstPoint.x == lastPoint.x && firstPoint.y == lastPoint.y)
|
||||
{
|
||||
points.pop();
|
||||
points.pop();
|
||||
|
@ -313,7 +314,7 @@ PIXI.WebGLGraphics.buildLine = function(graphicsData, webGLData)
|
|||
var width = graphicsData.lineWidth / 2;
|
||||
|
||||
// sort color
|
||||
var color = HEXtoRGB(graphicsData.lineColor);
|
||||
var color = hex2rgb(graphicsData.lineColor);
|
||||
var alpha = graphicsData.lineAlpha;
|
||||
var r = color[0] * alpha;
|
||||
var g = color[1] * alpha;
|
||||
|
@ -386,7 +387,7 @@ PIXI.WebGLGraphics.buildLine = function(graphicsData, webGLData)
|
|||
|
||||
denom = a1*b2 - a2*b1;
|
||||
|
||||
if (denom == 0) {
|
||||
if (denom === 0) {
|
||||
denom+=1;
|
||||
}
|
||||
|
||||
|
@ -450,10 +451,10 @@ PIXI.WebGLGraphics.buildLine = function(graphicsData, webGLData)
|
|||
|
||||
indices.push(indexStart);
|
||||
|
||||
for (var i=0; i < indexCount; i++)
|
||||
for (i = 0; i < indexCount; i++)
|
||||
{
|
||||
indices.push(indexStart++);
|
||||
};
|
||||
}
|
||||
|
||||
indices.push(indexStart-1);
|
||||
}
|
||||
|
@ -470,45 +471,36 @@ PIXI.WebGLGraphics.buildLine = function(graphicsData, webGLData)
|
|||
PIXI.WebGLGraphics.buildPoly = function(graphicsData, webGLData)
|
||||
{
|
||||
var points = graphicsData.points;
|
||||
if(points.length < 6)return;
|
||||
if (points.length < 6) return;
|
||||
|
||||
// get first and last point.. figure out the middle!
|
||||
var verts = webGLData.points;
|
||||
var indices = webGLData.indices;
|
||||
|
||||
var length = points.length / 2;
|
||||
|
||||
// sort color
|
||||
var color = HEXtoRGB(graphicsData.fillColor);
|
||||
var alpha = graphicsData.fillAlpha;
|
||||
var r = color[0] * alpha;
|
||||
var g = color[1] * alpha;
|
||||
var b = color[2] * alpha;
|
||||
|
||||
var triangles = PIXI.PolyK.Triangulate(points);
|
||||
|
||||
var vertPos = verts.length / 6;
|
||||
|
||||
for (var i=0; i < triangles.length; i+=3)
|
||||
for (var i = 0, l = triangles.length; i < l; i+=3)
|
||||
{
|
||||
indices.push(triangles[i] + vertPos);
|
||||
indices.push(triangles[i] + vertPos);
|
||||
indices.push(triangles[i+1] + vertPos);
|
||||
indices.push(triangles[i+2] +vertPos);
|
||||
indices.push(triangles[i+2] + vertPos);
|
||||
};
|
||||
}
|
||||
|
||||
for (var i = 0; i < length; i++)
|
||||
// sort color
|
||||
var color = hex2rgb(graphicsData.fillColor);
|
||||
var alpha = graphicsData.fillAlpha;
|
||||
var r = color[0] * alpha;
|
||||
var g = color[1] * alpha;
|
||||
var b = color[2] * alpha;
|
||||
|
||||
for (i = 0, l = points.length / 2; i < l; i++)
|
||||
{
|
||||
verts.push(points[i * 2], points[i * 2 + 1],
|
||||
r, g, b, alpha);
|
||||
};
|
||||
}
|
||||
|
||||
function HEXtoRGB(hex) {
|
||||
return [(hex >> 16 & 0xFF) / 255, ( hex >> 8 & 0xFF) / 255, (hex & 0xFF)/ 255];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -18,9 +18,8 @@
|
|||
PIXI.WebGLRenderGroup = function(gl)
|
||||
{
|
||||
this.gl = gl;
|
||||
this.root;
|
||||
|
||||
this.backgroundColor;
|
||||
this.root = null;
|
||||
// this.backgroundColor = null;
|
||||
this.batchs = [];
|
||||
this.toRemove = [];
|
||||
}
|
||||
|
@ -153,11 +152,9 @@ PIXI.WebGLRenderGroup.prototype.renderSpecific = function(displayObject, project
|
|||
// to do!
|
||||
// render part of the scene...
|
||||
|
||||
var startIndex;
|
||||
var startBatchIndex;
|
||||
|
||||
var endIndex;
|
||||
var endBatchIndex;
|
||||
var startIndex, startBatchIndex,
|
||||
endIndex, endBatchIndex,
|
||||
head, next;
|
||||
|
||||
/*
|
||||
* LOOK FOR THE NEXT SPRITE
|
||||
|
@ -177,8 +174,8 @@ PIXI.WebGLRenderGroup.prototype.renderSpecific = function(displayObject, project
|
|||
{
|
||||
startBatch = nextRenderable.batch;
|
||||
|
||||
var head = startBatch.head;
|
||||
var next = head;
|
||||
head = startBatch.head;
|
||||
next = head;
|
||||
|
||||
// ok now we have the batch.. need to find the start index!
|
||||
if(head == nextRenderable)
|
||||
|
@ -215,7 +212,7 @@ PIXI.WebGLRenderGroup.prototype.renderSpecific = function(displayObject, project
|
|||
{
|
||||
endBatch = lastRenderable.batch;
|
||||
|
||||
var head = endBatch.head;
|
||||
head = endBatch.head;
|
||||
|
||||
if(head == lastRenderable)
|
||||
{
|
||||
|
@ -537,8 +534,9 @@ PIXI.WebGLRenderGroup.prototype.removeDisplayObjectAndChildren = function(displa
|
|||
PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousObject, nextObject)
|
||||
{
|
||||
// while looping below THE OBJECT MAY NOT HAVE BEEN ADDED
|
||||
var previousSprite = previousObject;
|
||||
var nextSprite = nextObject;
|
||||
var previousSprite = previousObject,
|
||||
nextSprite = nextObject,
|
||||
batch, index;
|
||||
|
||||
/*
|
||||
* so now we have the next renderable and the previous renderable
|
||||
|
@ -546,8 +544,7 @@ PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousO
|
|||
*/
|
||||
if(displayObject instanceof PIXI.Sprite)
|
||||
{
|
||||
var previousBatch
|
||||
var nextBatch
|
||||
var previousBatch, nextBatch;
|
||||
|
||||
if(previousSprite instanceof PIXI.Sprite)
|
||||
{
|
||||
|
@ -594,11 +591,11 @@ PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousO
|
|||
* seems the new sprite is in the middle of a batch
|
||||
* lets split it..
|
||||
*/
|
||||
var batch = PIXI.WebGLRenderer.getBatch();
|
||||
batch = PIXI.WebGLRenderer.getBatch();
|
||||
|
||||
var index = this.batchs.indexOf( previousBatch );
|
||||
index = this.batchs.indexOf( previousBatch );
|
||||
batch.init(displayObject);
|
||||
this.batchs.splice(index+1, 0, batch, splitBatch);
|
||||
this.batchs.splice(index + 1, 0, batch, splitBatch);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -619,13 +616,13 @@ PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousO
|
|||
* time to create anew one!
|
||||
*/
|
||||
|
||||
var batch = PIXI.WebGLRenderer.getBatch();
|
||||
batch = PIXI.WebGLRenderer.getBatch();
|
||||
batch.init(displayObject);
|
||||
|
||||
if(previousBatch) // if this is invalid it means
|
||||
{
|
||||
var index = this.batchs.indexOf( previousBatch );
|
||||
this.batchs.splice(index+1, 0, batch);
|
||||
index = this.batchs.indexOf( previousBatch );
|
||||
this.batchs.splice(index + 1, 0, batch);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -648,14 +645,14 @@ PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousO
|
|||
this.initStrip(displayObject);
|
||||
// this.batchs.push(displayObject);
|
||||
}
|
||||
else if(displayObject)// instanceof PIXI.Graphics)
|
||||
/*else if(displayObject)// instanceof PIXI.Graphics)
|
||||
{
|
||||
//displayObject.initWebGL(this);
|
||||
|
||||
// add to a batch!!
|
||||
//this.initStrip(displayObject);
|
||||
//this.batchs.push(displayObject);
|
||||
}
|
||||
}*/
|
||||
|
||||
this.insertAfter(displayObject, previousSprite);
|
||||
|
||||
|
@ -673,9 +670,11 @@ PIXI.WebGLRenderGroup.prototype.insertObject = function(displayObject, previousO
|
|||
*/
|
||||
PIXI.WebGLRenderGroup.prototype.insertAfter = function(item, displayObject)
|
||||
{
|
||||
var previousBatch, splitBatch, index;
|
||||
|
||||
if(displayObject instanceof PIXI.Sprite)
|
||||
{
|
||||
var previousBatch = displayObject.batch;
|
||||
previousBatch = displayObject.batch;
|
||||
|
||||
if(previousBatch)
|
||||
{
|
||||
|
@ -685,7 +684,7 @@ PIXI.WebGLRenderGroup.prototype.insertAfter = function(item, displayObject)
|
|||
if(previousBatch.tail == displayObject)
|
||||
{
|
||||
// is it tail? insert in to batchs
|
||||
var index = this.batchs.indexOf( previousBatch );
|
||||
index = this.batchs.indexOf( previousBatch );
|
||||
this.batchs.splice(index+1, 0, item);
|
||||
}
|
||||
else
|
||||
|
@ -693,7 +692,7 @@ PIXI.WebGLRenderGroup.prototype.insertAfter = function(item, displayObject)
|
|||
// TODO MODIFY ADD / REMOVE CHILD TO ACCOUNT FOR FILTERS (also get prev and next) //
|
||||
|
||||
// THERE IS A SPLIT IN THIS BATCH! //
|
||||
var splitBatch = previousBatch.split(displayObject.__next);
|
||||
splitBatch = previousBatch.split(displayObject.__next);
|
||||
|
||||
// COOL!
|
||||
// add it back into the array
|
||||
|
@ -702,8 +701,8 @@ PIXI.WebGLRenderGroup.prototype.insertAfter = function(item, displayObject)
|
|||
* seems the new sprite is in the middle of a batch
|
||||
* lets split it..
|
||||
*/
|
||||
var index = this.batchs.indexOf( previousBatch );
|
||||
this.batchs.splice(index+1, 0, item, splitBatch);
|
||||
index = this.batchs.indexOf( previousBatch );
|
||||
this.batchs.splice(index + 1, 0, item, splitBatch);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -713,8 +712,8 @@ PIXI.WebGLRenderGroup.prototype.insertAfter = function(item, displayObject)
|
|||
}
|
||||
else
|
||||
{
|
||||
var index = this.batchs.indexOf( displayObject );
|
||||
this.batchs.splice(index+1, 0, item);
|
||||
index = this.batchs.indexOf( displayObject );
|
||||
this.batchs.splice(index + 1, 0, item);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -738,9 +737,9 @@ PIXI.WebGLRenderGroup.prototype.removeObject = function(displayObject)
|
|||
* removing is a lot quicker..
|
||||
*
|
||||
*/
|
||||
var batchToRemove;
|
||||
var batchToRemove, index;
|
||||
|
||||
if(displayObject instanceof PIXI.Sprite)
|
||||
if (displayObject instanceof PIXI.Sprite)
|
||||
{
|
||||
// should always have a batch!
|
||||
var batch = displayObject.batch;
|
||||
|
@ -748,7 +747,7 @@ PIXI.WebGLRenderGroup.prototype.removeObject = function(displayObject)
|
|||
|
||||
batch.remove(displayObject);
|
||||
|
||||
if(batch.size==0)
|
||||
if (!batch.size)
|
||||
{
|
||||
batchToRemove = batch;
|
||||
}
|
||||
|
@ -763,12 +762,12 @@ PIXI.WebGLRenderGroup.prototype.removeObject = function(displayObject)
|
|||
*/
|
||||
if(batchToRemove)
|
||||
{
|
||||
var index = this.batchs.indexOf( batchToRemove );
|
||||
if(index == -1)return;// this means it was added then removed before rendered
|
||||
index = this.batchs.indexOf( batchToRemove );
|
||||
if (index === -1) return;// this means it was added then removed before rendered
|
||||
|
||||
// ok so.. check to see if you adjacent batchs should be joined.
|
||||
// TODO may optimise?
|
||||
if(index == 0 || index == this.batchs.length-1)
|
||||
if (index === 0 || index === this.batchs.length - 1)
|
||||
{
|
||||
// wha - eva! just get of the empty batch!
|
||||
this.batchs.splice(index, 1);
|
||||
|
@ -777,15 +776,15 @@ PIXI.WebGLRenderGroup.prototype.removeObject = function(displayObject)
|
|||
return;
|
||||
}
|
||||
|
||||
if(this.batchs[index-1] instanceof PIXI.WebGLBatch && this.batchs[index+1] instanceof PIXI.WebGLBatch)
|
||||
if(this.batchs[index - 1] instanceof PIXI.WebGLBatch && this.batchs[index + 1] instanceof PIXI.WebGLBatch)
|
||||
{
|
||||
if(this.batchs[index-1].texture == this.batchs[index+1].texture && this.batchs[index-1].blendMode == this.batchs[index+1].blendMode)
|
||||
if(this.batchs[index - 1].texture == this.batchs[index + 1].texture && this.batchs[index - 1].blendMode == this.batchs[index + 1].blendMode)
|
||||
{
|
||||
//console.log("MERGE")
|
||||
this.batchs[index-1].merge(this.batchs[index+1]);
|
||||
this.batchs[index - 1].merge(this.batchs[index + 1]);
|
||||
|
||||
if(batchToRemove instanceof PIXI.WebGLBatch)PIXI.WebGLRenderer.returnBatch(batchToRemove);
|
||||
PIXI.WebGLRenderer.returnBatch(this.batchs[index+1]);
|
||||
PIXI.WebGLRenderer.returnBatch(this.batchs[index + 1]);
|
||||
this.batchs.splice(index, 2);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ PIXI._defaultFrame = new PIXI.Rectangle(0,0,1,1);
|
|||
|
||||
// an instance of the gl context..
|
||||
// only one at the moment :/
|
||||
PIXI.gl;
|
||||
PIXI.gl = null;
|
||||
|
||||
/**
|
||||
* the WebGLRenderer is draws the stage and all its content onto a webGL enabled canvas. This renderer
|
||||
|
@ -94,7 +94,7 @@ PIXI.WebGLRenderer.prototype.constructor = PIXI.WebGLRenderer;
|
|||
*/
|
||||
PIXI.WebGLRenderer.getBatch = function()
|
||||
{
|
||||
if(PIXI._batchs.length == 0)
|
||||
if(!PIXI._batchs.length)
|
||||
{
|
||||
return new PIXI.WebGLBatch(PIXI.WebGLRenderer.gl);
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ PIXI.WebGLRenderer.prototype.render = function(stage)
|
|||
|
||||
// HACK TO TEST
|
||||
|
||||
this.stageRenderGroup.backgroundColor = stage.backgroundColorSplit;
|
||||
// this.stageRenderGroup.backgroundColor = stage.backgroundColorSplit;
|
||||
this.stageRenderGroup.render(PIXI.projection);
|
||||
|
||||
// interaction
|
||||
|
@ -185,10 +185,10 @@ PIXI.WebGLRenderer.prototype.render = function(stage)
|
|||
// after rendering lets confirm all frames that have been uodated..
|
||||
if(PIXI.Texture.frameUpdates.length > 0)
|
||||
{
|
||||
for (var i=0; i < PIXI.Texture.frameUpdates.length; i++)
|
||||
for (var i = 0, l = PIXI.Texture.frameUpdates.length; i < l; i++)
|
||||
{
|
||||
PIXI.Texture.frameUpdates[i].updateFrame = false;
|
||||
};
|
||||
}
|
||||
|
||||
PIXI.Texture.frameUpdates = [];
|
||||
}
|
||||
|
@ -204,8 +204,10 @@ PIXI.WebGLRenderer.prototype.render = function(stage)
|
|||
PIXI.WebGLRenderer.updateTextures = function()
|
||||
{
|
||||
//TODO break this out into a texture manager...
|
||||
for (var i=0; i < PIXI.texturesToUpdate.length; i++) PIXI.WebGLRenderer.updateTexture(PIXI.texturesToUpdate[i]);
|
||||
for (var i=0; i < PIXI.texturesToDestroy.length; i++) PIXI.WebGLRenderer.destroyTexture(PIXI.texturesToDestroy[i]);
|
||||
for (var i = 0, l = PIXI.texturesToUpdate.length; i < l; i++)
|
||||
PIXI.WebGLRenderer.updateTexture(PIXI.texturesToUpdate[i]);
|
||||
for (i = 0, l = PIXI.texturesToDestroy.length; i < l; i++)
|
||||
PIXI.WebGLRenderer.destroyTexture(PIXI.texturesToDestroy[i]);
|
||||
PIXI.texturesToUpdate = [];
|
||||
PIXI.texturesToDestroy = [];
|
||||
}
|
||||
|
@ -334,13 +336,13 @@ PIXI.WebGLRenderer.prototype.handleContextRestored = function(event)
|
|||
var texture = PIXI.TextureCache[key].baseTexture;
|
||||
texture._glTexture = null;
|
||||
PIXI.WebGLRenderer.updateTexture(texture);
|
||||
};
|
||||
}
|
||||
|
||||
for (var i=0; i < this.batchs.length; i++)
|
||||
for (var i = 0, l = this.batchs.length; i < l; i++)
|
||||
{
|
||||
this.batchs[i].restoreLostContext(this.gl)//
|
||||
this.batchs[i].dirty = true;
|
||||
};
|
||||
}
|
||||
|
||||
PIXI._restoreBatchs(this.gl);
|
||||
|
||||
|
|
|
@ -223,7 +223,7 @@ PIXI.Text.prototype.determineFontHeight = function(fontStyle)
|
|||
PIXI.Text.prototype.wordWrap = function(text)
|
||||
{
|
||||
// search good wrap position
|
||||
var searchWrapPos = function(ctx, text, start, end, wrapWidth)
|
||||
function searchWrapPos(ctx, text, start, end, wrapWidth)
|
||||
{
|
||||
var p = Math.floor((end-start) / 2) + start;
|
||||
if(p == start) {
|
||||
|
@ -238,24 +238,24 @@ PIXI.Text.prototype.wordWrap = function(text)
|
|||
}
|
||||
else
|
||||
{
|
||||
return arguments.callee(ctx, text, p, end, wrapWidth);
|
||||
return searchWrapPos(ctx, text, p, end, wrapWidth);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return arguments.callee(ctx, text, start, p, wrapWidth);
|
||||
return searchWrapPos(ctx, text, start, p, wrapWidth);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var lineWrap = function(ctx, text, wrapWidth)
|
||||
function lineWrap(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);
|
||||
};
|
||||
return text.substring(0, pos) + "\n" + lineWrap(ctx, text.substring(pos), wrapWidth);
|
||||
}
|
||||
|
||||
var result = "";
|
||||
var lines = text.split("\n");
|
||||
|
|
|
@ -50,7 +50,7 @@ PIXI.PolyK.Triangulate = function(p)
|
|||
var avl = [];
|
||||
for(var i=0; i<n; i++) avl.push(i);
|
||||
|
||||
var i = 0;
|
||||
i = 0;
|
||||
var al = n;
|
||||
while(al > 3)
|
||||
{
|
||||
|
@ -86,9 +86,9 @@ PIXI.PolyK.Triangulate = function(p)
|
|||
// reset!
|
||||
if(sign)
|
||||
{
|
||||
var tgs = [];
|
||||
tgs = [];
|
||||
avl = [];
|
||||
for(var i=0; i<n; i++) avl.push(i);
|
||||
for(i=0; i<n; i++) avl.push(i);
|
||||
|
||||
i = 0;
|
||||
al = n;
|
||||
|
|
|
@ -19,8 +19,8 @@ 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'];
|
||||
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] ||
|
||||
window[vendors[x]+'CancelRequestAnimationFrame'];
|
||||
}
|
||||
|
||||
if (!window.requestAnimationFrame)
|
||||
|
@ -43,10 +43,10 @@ window.requestAnimFrame = window.requestAnimationFrame;
|
|||
/**
|
||||
* Converts a hex color number to an [R, G, B] array
|
||||
*
|
||||
* @method HEXtoRGB
|
||||
* @method hex2rgb
|
||||
* @param hex {Number}
|
||||
*/
|
||||
function HEXtoRGB(hex) {
|
||||
function hex2rgb(hex) {
|
||||
return [(hex >> 16 & 0xFF) / 255, ( hex >> 8 & 0xFF) / 255, (hex & 0xFF)/ 255];
|
||||
}
|
||||
|
||||
|
@ -69,8 +69,8 @@ if (typeof Function.prototype.bind != 'function') {
|
|||
}
|
||||
|
||||
bound.prototype = (function F(proto) {
|
||||
proto && (F.prototype = proto);
|
||||
if (!(this instanceof F)) return new F;
|
||||
if (proto) F.prototype = proto;
|
||||
if (!(this instanceof F)) return new F();
|
||||
})(target.prototype);
|
||||
|
||||
return bound;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue