diff --git a/angry-birds/.gitattributes b/angry-birds/.gitattributes new file mode 100644 index 000000000..bdb0cabc8 --- /dev/null +++ b/angry-birds/.gitattributes @@ -0,0 +1,17 @@ +# Auto detect text files and perform LF normalization +* text=auto + +# Custom for Visual Studio +*.cs diff=csharp + +# Standard to msysgit +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain diff --git a/angry-birds/.gitignore b/angry-birds/.gitignore new file mode 100644 index 000000000..cd2946ad7 --- /dev/null +++ b/angry-birds/.gitignore @@ -0,0 +1,47 @@ +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# ========================= +# Operating System Files +# ========================= + +# OSX +# ========================= + +.DS_Store +.AppleDouble +.LSOverride + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk diff --git a/angry-birds/Licence.md b/angry-birds/Licence.md new file mode 100644 index 000000000..f7ba9dafb --- /dev/null +++ b/angry-birds/Licence.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 tonikolaba + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/angry-birds/README.md b/angry-birds/README.md new file mode 100644 index 000000000..a01780b2f --- /dev/null +++ b/angry-birds/README.md @@ -0,0 +1,13 @@ +# AngryBirds +------------------------------------------------- +Angry Birds :anger: :bird: Game using JavaScript. + +# Contributors + +#### Authors: + +* ![Mahdi7s](https://github.com/Mahdi7s) + +* ![tonikolaba](https://github.com/tonikolaba) + +![Alt text](https://github.com/tonikolaba/download/blob/master/info/artofsoullogoVOG.png?raw=true"ArtofSoul") diff --git a/angry-birds/index.html b/angry-birds/index.html new file mode 100644 index 000000000..cc9dc739e --- /dev/null +++ b/angry-birds/index.html @@ -0,0 +1,21 @@ + + + + + + Simple Angry Birds + + + + + + +

Use a better browser !

+
+ + diff --git a/angry-birds/js/b2.js b/angry-birds/js/b2.js new file mode 100644 index 000000000..7b32d1ea7 --- /dev/null +++ b/angry-birds/js/b2.js @@ -0,0 +1,269 @@ +// Author: www.mahdi7s.com + +var MathH = { + clamp: function (num, min, max) { + return Math.min(max, Math.max(num, min)); + } +}; + +var BodyUserData = function (objectRoll, fullHealth) { + var self = this, + currentHealth = fullHealth; + + this.isDead = false; + this.isContacted = false; + this.getObjectRoll = function () { + return objectRoll; + }; + this.getFullHealth = function () { + return fullHealth; + }; + this.getHealth = function () { + return self.currentHealth; + }; + this.damage = function (impulse) { + this.isDead = ((currentHealth -= impulse) <= 0); + }; +} + +var GameObjectRoll = { + Enemy: "ENEMY!", + Wood: "Wood!", + Bird: "BIRD!" +}; +Object.freeze(GameObjectRoll); // So it's like an enum + +var b2Body = Box2D.Dynamics.b2Body, + b2BodyDef = Box2D.Dynamics.b2BodyDef, + b2FixtureDef = Box2D.Dynamics.b2FixtureDef, + b2CircleShape = Box2D.Collision.Shapes.b2CircleShape, + b2EdgeChainDef = Box2D.Collision.Shapes.b2EdgeChainDef, + b2EdgeShape = Box2D.Collision.Shapes.b2EdgeShape, + b2MassData = Box2D.Collision.Shapes.b2MassData, + b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape, + b2Shape = Box2D.Collision.Shapes.b2Shape, + b2Color = Box2D.Common.b2Color, + b2internal = Box2D.Common.b2internal, + b2Settings = Box2D.Common.b2Settings, + b2Mat22 = Box2D.Common.Math.b2Mat22, + b2Mat33 = Box2D.Common.Math.b2Mat33, + b2Math = Box2D.Common.Math.b2Math, + b2Sweep = Box2D.Common.Math.b2Sweep, + b2Transform = Box2D.Common.Math.b2Transform, + b2Vec2 = Box2D.Common.Math.b2Vec2, + b2Vec3 = Box2D.Common.Math.b2Vec3, + b2AABB = Box2D.Collision.b2AABB, + b2Bound = Box2D.Collision.b2Bound, + b2BoundValues = Box2D.Collision.b2BoundValues, + b2Collision = Box2D.Collision.b2Collision, + b2ContactID = Box2D.Collision.b2ContactID, + b2ContactPoint = Box2D.Collision.b2ContactPoint, + b2ContactListener = Box2D.Dynamics.b2ContactListener, + b2Distance = Box2D.Collision.b2Distance, + b2DistanceInput = Box2D.Collision.b2DistanceInput, + b2DistanceOutput = Box2D.Collision.b2DistanceOutput, + b2DistanceProxy = Box2D.Collision.b2DistanceProxy, + b2DynamicTree = Box2D.Collision.b2DynamicTree, + b2DynamicTreeBroadPhase = Box2D.Collision.b2DynamicTreeBroadPhase, + b2DynamicTreeNode = Box2D.Collision.b2DynamicTreeNode, + b2DynamicTreePair = Box2D.Collision.b2DynamicTreePair, + b2DebugDraw = Box2D.Dynamics.b2DebugDraw, + b2Manifold = Box2D.Collision.b2Manifold, + b2ManifoldPoint = Box2D.Collision.b2ManifoldPoint, + b2Point = Box2D.Collision.b2Point, + b2RayCastInput = Box2D.Collision.b2RayCastInput, + b2RayCastOutput = Box2D.Collision.b2RayCastOutput, + b2Segment = Box2D.Collision.b2Segment, + b2SeparationFunction = Box2D.Collision.b2SeparationFunction, + b2Simplex = Box2D.Collision.b2Simplex, + b2SimplexCache = Box2D.Collision.b2SimplexCache, + b2SimplexVertex = Box2D.Collision.b2SimplexVertex, + b2TimeOfImpact = Box2D.Collision.b2TimeOfImpact, + b2TOIInput = Box2D.Collision.b2TOIInput, + b2World = Box2D.Dynamics.b2World, + b2WorldManifold = Box2D.Collision.b2WorldManifold, + ClipVertex = Box2D.Collision.ClipVertex, + Features = Box2D.Collision.Features, + IBroadPhase = Box2D.Collision.IBroadPhase; + +var b2 = (function () { + var self = this, + deadsCount = 0, + userScore = 0, + world, + enableDebugDraw = false, + bodies = [], + PTMRatio = 30.0, + toWorld = function (n) { + return n / PTMRatio; + }, + toScreen = function (n) { + return n * PTMRatio; + }, + b2AngleToCCRotation = function (n) { + return (-1 * cc.RADIANS_TO_DEGREES(n)); + }, + CCRotationToB2Angle = function (n) { + return cc.DEGREES_TO_RADIANS(-1 * n); + }; + + var contactListener = new b2ContactListener(); + contactListener.BeginContact = function (contact) { + var bodyA = contact.GetFixtureA() + .GetBody(), + bodyB = contact.GetFixtureB() + .GetBody(), + bAData = bodyA.GetUserData(), + bBData = bodyB.GetUserData(); + + var setContacted = function (data) { + data && (data.isContacted = true); + }; + + setContacted(bAData); + setContacted(bBData); + }; + contactListener.EndContact = function (contact) {}; + contactListener.PreSolve = function (contact, oldManifold) {}; + contactListener.PostSolve = function (contact, impulse) { + var bodyA = contact.GetFixtureA() + .GetBody(), + bodyB = contact.GetFixtureB() + .GetBody(), + bAData = bodyA.GetUserData(), + bBData = bodyB.GetUserData(); + + var imp0 = impulse.normalImpulses[0]; + if (imp0 <= 2) return; // prevent little impulses + + var damage = function (bodyData) { + if (!bodyData || (bodyData.getHealth() == bodyData.getFullHealth() && imp0 < 12)) return; + + var objRoll = bodyData.getObjectRoll(); + if (objRoll === GameObjectRoll.Enemy || objRoll === GameObjectRoll.Wood /**/ ) { + bodyData.damage(imp0); + } + }; + + damage(bAData); + damage(bBData); + }; + + return { + toWorld: function (n) { + return toWorld(n); + }, + toScreen: function (n) { + return toScreen(n); + }, + initWorld: function () { + deadsCount = userScore = 0; + world = new b2World(new b2Vec2(0, - 10), true); + world.SetContinuousPhysics(true); + world.SetContactListener(contactListener); + bodies = []; + }, + getUserScore: function () { + return userScore; + }, + enablePhysicsFor: function (desc) { + var bodyDef = new b2BodyDef(), + scale = { + x: desc.sprite.getScaleX(), + y: desc.sprite.getScaleY() + }, + anch = desc.sprite.getAnchorPointInPoints(), + anchPoint = cc.p(anch.x * scale.x, anch.y * scale.y), + position = desc.sprite.getPosition(), + contentSize = desc.sprite.getContentSize(), + size = { + width: contentSize.width * scale.x, + height: contentSize.height * scale.y + }, + center = cc.p(position.x - anchPoint.x + size.width / 2, position.y - anchPoint.y + size.height / 2); + + bodyDef.type = desc.type === "static" ? b2Body.b2_staticBody : desc.type === "dynamic" ? b2Body.b2_dynamicBody : b2Body.b2_kinematicBody; + + bodyDef.position.Set(toWorld(center.x), toWorld(center.y)); + bodyDef.angle = CCRotationToB2Angle(desc.sprite.getRotation()); + + var fixDef = new b2FixtureDef(); + switch (desc.shape) { + case "circle": + fixDef.shape = new b2CircleShape(toWorld(desc.radius || (size.height / 2))); + break; + case "box": + fixDef.shape = new b2PolygonShape(); + fixDef.shape.SetAsBox(toWorld(size.width) / 2, toWorld(size.height) / 2); + break; + } + + fixDef.density = desc.density || 1; + fixDef.friction = desc.friction || 0.5; + fixDef.restitution = desc.restitution || 0.1; + + var body = world.CreateBody(bodyDef); + body.CreateFixture(fixDef); + + desc.userData && body.SetUserData(desc.userData); + + body.sprite = desc.sprite; + desc.sprite.body = body; + + bodies.push(body); + }, + simulate: function () { + world.Step(1 / 60, // fixed time step + 10, // velocity iterations + 10); // position iterations + + enableDebugDraw && world.DrawDebugData(); + + for (var i = 0; i < bodies.length; i++) { + var body = bodies[i], + bodyData = body.GetUserData(), + bPos = body.GetPosition(), + bAngle = body.GetAngle(); + + if (bodyData && bodyData.isDead) { + world.DestroyBody(body); + + userScore = (++deadsCount) * 1000; + body.sprite.runAction(cc.FadeOut.create(0.5)); + body.SetUserData(null); + + continue; + } + + var scale = { + x: body.sprite.getScaleX(), + y: body.sprite.getScaleY() + }, + anch = body.sprite.getAnchorPointInPoints(), + anchPoint = cc.p(anch.x * scale.x, anch.y * scale.y), + position = body.sprite.getPosition(), + contentSize = body.sprite.getContentSize(), + size = { + width: contentSize.width * scale.x, + height: contentSize.height * scale.y + }; + + body.sprite.setPosition(cc.p(toScreen(bPos.x) + anchPoint.x - size.width / 2, toScreen(bPos.y) + anchPoint.y - size.height / 2)); + body.sprite.setRotation(b2AngleToCCRotation(bAngle)); + } + + world.ClearForces(); + }, + debugDraw: function (enable) { + if ((enableDebugDraw = enable)) { + var debugDraw = new b2DebugDraw(); + debugDraw.SetSprite(document.getElementsByTagName("canvas")[0].getContext("2d")); + debugDraw.SetDrawScale(PTMRatio); + debugDraw.SetFillAlpha(0.5); + debugDraw.SetLineThickness(1.0); + debugDraw.SetFlags(b2DebugDraw.e_shapeBit | b2DebugDraw.e_jointBit); + world.SetDebugDraw(debugDraw); + } + } + }; +}()); \ No newline at end of file diff --git a/angry-birds/js/box2d.js b/angry-birds/js/box2d.js new file mode 100644 index 000000000..4adf24923 --- /dev/null +++ b/angry-birds/js/box2d.js @@ -0,0 +1,442 @@ +var Box2D={}; +(function(n,r){function p(){}!(Object.prototype.defineProperty instanceof Function)&&(Object.prototype.__defineGetter__ instanceof Function&&Object.prototype.__defineSetter__ instanceof Function)&&(Object.defineProperty=function(m,e,j){j.get instanceof Function&&m.__defineGetter__(e,j.get);j.set instanceof Function&&m.__defineSetter__(e,j.set)});n.inherit=function(m,e){p.prototype=e.prototype;m.prototype=new p;m.prototype.constructor=m};n.generateCallback=function(m,e){return function(){e.apply(m,arguments)}}; +n.NVector=function(m){m===r&&(m=0);for(var e=Array(m||0),j=0;jy&&(e=l,l=y,y=e,e=1),l>a&&(c.x=e,c.y=0,a=l),h=Math.min(h,y),a>h)return!1;if(uy&&(e=l,l=y,y=e,e=1),l>a&&(c.y=e,c.x=0,a=l),h=Math.min(h,y),a>h)return!1; +b.fraction=a;return!0};q.prototype.TestOverlap=function(b){var k=b.lowerBound.y-this.upperBound.y,a=this.lowerBound.y-b.upperBound.y;return 0=f&&b[v++].Set(k[0]);0>=g&&b[v++].Set(k[1]);0>f*g&&(a=f/(f-g),g=b[v],g=g.v,g.x=s.x+a*(d.x-s.x),g.y=s.y+a*(d.y-s.y),g=b[v],g.id=(0c&&(c=f,u=l);s=w.EdgeSeparation(k,a,u,h,g);f=parseInt(0<=u-1?u-1:v-1); +d=w.EdgeSeparation(k,a,f,h,g);var y=parseInt(u+1s&&d>c)m=-1,l=f,e=d;else if(c>s)m=1,l=y,e=c;else return b[0]=u,s;for(;;)if(u=-1==m?0<=l-1?l-1:v-1:l+1e)l=u,e=s;else break;b[0]=l;return e};w.FindIncidentEdge=function(b,k,a,h,g,v){void 0===h&&(h=0);parseInt(k.m_vertexCount);var s=k.m_normals,f=parseInt(g.m_vertexCount),k=g.m_vertices,g=g.m_normals,d;d=a.R;var a=s[h],s=d.col1.x*a.x+d.col2.x*a.y,u=d.col1.y* +a.x+d.col2.y*a.y;d=v.R;a=d.col1.x*s+d.col1.y*u;u=d.col2.x*s+d.col2.y*u;s=a;d=0;for(var y=Number.MAX_VALUE,c=0;cs)){var d;w.s_edgeBO[0]=0;var u=w.FindMaxSeparation(w.s_edgeBO,h,g,a,k);d=w.s_edgeBO[0];if(!(u>s)){var y=0,c=0;u>0.98*f+0.0010?(f=h,h=a,a=g,y=d,b.m_type= +B.e_faceB,c=1):(f=a,a=k,k=g,y=v,b.m_type=B.e_faceA,c=0);v=w.s_incidentEdge;w.FindIncidentEdge(v,f,a,y,h,k);d=parseInt(f.m_vertexCount);var g=f.m_vertices,f=g[y],l;l=y+1j)&&(j=w.ClipSegmentToLine(f,l,u,d),!(2>j))){b.m_localPlaneNormal.SetV(g);b.m_localPoint.SetV(h);for(h=g=0;hv*v||(b.m_type= +B.e_circles,b.m_localPoint.SetV(a.m_p),b.m_localPlaneNormal.SetZero(),b.m_pointCount=1,b.m_points[0].m_localPoint.SetV(g.m_p),b.m_points[0].m_id.key=0)};w.CollidePolygonAndCircle=function(b,a,k,h,g){var v=b.m_pointCount=0,d=0,f,s;s=g.R;f=h.m_p;var u=g.position.y+(s.col1.y*f.x+s.col2.y*f.y),v=g.position.x+(s.col1.x*f.x+s.col2.x*f.y)-k.position.x,d=u-k.position.y;s=k.R;k=v*s.col1.x+d*s.col1.y;s=v*s.col2.x+d*s.col2.y;for(var y=0,u=-Number.MAX_VALUE,g=a.m_radius+h.m_radius,c=parseInt(a.m_vertexCount), +l=a.m_vertices,a=a.m_normals,e=0;eg)return;v>u&&(u=v,y=e)}v=parseInt(y);d=parseInt(v+1=(k-f.x)*(l.x-f.x)+(s-f.y)*(l.y-f.y)?(k-f.x)*(k-f.x)+(s-f.y)*(s-f.y)>g*g||(b.m_pointCount= +1,b.m_type=B.e_faceA,b.m_localPlaneNormal.x=k-f.x,b.m_localPlaneNormal.y=s-f.y,b.m_localPlaneNormal.Normalize(),b.m_localPoint.SetV(f),b.m_points[0].m_localPoint.SetV(h.m_p),b.m_points[0].m_id.key=0):0>=u?(k-l.x)*(k-l.x)+(s-l.y)*(s-l.y)>g*g||(b.m_pointCount=1,b.m_type=B.e_faceA,b.m_localPlaneNormal.x=k-l.x,b.m_localPlaneNormal.y=s-l.y,b.m_localPlaneNormal.Normalize(),b.m_localPoint.SetV(l),b.m_points[0].m_localPoint.SetV(h.m_p),b.m_points[0].m_id.key=0):(y=0.5*(f.x+l.x),f=0.5*(f.y+l.y),u=(k-y)*a[v].x+ +(s-f)*a[v].y,u>g||(b.m_pointCount=1,b.m_type=B.e_faceA,b.m_localPlaneNormal.x=a[v].x,b.m_localPlaneNormal.y=a[v].y,b.m_localPlaneNormal.Normalize(),b.m_localPoint.Set(y,f),b.m_points[0].m_localPoint.SetV(h.m_p),b.m_points[0].m_id.key=0)))};w.TestOverlap=function(b,a){var k=a.lowerBound,g=b.upperBound,h=k.x-g.x,v=k.y-g.y,k=b.lowerBound,g=a.upperBound,f=k.y-g.y;return 0>8&255;this.features._incidentVertex=(this._key&16711680)>>16&255;this.features._flip=(this._key&4278190080)>>24&255}});t.b2ContactPoint=function(){this.position=new c;this.velocity=new c;this.normal=new c;this.id=new A};J.b2Distance=function(){};J.Distance=function(b,k,a){++J.b2_gjkCalls;var g=a.proxyA,h=a.proxyB,v=a.transformA, +f=a.transformB,d=J.s_simplex;d.ReadCache(k,g,v,h,f);var s=d.m_vertices,u=J.s_saveA,y=J.s_saveB,l=0;d.GetClosestPoint().LengthSquared();for(var z=0,j,q=0;20>q;){l=d.m_count;for(z=0;zk+h&&b.distance> +Number.MIN_VALUE?(b.distance-=k+h,a=e.SubtractVV(b.pointB,b.pointA),a.Normalize(),b.pointA.x+=k*a.x,b.pointA.y+=k*a.y,b.pointB.x-=h*a.x,b.pointB.y-=h*a.y):(j=new c,j.x=0.5*(b.pointA.x+b.pointB.x),j.y=0.5*(b.pointA.y+b.pointB.y),b.pointA.x=b.pointB.x=j.x,b.pointA.y=b.pointB.y=j.y,b.distance=0))};Box2D.postDefs.push(function(){Box2D.Collision.b2Distance.s_simplex=new h;Box2D.Collision.b2Distance.s_saveA=new Vector_a2j_Number(3);Box2D.Collision.b2Distance.s_saveB=new Vector_a2j_Number(3)});L.b2DistanceInput= +function(){};d.b2DistanceOutput=function(){this.pointA=new c;this.pointB=new c};z.b2DistanceProxy=function(){};z.prototype.Set=function(b){switch(b.GetType()){case p.e_circleShape:b=b instanceof n?b:null;this.m_vertices=new Vector(1,!0);this.m_vertices[0]=b.m_p;this.m_count=1;this.m_radius=b.m_radius;break;case p.e_polygonShape:b=b instanceof r?b:null;this.m_vertices=b.m_vertices;this.m_count=b.m_vertexCount;this.m_radius=b.m_radius;break;default:m.b2Assert(!1)}};z.prototype.GetSupport=function(b){for(var a= +0,k=this.m_vertices[0].x*b.x+this.m_vertices[0].y*b.y,g=1;gk&&(a=g,k=h)}return a};z.prototype.GetSupportVertex=function(b){for(var a=0,k=this.m_vertices[0].x*b.x+this.m_vertices[0].y*b.y,g=1;gk&&(a=g,k=h)}return this.m_vertices[a]};z.prototype.GetVertexCount=function(){return this.m_count};z.prototype.GetVertex=function(b){void 0===b&&(b=0);m.b2Assert(0<= +b&&b>g&1?k.child2:k.child1,g=g+1&31;++this.m_path;this.RemoveLeaf(k);this.InsertLeaf(k)}};l.prototype.GetFatAABB=function(b){return b.aabb};l.prototype.GetUserData=function(b){return b.userData};l.prototype.Query=function(b,k){if(null!=this.m_root){var a=new Vector,g=0;for(a[g++]=this.m_root;0=g?b:g;++k.m_pairCount;return!0},h)}for(a=k.m_moveBuffer.length=0;as){var y=h.x-this.p1.x,c=h.y-this.p1.y,h=y*a+c*d;if(0<=h&&h<=g*u&&(g=-v*c+f*y,-s*u<=g&&g<=u*(1+s)))return h/=u,g=Math.sqrt(a*a+d*d),b[0]=h,k.Set(a/g,d/g),!0}return!1};I.prototype.Extend=function(b){this.ExtendForward(b);this.ExtendBackward(b)};I.prototype.ExtendForward=function(b){var k=this.p2.x- +this.p1.x,a=this.p2.y-this.p1.y,b=Math.min(0k?(b.lowerBound.x-this.p1.x)/k:Number.POSITIVE_INFINITY,0a?(b.lowerBound.y-this.p1.y)/a:Number.POSITIVE_INFINITY);this.p2.x=this.p1.x+k*b;this.p2.y=this.p1.y+a*b};I.prototype.ExtendBackward=function(b){var k=-this.p2.x+this.p1.x,a=-this.p2.y+this.p1.y,b=Math.min(0k?(b.lowerBound.x-this.p2.x)/k:Number.POSITIVE_INFINITY,0 +a?(b.lowerBound.y-this.p2.y)/a:Number.POSITIVE_INFINITY);this.p1.x=this.p2.x+k*b;this.p1.y=this.p2.y+a*b};a.b2SeparationFunction=function(){this.m_localPoint=new c;this.m_axis=new c};a.prototype.Initialize=function(b,k,g,h,v){this.m_proxyA=k;this.m_proxyB=h;var f=parseInt(b.count);m.b2Assert(0f);var d,s,u,y,l=y=u=h=k=0,z=0,l=0;1==f?(this.m_type=a.e_points,d=this.m_proxyA.GetVertex(b.indexA[0]),s=this.m_proxyB.GetVertex(b.indexB[0]),f=d,b=g.R,k=g.position.x+(b.col1.x*f.x+b.col2.x*f.y),h=g.position.y+ +(b.col1.y*f.x+b.col2.y*f.y),f=s,b=v.R,u=v.position.x+(b.col1.x*f.x+b.col2.x*f.y),y=v.position.y+(b.col1.y*f.x+b.col2.y*f.y),this.m_axis.x=u-k,this.m_axis.y=y-h,this.m_axis.Normalize()):(b.indexB[0]==b.indexB[1]?(this.m_type=a.e_faceA,k=this.m_proxyA.GetVertex(b.indexA[0]),h=this.m_proxyA.GetVertex(b.indexA[1]),s=this.m_proxyB.GetVertex(b.indexB[0]),this.m_localPoint.x=0.5*(k.x+h.x),this.m_localPoint.y=0.5*(k.y+h.y),this.m_axis=e.CrossVF(e.SubtractVV(h,k),1),this.m_axis.Normalize(),f=this.m_axis,b= +g.R,l=b.col1.x*f.x+b.col2.x*f.y,z=b.col1.y*f.x+b.col2.y*f.y,f=this.m_localPoint,b=g.R,k=g.position.x+(b.col1.x*f.x+b.col2.x*f.y),h=g.position.y+(b.col1.y*f.x+b.col2.y*f.y),f=s,b=v.R,u=v.position.x+(b.col1.x*f.x+b.col2.x*f.y),y=v.position.y+(b.col1.y*f.x+b.col2.y*f.y),l=(u-k)*l+(y-h)*z):b.indexA[0]==b.indexA[0]?(this.m_type=a.e_faceB,u=this.m_proxyB.GetVertex(b.indexB[0]),y=this.m_proxyB.GetVertex(b.indexB[1]),d=this.m_proxyA.GetVertex(b.indexA[0]),this.m_localPoint.x=0.5*(u.x+y.x),this.m_localPoint.y= +0.5*(u.y+y.y),this.m_axis=e.CrossVF(e.SubtractVV(y,u),1),this.m_axis.Normalize(),f=this.m_axis,b=v.R,l=b.col1.x*f.x+b.col2.x*f.y,z=b.col1.y*f.x+b.col2.y*f.y,f=this.m_localPoint,b=v.R,u=v.position.x+(b.col1.x*f.x+b.col2.x*f.y),y=v.position.y+(b.col1.y*f.x+b.col2.y*f.y),f=d,b=g.R,k=g.position.x+(b.col1.x*f.x+b.col2.x*f.y),h=g.position.y+(b.col1.y*f.x+b.col2.y*f.y),l=(k-u)*l+(h-y)*z):(k=this.m_proxyA.GetVertex(b.indexA[0]),h=this.m_proxyA.GetVertex(b.indexA[1]),u=this.m_proxyB.GetVertex(b.indexB[0]), +y=this.m_proxyB.GetVertex(b.indexB[1]),e.MulX(g,d),d=e.MulMV(g.R,e.SubtractVV(h,k)),e.MulX(v,s),l=e.MulMV(v.R,e.SubtractVV(y,u)),v=d.x*d.x+d.y*d.y,s=l.x*l.x+l.y*l.y,b=e.SubtractVV(l,d),g=d.x*b.x+d.y*b.y,b=l.x*b.x+l.y*b.y,d=d.x*l.x+d.y*l.y,z=v*s-d*d,l=0,0!=z&&(l=e.Clamp((d*b-g*s)/z,0,1)),0>(d*l+b)/s&&(l=e.Clamp((d-g)/v,0,1)),d=new c,d.x=k.x+l*(h.x-k.x),d.y=k.y+l*(h.y-k.y),s=new c,s.x=u.x+l*(y.x-u.x),s.y=u.y+l*(y.y-u.y),0==l||1==l?(this.m_type=a.e_faceB,this.m_axis=e.CrossVF(e.SubtractVV(y,u),1),this.m_axis.Normalize(), +this.m_localPoint=s):(this.m_type=a.e_faceA,this.m_axis=e.CrossVF(e.SubtractVV(h,k),1),this.m_localPoint=d)),0>l&&this.m_axis.NegativeSelf())};a.prototype.Evaluate=function(b,k){var g,h,v=0;switch(this.m_type){case a.e_points:return g=e.MulTMV(b.R,this.m_axis),h=e.MulTMV(k.R,this.m_axis.GetNegative()),g=this.m_proxyA.GetSupportVertex(g),h=this.m_proxyB.GetSupportVertex(h),g=e.MulX(b,g),h=e.MulX(k,h),v=(h.x-g.x)*this.m_axis.x+(h.y-g.y)*this.m_axis.y;case a.e_faceA:return v=e.MulMV(b.R,this.m_axis), +g=e.MulX(b,this.m_localPoint),h=e.MulTMV(k.R,v.GetNegative()),h=this.m_proxyB.GetSupportVertex(h),h=e.MulX(k,h),v=(h.x-g.x)*v.x+(h.y-g.y)*v.y;case a.e_faceB:return v=e.MulMV(k.R,this.m_axis),h=e.MulX(k,this.m_localPoint),g=e.MulTMV(b.R,v.GetNegative()),g=this.m_proxyA.GetSupportVertex(g),g=e.MulX(b,g),v=(g.x-h.x)*v.x+(g.y-h.y)*v.y;default:return m.b2Assert(!1),0}};Box2D.postDefs.push(function(){Box2D.Collision.b2SeparationFunction.e_points=1;Box2D.Collision.b2SeparationFunction.e_faceA=2;Box2D.Collision.b2SeparationFunction.e_faceB= +4});h.b2Simplex=function(){this.m_v1=new g;this.m_v2=new g;this.m_v3=new g;this.m_vertices=new Vector(3)};h.prototype.b2Simplex=function(){this.m_vertices[0]=this.m_v1;this.m_vertices[1]=this.m_v2;this.m_vertices[2]=this.m_v3};h.prototype.ReadCache=function(b,k,a,g,h){m.b2Assert(0<=b.count&&3>=b.count);var v,f;this.m_count=b.count;for(var d=this.m_vertices,s=0;s=b?this.m_count=this.m_v1.a=1:(k=k.x*a.x+k.y*a.y,0>=k?(this.m_count=this.m_v2.a=1,this.m_v1.Set(this.m_v2)):(a=1/(k+b),this.m_v1.a=k*a,this.m_v2.a=b*a,this.m_count=2))};h.prototype.Solve3=function(){var b=this.m_v1.w,k=this.m_v2.w,a=this.m_v3.w,g=e.SubtractVV(k,b),h=e.Dot(b,g),v=e.Dot(k,g),h=-h,f=e.SubtractVV(a,b),d=e.Dot(b,f),s=e.Dot(a,f),d=-d,u=e.SubtractVV(a,k),y=e.Dot(k,u),u=e.Dot(a,u),y=-y,f=e.CrossVV(g,f), +g=f*e.CrossVV(k,a),a=f*e.CrossVV(a,b),b=f*e.CrossVV(b,k);0>=h&&0>=d?this.m_count=this.m_v1.a=1:0=b?(s=1/(v+h),this.m_v1.a=v*s,this.m_v2.a=h*s,this.m_count=2):0=a?(v=1/(s+d),this.m_v1.a=s*v,this.m_v3.a=d*v,this.m_count=2,this.m_v2.Set(this.m_v3)):0>=v&&0>=y?(this.m_count=this.m_v2.a=1,this.m_v1.Set(this.m_v2)):0>=s&&0>=u?(this.m_count=this.m_v3.a=1,this.m_v1.Set(this.m_v3)):0=g?(v=1/(u+y),this.m_v2.a=u*v,this.m_v3.a=y*v,this.m_count=2,this.m_v1.Set(this.m_v3)):(v=1/ +(g+a+b),this.m_v1.a=g*v,this.m_v2.a=a*v,this.m_v3.a=b*v,this.m_count=3)};s.b2SimplexCache=function(){this.indexA=new Vector_a2j_Number(3);this.indexB=new Vector_a2j_Number(3)};g.b2SimplexVertex=function(){};g.prototype.Set=function(b){this.wA.SetV(b.wA);this.wB.SetV(b.wB);this.w.SetV(b.w);this.a=b.a;this.indexA=b.indexA;this.indexB=b.indexB};u.b2TimeOfImpact=function(){};u.TimeOfImpact=function(b){++u.b2_toiCalls;var k=b.proxyA,a=b.proxyB,g=b.sweepA,h=b.sweepB;m.b2Assert(g.t0==h.t0);m.b2Assert(1- +g.t0>Number.MIN_VALUE);var v=k.m_radius+a.m_radius,b=b.tolerance,f=0,d=0,s=0;u.s_cache.count=0;for(u.s_distanceInput.useRadii=!1;;){g.GetTransform(u.s_xfA,f);h.GetTransform(u.s_xfB,f);u.s_distanceInput.proxyA=k;u.s_distanceInput.proxyB=a;u.s_distanceInput.transformA=u.s_xfA;u.s_distanceInput.transformB=u.s_xfB;J.Distance(u.s_distanceOutput,u.s_cache,u.s_distanceInput);if(0>=u.s_distanceOutput.distance){f=1;break}u.s_fcn.Initialize(u.s_cache,k,u.s_xfA,a,u.s_xfB);var y=u.s_fcn.Evaluate(u.s_xfA,u.s_xfB); +if(0>=y){f=1;break}0==d&&(s=y>v?e.Max(v-b,0.75*v):e.Max(y-b,0.02*v));if(y-s<0.5*b){if(0==d){f=1;break}break}var c=f,l=f,z=1;g.GetTransform(u.s_xfA,z);h.GetTransform(u.s_xfB,z);var j=u.s_fcn.Evaluate(u.s_xfA,u.s_xfB);if(j>=s){f=1;break}for(var q=0;;){var C=0,C=q&1?l+(s-y)*(z-l)/(j-y):0.5*(l+z);g.GetTransform(u.s_xfA,C);h.GetTransform(u.s_xfB,C);var B=u.s_fcn.Evaluate(u.s_xfA,u.s_xfB);if(e.Abs(B-s)<0.025*b){c=C;break}B>s?(l=C,y=B):(z=C,j=B);++q;++u.b2_toiRootIters;if(50==q)break}u.b2_toiMaxRootIters= +e.Max(u.b2_toiMaxRootIters,q);if(c<(1+100*Number.MIN_VALUE)*f)break;f=c;d++;++u.b2_toiIters;if(1E3==d)break}u.b2_toiMaxIters=e.Max(u.b2_toiMaxIters,d);return f};Box2D.postDefs.push(function(){Box2D.Collision.b2TimeOfImpact.b2_toiCalls=0;Box2D.Collision.b2TimeOfImpact.b2_toiIters=0;Box2D.Collision.b2TimeOfImpact.b2_toiMaxIters=0;Box2D.Collision.b2TimeOfImpact.b2_toiRootIters=0;Box2D.Collision.b2TimeOfImpact.b2_toiMaxRootIters=0;Box2D.Collision.b2TimeOfImpact.s_cache=new s;Box2D.Collision.b2TimeOfImpact.s_distanceInput= +new L;Box2D.Collision.b2TimeOfImpact.s_xfA=new x;Box2D.Collision.b2TimeOfImpact.s_xfB=new x;Box2D.Collision.b2TimeOfImpact.s_fcn=new a;Box2D.Collision.b2TimeOfImpact.s_distanceOutput=new d});y.b2TOIInput=function(){this.proxyA=new z;this.proxyB=new z;this.sweepA=new j;this.sweepB=new j};f.b2WorldManifold=function(){this.m_normal=new c};f.prototype.b2WorldManifold=function(){this.m_points=new Vector(m.b2_maxManifoldPoints);for(var b=0;bNumber.MIN_VALUE*Number.MIN_VALUE?(s=Math.sqrt(s),this.m_normal.x=f/s,this.m_normal.y=d/s):(this.m_normal.x= +1,this.m_normal.y=0);f=k+a*this.m_normal.y;g-=h*this.m_normal.y;this.m_points[0].x=0.5*(v+a*this.m_normal.x+(b-h*this.m_normal.x));this.m_points[0].y=0.5*(f+g);break;case B.e_faceA:d=k.R;f=b.m_localPlaneNormal;s=d.col1.x*f.x+d.col2.x*f.y;u=d.col1.y*f.x+d.col2.y*f.y;d=k.R;f=b.m_localPoint;y=k.position.x+d.col1.x*f.x+d.col2.x*f.y;c=k.position.y+d.col1.y*f.x+d.col2.y*f.y;this.m_normal.x=s;this.m_normal.y=u;for(v=0;vt||nthis.m_radius)return e.SetV(l),Math.PI*this.m_radius*this.m_radius;var c=this.m_radius*this.m_radius,m=j*j,j=c*(Math.asin(j/this.m_radius)+Math.PI/2)+j*Math.sqrt(c-m),c=-2/3*Math.pow(c-m,1.5)/j;e.x=l.x+d.x*c;e.y=l.y+d.y*c;return j};r.prototype.GetLocalPosition=function(){return this.m_p}; +r.prototype.SetLocalPosition=function(d){this.m_p.SetV(d)};r.prototype.GetRadius=function(){return this.m_radius};r.prototype.SetRadius=function(d){void 0===d&&(d=0);this.m_radius=d};r.prototype.b2CircleShape=function(d){void 0===d&&(d=0);this.__super.b2Shape.call(this);this.m_type=x.e_circleShape;this.m_radius=d};p.b2EdgeChainDef=function(){};p.prototype.b2EdgeChainDef=function(){this.vertexCount=0;this.isALoop=!0;this.vertices=[]};Box2D.inherit(m,Box2D.Collision.Shapes.b2Shape);m.prototype.__super= +Box2D.Collision.Shapes.b2Shape.prototype;m.b2EdgeShape=function(){Box2D.Collision.Shapes.b2Shape.b2Shape.apply(this,arguments);this.s_supportVec=new D;this.m_v1=new D;this.m_v2=new D;this.m_coreV1=new D;this.m_coreV2=new D;this.m_normal=new D;this.m_direction=new D;this.m_cornerDir1=new D;this.m_cornerDir2=new D};m.prototype.TestPoint=function(){return!1};m.prototype.RayCast=function(d,c,l){var e,j=c.p2.x-c.p1.x,m=c.p2.y-c.p1.y;e=l.R;var q=l.position.x+(e.col1.x*this.m_v1.x+e.col2.x*this.m_v1.y), +n=l.position.y+(e.col1.y*this.m_v1.x+e.col2.y*this.m_v1.y),t=l.position.y+(e.col1.y*this.m_v2.x+e.col2.y*this.m_v2.y)-n,l=-(l.position.x+(e.col1.x*this.m_v2.x+e.col2.x*this.m_v2.y)-q);e=100*Number.MIN_VALUE;var r=-(j*t+m*l);if(r>e){var q=c.p1.x-q,p=c.p1.y-n,n=q*t+p*l;if(0<=n&&n<=c.maxFraction*r&&(c=-j*p+m*q,-e*r<=c&&c<=r*(1+e)))return d.fraction=n/r,c=Math.sqrt(t*t+l*l),d.normal.x=t/c,d.normal.y=l/c,!0}return!1};m.prototype.ComputeAABB=function(d,c){var l=c.R,e=c.position.x+(l.col1.x*this.m_v1.x+ +l.col2.x*this.m_v1.y),j=c.position.y+(l.col1.y*this.m_v1.x+l.col2.y*this.m_v1.y),q=c.position.x+(l.col1.x*this.m_v2.x+l.col2.x*this.m_v2.y),l=c.position.y+(l.col1.y*this.m_v2.x+l.col2.y*this.m_v2.y);eq*c+d*l?(this.s_supportVec.x=j,this.s_supportVec.y=m):(this.s_supportVec.x=q,this.s_supportVec.y=d);return this.s_supportVec};m.prototype.b2EdgeShape=function(d,c){this.__super.b2Shape.call(this);this.m_type=x.e_edgeShape;this.m_nextEdge=this.m_prevEdge=null;this.m_v1=d;this.m_v2=c;this.m_direction.Set(this.m_v2.x-this.m_v1.x,this.m_v2.y-this.m_v1.y);this.m_length= +this.m_direction.Normalize();this.m_normal.Set(this.m_direction.y,-this.m_direction.x);this.m_coreV1.Set(-n.b2_toiSlop*(this.m_normal.x-this.m_direction.x)+this.m_v1.x,-n.b2_toiSlop*(this.m_normal.y-this.m_direction.y)+this.m_v1.y);this.m_coreV2.Set(-n.b2_toiSlop*(this.m_normal.x+this.m_direction.x)+this.m_v2.x,-n.b2_toiSlop*(this.m_normal.y+this.m_direction.y)+this.m_v2.y);this.m_cornerDir1=this.m_normal;this.m_cornerDir2.Set(-this.m_normal.x,-this.m_normal.y)};m.prototype.SetPrevEdge=function(d, +c,l,e){this.m_prevEdge=d;this.m_coreV1=c;this.m_cornerDir1=l;this.m_cornerConvex1=e};m.prototype.SetNextEdge=function(d,c,l,e){this.m_nextEdge=d;this.m_coreV2=c;this.m_cornerDir2=l;this.m_cornerConvex2=e};e.b2MassData=function(){this.mass=0;this.center=new D(0,0);this.I=0};Box2D.inherit(j,Box2D.Collision.Shapes.b2Shape);j.prototype.__super=Box2D.Collision.Shapes.b2Shape.prototype;j.b2PolygonShape=function(){Box2D.Collision.Shapes.b2Shape.b2Shape.apply(this,arguments)};j.prototype.Copy=function(){var d= +new j;d.Set(this);return d};j.prototype.Set=function(d){this.__super.Set.call(this,d);if(Box2D.is(d,j)){d=d instanceof j?d:null;this.m_centroid.SetV(d.m_centroid);this.m_vertexCount=d.m_vertexCount;this.Reserve(this.m_vertexCount);for(var c=0;cNumber.MIN_VALUE);this.m_normals[l].SetV(q.CrossVF(e, +1));this.m_normals[l].Normalize()}this.m_centroid=j.ComputeCentroid(this.m_vertices,this.m_vertexCount)};j.AsVector=function(d,c){void 0===c&&(c=0);var l=new j;l.SetAsVector(d,c);return l};j.prototype.SetAsBox=function(d,c){void 0===d&&(d=0);void 0===c&&(c=0);this.m_vertexCount=4;this.Reserve(4);this.m_vertices[0].Set(-d,-c);this.m_vertices[1].Set(d,-c);this.m_vertices[2].Set(d,c);this.m_vertices[3].Set(-d,c);this.m_normals[0].Set(0,-1);this.m_normals[1].Set(1,0);this.m_normals[2].Set(0,1);this.m_normals[3].Set(-1, +0);this.m_centroid.SetZero()};j.AsBox=function(d,c){void 0===d&&(d=0);void 0===c&&(c=0);var l=new j;l.SetAsBox(d,c);return l};j.prototype.SetAsOrientedBox=function(d,c,l,e){void 0===d&&(d=0);void 0===c&&(c=0);void 0===l&&(l=null);void 0===e&&(e=0);this.m_vertexCount=4;this.Reserve(4);this.m_vertices[0].Set(-d,-c);this.m_vertices[1].Set(d,-c);this.m_vertices[2].Set(d,c);this.m_vertices[3].Set(-d,c);this.m_normals[0].Set(0,-1);this.m_normals[1].Set(1,0);this.m_normals[2].Set(0,1);this.m_normals[3].Set(-1, +0);this.m_centroid=l;d=new K;d.position=l;d.R.Set(e);for(l=0;lm)return!1}else 0>q&&mr?q:r,n=n>e?n:e;d.lowerBound.x=j-this.m_radius; +d.lowerBound.y=m-this.m_radius;d.upperBound.x=q+this.m_radius;d.upperBound.y=n+this.m_radius};j.prototype.ComputeMass=function(d,c){void 0===c&&(c=0);if(2==this.m_vertexCount)d.center.x=0.5*(this.m_vertices[0].x+this.m_vertices[1].x),d.center.y=0.5*(this.m_vertices[0].y+this.m_vertices[1].y),d.mass=0,d.I=0;else{for(var e=0,j=0,m=0,q=0,n=1/3,t=0;te&&(c=j,e=m)}return c};j.prototype.GetSupportVertex=function(d){for(var c=0,e=this.m_vertices[0].x*d.x+this.m_vertices[0].y*d.y,j=1;je&&(c=j,e=m)}return this.m_vertices[c]};j.prototype.Validate=function(){return!1};j.prototype.b2PolygonShape=function(){this.__super.b2Shape.call(this);this.m_type=x.e_polygonShape;this.m_centroid=new D;this.m_vertices=new Vector;this.m_normals= +new Vector};j.prototype.Reserve=function(d){void 0===d&&(d=0);for(var c=parseInt(this.m_vertices.length);ca&&(a=y);g>h&&(h=g)}s=(a-r)*(h-w);s<0.95*c&&(c=s,d.R.col1.x=n,d.R.col1.y=t,d.R.col2.x=p,d.R.col2.y=A,n=0.5*(r+a),t=0.5*(w+h),p=d.R,d.center.x=q.x+(p.col1.x*n+p.col2.x*t),d.center.y=q.y+(p.col1.y*n+p.col2.y* +t),d.extents.x=0.5*(a-r),d.extents.y=0.5*(h-w))}};Box2D.postDefs.push(function(){Box2D.Collision.Shapes.b2PolygonShape.s_mat=new c});x.b2Shape=function(){};x.prototype.Copy=function(){return null};x.prototype.Set=function(d){this.m_radius=d.m_radius};x.prototype.GetType=function(){return this.m_type};x.prototype.TestPoint=function(){return!1};x.prototype.RayCast=function(){return!1};x.prototype.ComputeAABB=function(){};x.prototype.ComputeMass=function(){};x.prototype.ComputeSubmergedArea=function(){return 0}; +x.TestOverlap=function(d,c,e,j){var m=new A;m.proxyA=new J;m.proxyA.Set(d);m.proxyB=new J;m.proxyB.Set(e);m.transformA=c;m.transformB=j;m.useRadii=!0;d=new L;d.count=0;c=new t;w.Distance(c,d,m);return c.distance<10*Number.MIN_VALUE};x.prototype.b2Shape=function(){this.m_type=x.e_unknownShape;this.m_radius=n.b2_linearSlop};Box2D.postDefs.push(function(){Box2D.Collision.Shapes.b2Shape.e_unknownShape=-1;Box2D.Collision.Shapes.b2Shape.e_circleShape=0;Box2D.Collision.Shapes.b2Shape.e_polygonShape=1;Box2D.Collision.Shapes.b2Shape.e_edgeShape= +2;Box2D.Collision.Shapes.b2Shape.e_shapeTypeCount=3;Box2D.Collision.Shapes.b2Shape.e_hitCollide=1;Box2D.Collision.Shapes.b2Shape.e_missCollide=0;Box2D.Collision.Shapes.b2Shape.e_startsInsideCollide=-1})})(); +(function(){var n=Box2D.Common.b2Color,r=Box2D.Common.b2Settings,p=Box2D.Common.Math.b2Math;n.b2Color=function(){this._b=this._g=this._r=0};n.prototype.b2Color=function(m,e,j){void 0===m&&(m=0);void 0===e&&(e=0);void 0===j&&(j=0);this._r=Box2D.parseUInt(255*p.Clamp(m,0,1));this._g=Box2D.parseUInt(255*p.Clamp(e,0,1));this._b=Box2D.parseUInt(255*p.Clamp(j,0,1))};n.prototype.Set=function(m,e,j){void 0===m&&(m=0);void 0===e&&(e=0);void 0===j&&(j=0);this._r=Box2D.parseUInt(255*p.Clamp(m,0,1));this._g= +Box2D.parseUInt(255*p.Clamp(e,0,1));this._b=Box2D.parseUInt(255*p.Clamp(j,0,1))};Object.defineProperty(n.prototype,"r",{enumerable:!1,configurable:!0,set:function(m){void 0===m&&(m=0);this._r=Box2D.parseUInt(255*p.Clamp(m,0,1))}});Object.defineProperty(n.prototype,"g",{enumerable:!1,configurable:!0,set:function(m){void 0===m&&(m=0);this._g=Box2D.parseUInt(255*p.Clamp(m,0,1))}});Object.defineProperty(n.prototype,"b",{enumerable:!1,configurable:!0,set:function(m){void 0===m&&(m=0);this._b=Box2D.parseUInt(255* +p.Clamp(m,0,1))}});Object.defineProperty(n.prototype,"color",{enumerable:!1,configurable:!0,get:function(){return this._r<<16|this._g<<8|this._b}});r.b2Settings=function(){};r.b2MixFriction=function(m,e){void 0===m&&(m=0);void 0===e&&(e=0);return Math.sqrt(m*e)};r.b2MixRestitution=function(m,e){void 0===m&&(m=0);void 0===e&&(e=0);return m>e?m:e};r.b2Assert=function(m){if(!m)throw"Assertion Failed";};Box2D.postDefs.push(function(){Box2D.Common.b2Settings.VERSION="2.1alpha";Box2D.Common.b2Settings.USHRT_MAX= +65535;Box2D.Common.b2Settings.b2_pi=Math.PI;Box2D.Common.b2Settings.b2_maxManifoldPoints=2;Box2D.Common.b2Settings.b2_aabbExtension=0.1;Box2D.Common.b2Settings.b2_aabbMultiplier=2;Box2D.Common.b2Settings.b2_polygonRadius=2*r.b2_linearSlop;Box2D.Common.b2Settings.b2_linearSlop=0.0050;Box2D.Common.b2Settings.b2_angularSlop=2/180*r.b2_pi;Box2D.Common.b2Settings.b2_toiSlop=8*r.b2_linearSlop;Box2D.Common.b2Settings.b2_maxTOIContactsPerIsland=32;Box2D.Common.b2Settings.b2_maxTOIJointsPerIsland=32;Box2D.Common.b2Settings.b2_velocityThreshold= +1;Box2D.Common.b2Settings.b2_maxLinearCorrection=0.2;Box2D.Common.b2Settings.b2_maxAngularCorrection=8/180*r.b2_pi;Box2D.Common.b2Settings.b2_maxTranslation=2;Box2D.Common.b2Settings.b2_maxTranslationSquared=r.b2_maxTranslation*r.b2_maxTranslation;Box2D.Common.b2Settings.b2_maxRotation=0.5*r.b2_pi;Box2D.Common.b2Settings.b2_maxRotationSquared=r.b2_maxRotation*r.b2_maxRotation;Box2D.Common.b2Settings.b2_contactBaumgarte=0.2;Box2D.Common.b2Settings.b2_timeToSleep=0.5;Box2D.Common.b2Settings.b2_linearSleepTolerance= +0.01;Box2D.Common.b2Settings.b2_angularSleepTolerance=2/180*r.b2_pi})})(); +(function(){var n=Box2D.Common.Math.b2Mat22,r=Box2D.Common.Math.b2Mat33,p=Box2D.Common.Math.b2Math,m=Box2D.Common.Math.b2Sweep,e=Box2D.Common.Math.b2Transform,j=Box2D.Common.Math.b2Vec2,x=Box2D.Common.Math.b2Vec3;n.b2Mat22=function(){this.col1=new j;this.col2=new j};n.prototype.b2Mat22=function(){this.SetIdentity()};n.FromAngle=function(c){void 0===c&&(c=0);var e=new n;e.Set(c);return e};n.FromVV=function(c,e){var j=new n;j.SetVV(c,e);return j};n.prototype.Set=function(c){void 0===c&&(c=0);var e= +Math.cos(c),c=Math.sin(c);this.col1.x=e;this.col2.x=-c;this.col1.y=c;this.col2.y=e};n.prototype.SetVV=function(c,e){this.col1.SetV(c);this.col2.SetV(e)};n.prototype.Copy=function(){var c=new n;c.SetM(this);return c};n.prototype.SetM=function(c){this.col1.SetV(c.col1);this.col2.SetV(c.col2)};n.prototype.AddM=function(c){this.col1.x+=c.col1.x;this.col1.y+=c.col1.y;this.col2.x+=c.col2.x;this.col2.y+=c.col2.y};n.prototype.SetIdentity=function(){this.col1.x=1;this.col2.x=0;this.col1.y=0;this.col2.y=1}; +n.prototype.SetZero=function(){this.col1.x=0;this.col2.x=0;this.col1.y=0;this.col2.y=0};n.prototype.GetAngle=function(){return Math.atan2(this.col1.y,this.col1.x)};n.prototype.GetInverse=function(c){var e=this.col1.x,j=this.col2.x,m=this.col1.y,n=this.col2.y,r=e*n-j*m;0!=r&&(r=1/r);c.col1.x=r*n;c.col2.x=-r*j;c.col1.y=-r*m;c.col2.y=r*e;return c};n.prototype.Solve=function(c,e,j){void 0===e&&(e=0);void 0===j&&(j=0);var m=this.col1.x,n=this.col2.x,r=this.col1.y,t=this.col2.y,p=m*t-n*r;0!=p&&(p=1/p); +c.x=p*(t*e-n*j);c.y=p*(m*j-r*e);return c};n.prototype.Abs=function(){this.col1.Abs();this.col2.Abs()};r.b2Mat33=function(){this.col1=new x;this.col2=new x;this.col3=new x};r.prototype.b2Mat33=function(c,e,j){void 0===c&&(c=null);void 0===e&&(e=null);void 0===j&&(j=null);!c&&!e&&!j?(this.col1.SetZero(),this.col2.SetZero(),this.col3.SetZero()):(this.col1.SetV(c),this.col2.SetV(e),this.col3.SetV(j))};r.prototype.SetVVV=function(c,e,j){this.col1.SetV(c);this.col2.SetV(e);this.col3.SetV(j)};r.prototype.Copy= +function(){return new r(this.col1,this.col2,this.col3)};r.prototype.SetM=function(c){this.col1.SetV(c.col1);this.col2.SetV(c.col2);this.col3.SetV(c.col3)};r.prototype.AddM=function(c){this.col1.x+=c.col1.x;this.col1.y+=c.col1.y;this.col1.z+=c.col1.z;this.col2.x+=c.col2.x;this.col2.y+=c.col2.y;this.col2.z+=c.col2.z;this.col3.x+=c.col3.x;this.col3.y+=c.col3.y;this.col3.z+=c.col3.z};r.prototype.SetIdentity=function(){this.col1.x=1;this.col2.x=0;this.col3.x=0;this.col1.y=0;this.col2.y=1;this.col3.y=0; +this.col1.z=0;this.col2.z=0;this.col3.z=1};r.prototype.SetZero=function(){this.col1.x=0;this.col2.x=0;this.col3.x=0;this.col1.y=0;this.col2.y=0;this.col3.y=0;this.col1.z=0;this.col2.z=0;this.col3.z=0};r.prototype.Solve22=function(c,e,j){void 0===e&&(e=0);void 0===j&&(j=0);var m=this.col1.x,n=this.col2.x,r=this.col1.y,t=this.col2.y,p=m*t-n*r;0!=p&&(p=1/p);c.x=p*(t*e-n*j);c.y=p*(m*j-r*e);return c};r.prototype.Solve33=function(c,e,j,m){void 0===e&&(e=0);void 0===j&&(j=0);void 0===m&&(m=0);var n=this.col1.x, +r=this.col1.y,t=this.col1.z,p=this.col2.x,x=this.col2.y,d=this.col2.z,z=this.col3.x,l=this.col3.y,C=this.col3.z,F=n*(x*C-d*l)+r*(d*z-p*C)+t*(p*l-x*z);0!=F&&(F=1/F);c.x=F*(e*(x*C-d*l)+j*(d*z-p*C)+m*(p*l-x*z));c.y=F*(n*(j*C-m*l)+r*(m*z-e*C)+t*(e*l-j*z));c.z=F*(n*(x*m-d*j)+r*(d*e-p*m)+t*(p*j-x*e));return c};p.b2Math=function(){};p.IsValid=function(c){void 0===c&&(c=0);return isFinite(c)};p.Dot=function(c,e){return c.x*e.x+c.y*e.y};p.CrossVV=function(c,e){return c.x*e.y-c.y*e.x};p.CrossVF=function(c, +e){void 0===e&&(e=0);return new j(e*c.y,-e*c.x)};p.CrossFV=function(c,e){void 0===c&&(c=0);return new j(-c*e.y,c*e.x)};p.MulMV=function(c,e){return new j(c.col1.x*e.x+c.col2.x*e.y,c.col1.y*e.x+c.col2.y*e.y)};p.MulTMV=function(c,e){return new j(p.Dot(e,c.col1),p.Dot(e,c.col2))};p.MulX=function(c,e){var j=p.MulMV(c.R,e);j.x+=c.position.x;j.y+=c.position.y;return j};p.MulXT=function(c,e){var j=p.SubtractVV(e,c.position),m=j.x*c.R.col1.x+j.y*c.R.col1.y;j.y=j.x*c.R.col2.x+j.y*c.R.col2.y;j.x=m;return j}; +p.AddVV=function(c,e){return new j(c.x+e.x,c.y+e.y)};p.SubtractVV=function(c,e){return new j(c.x-e.x,c.y-e.y)};p.Distance=function(c,e){var j=c.x-e.x,m=c.y-e.y;return Math.sqrt(j*j+m*m)};p.DistanceSquared=function(c,e){var j=c.x-e.x,m=c.y-e.y;return j*j+m*m};p.MulFV=function(c,e){void 0===c&&(c=0);return new j(c*e.x,c*e.y)};p.AddMM=function(c,e){return n.FromVV(p.AddVV(c.col1,e.col1),p.AddVV(c.col2,e.col2))};p.MulMM=function(c,e){return n.FromVV(p.MulMV(c,e.col1),p.MulMV(c,e.col2))};p.MulTMM=function(c, +e){var m=new j(p.Dot(c.col1,e.col1),p.Dot(c.col2,e.col1)),r=new j(p.Dot(c.col1,e.col2),p.Dot(c.col2,e.col2));return n.FromVV(m,r)};p.Abs=function(c){void 0===c&&(c=0);return 0e?c:e};p.MaxV=function(c,e){return new j(p.Max(c.x,e.x),p.Max(c.y,e.y))};p.Clamp=function(c,e,j){void 0===c&&(c=0);void 0===e&&(e=0);void 0===j&&(j=0);return cj?j:c};p.ClampV=function(c,e,j){return p.MaxV(e,p.MinV(c,j))};p.Swap=function(c,e){var j=c[0];c[0]=e[0];e[0]=j};p.Random=function(){return 2*Math.random()-1};p.RandomRange=function(c,e){void 0===c&&(c=0);void 0===e&&(e=0);var j=Math.random();return(e-c)*j+c};p.NextPowerOfTwo=function(c){void 0===c&&(c=0);c|=c>>1&2147483647;c|= +c>>2&1073741823;c|=c>>4&268435455;c|=c>>8&16777215;return(c|c>>16&65535)+1};p.IsPowerOfTwo=function(c){void 0===c&&(c=0);return 0Number.MIN_VALUE){var e=(c-this.t0)/(1-this.t0);this.c0.x=(1-e)*this.c0.x+e*this.c.x;this.c0.y=(1-e)*this.c0.y+e*this.c.y;this.a0=(1-e)*this.a0+e*this.a;this.t0=c}};e.b2Transform=function(){this.position=new j;this.R=new n};e.prototype.b2Transform=function(c,e){void 0===c&&(c=null);void 0===e&&(e=null);c&&(this.position.SetV(c),this.R.SetM(e))};e.prototype.Initialize=function(c, +e){this.position.SetV(c);this.R.SetM(e)};e.prototype.SetIdentity=function(){this.position.SetZero();this.R.SetIdentity()};e.prototype.Set=function(c){this.position.SetV(c.position);this.R.SetM(c.R)};e.prototype.GetAngle=function(){return Math.atan2(this.R.col1.y,this.R.col1.x)};j.b2Vec2=function(){};j.prototype.b2Vec2=function(c,e){void 0===c&&(c=0);void 0===e&&(e=0);this.x=c;this.y=e};j.prototype.SetZero=function(){this.y=this.x=0};j.prototype.Set=function(c,e){void 0===c&&(c=0);void 0===e&&(e=0); +this.x=c;this.y=e};j.prototype.SetV=function(c){this.x=c.x;this.y=c.y};j.prototype.GetNegative=function(){return new j(-this.x,-this.y)};j.prototype.NegativeSelf=function(){this.x=-this.x;this.y=-this.y};j.Make=function(c,e){void 0===c&&(c=0);void 0===e&&(e=0);return new j(c,e)};j.prototype.Copy=function(){return new j(this.x,this.y)};j.prototype.Add=function(c){this.x+=c.x;this.y+=c.y};j.prototype.Subtract=function(c){this.x-=c.x;this.y-=c.y};j.prototype.Multiply=function(c){void 0===c&&(c=0);this.x*= +c;this.y*=c};j.prototype.MulM=function(c){var e=this.x;this.x=c.col1.x*e+c.col2.x*this.y;this.y=c.col1.y*e+c.col2.y*this.y};j.prototype.MulTM=function(c){var e=p.Dot(this,c.col1);this.y=p.Dot(this,c.col2);this.x=e};j.prototype.CrossVF=function(c){void 0===c&&(c=0);var e=this.x;this.x=c*this.y;this.y=-c*e};j.prototype.CrossFV=function(c){void 0===c&&(c=0);var e=this.x;this.x=-c*this.y;this.y=c*e};j.prototype.MinV=function(c){this.x=this.xc.x?this.x:c.x;this.y=this.y>c.y?this.y:c.y};j.prototype.Abs=function(){0>this.x&&(this.x=-this.x);0>this.y&&(this.y=-this.y)};j.prototype.Length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)};j.prototype.LengthSquared=function(){return this.x*this.x+this.y*this.y};j.prototype.Normalize=function(){var c=Math.sqrt(this.x*this.x+this.y*this.y);if(c=this.m_mass&&(this.m_mass=1);this.m_invMass=1/this.m_mass;0j.b2_maxTranslationSquared&&(f.m_linearVelocity.Normalize(),f.m_linearVelocity.x*=j.b2_maxTranslation*b.inv_dt,f.m_linearVelocity.y*= +j.b2_maxTranslation*b.inv_dt);s=b.dt*f.m_angularVelocity;s*s>j.b2_maxRotationSquared&&(f.m_angularVelocity=0>f.m_angularVelocity?-j.b2_maxRotation*b.inv_dt:j.b2_maxRotation*b.inv_dt);f.m_sweep.c0.SetV(f.m_sweep.c);f.m_sweep.a0=f.m_sweep.a;f.m_sweep.c.x+=b.dt*f.m_linearVelocity.x;f.m_sweep.c.y+=b.dt*f.m_linearVelocity.y;f.m_sweep.a+=b.dt*f.m_angularVelocity;f.SynchronizeTransform()}for(h=0;hs||n.Dot(f.m_linearVelocity,f.m_linearVelocity)> +a?g=f.m_sleepTime=0:(f.m_sleepTime+=b.dt,g=n.Min(g,f.m_sleepTime)));if(g>=j.b2_timeToSleep)for(h=0;hj.b2_maxTranslationSquared&&(g.m_linearVelocity.Normalize(),g.m_linearVelocity.x*=j.b2_maxTranslation*b.inv_dt,g.m_linearVelocity.y*=j.b2_maxTranslation*b.inv_dt);f=b.dt*g.m_angularVelocity;f*f>j.b2_maxRotationSquared&&(g.m_angularVelocity=0>g.m_angularVelocity?-j.b2_maxRotation*b.inv_dt:j.b2_maxRotation*b.inv_dt);g.m_sweep.c0.SetV(g.m_sweep.c);g.m_sweep.a0= +g.m_sweep.a;g.m_sweep.c.x+=b.dt*g.m_linearVelocity.x;g.m_sweep.c.y+=b.dt*g.m_linearVelocity.y;g.m_sweep.a+=b.dt*g.m_angularVelocity;g.SynchronizeTransform()}for(a=0;a=a);0a&&(a=(1-a)*m+a,1-1.5*H.b2_linearSlop};Box2D.postDefs.push(function(){Box2D.Dynamics.Contacts.b2ContactSolver.s_worldManifold=new s;Box2D.Dynamics.Contacts.b2ContactSolver.s_psm=new l});Box2D.inherit(t,Box2D.Dynamics.Contacts.b2Contact);t.prototype.__super=Box2D.Dynamics.Contacts.b2Contact.prototype;t.b2EdgeAndCircleContact=function(){Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this,arguments)};t.Create=function(){return new t};t.Destroy=function(){}; +t.prototype.Reset=function(a,h){this.__super.Reset.call(this,a,h)};t.prototype.Evaluate=function(){var a=this.m_fixtureA.GetBody(),h=this.m_fixtureB.GetBody();this.b2CollideEdgeAndCircle(this.m_manifold,this.m_fixtureA.GetShape()instanceof r?this.m_fixtureA.GetShape():null,a.m_xf,this.m_fixtureB.GetShape()instanceof n?this.m_fixtureB.GetShape():null,h.m_xf)};t.prototype.b2CollideEdgeAndCircle=function(){};Box2D.inherit(J,Box2D.Dynamics.Contacts.b2Contact);J.prototype.__super=Box2D.Dynamics.Contacts.b2Contact.prototype; +J.b2NullContact=function(){Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this,arguments)};J.prototype.b2NullContact=function(){this.__super.b2Contact.call(this)};J.prototype.Evaluate=function(){};Box2D.inherit(L,Box2D.Dynamics.Contacts.b2Contact);L.prototype.__super=Box2D.Dynamics.Contacts.b2Contact.prototype;L.b2PolyAndCircleContact=function(){Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this,arguments)};L.Create=function(){return new L};L.Destroy=function(){};L.prototype.Reset=function(a, +h){this.__super.Reset.call(this,a,h);H.b2Assert(a.GetType()==m.e_polygonShape);H.b2Assert(h.GetType()==m.e_circleShape)};L.prototype.Evaluate=function(){var a=this.m_fixtureA.m_body,h=this.m_fixtureB.m_body;G.CollidePolygonAndCircle(this.m_manifold,this.m_fixtureA.GetShape()instanceof p?this.m_fixtureA.GetShape():null,a.m_xf,this.m_fixtureB.GetShape()instanceof n?this.m_fixtureB.GetShape():null,h.m_xf)};Box2D.inherit(d,Box2D.Dynamics.Contacts.b2Contact);d.prototype.__super=Box2D.Dynamics.Contacts.b2Contact.prototype; +d.b2PolyAndEdgeContact=function(){Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this,arguments)};d.Create=function(){return new d};d.Destroy=function(){};d.prototype.Reset=function(a,h){this.__super.Reset.call(this,a,h);H.b2Assert(a.GetType()==m.e_polygonShape);H.b2Assert(h.GetType()==m.e_edgeShape)};d.prototype.Evaluate=function(){var a=this.m_fixtureA.GetBody(),h=this.m_fixtureB.GetBody();this.b2CollidePolyAndEdge(this.m_manifold,this.m_fixtureA.GetShape()instanceof p?this.m_fixtureA.GetShape(): +null,a.m_xf,this.m_fixtureB.GetShape()instanceof r?this.m_fixtureB.GetShape():null,h.m_xf)};d.prototype.b2CollidePolyAndEdge=function(){};Box2D.inherit(z,Box2D.Dynamics.Contacts.b2Contact);z.prototype.__super=Box2D.Dynamics.Contacts.b2Contact.prototype;z.b2PolygonContact=function(){Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this,arguments)};z.Create=function(){return new z};z.Destroy=function(){};z.prototype.Reset=function(a,h){this.__super.Reset.call(this,a,h)};z.prototype.Evaluate=function(){var a= +this.m_fixtureA.GetBody(),h=this.m_fixtureB.GetBody();G.CollidePolygons(this.m_manifold,this.m_fixtureA.GetShape()instanceof p?this.m_fixtureA.GetShape():null,a.m_xf,this.m_fixtureB.GetShape()instanceof p?this.m_fixtureB.GetShape():null,h.m_xf)};l.b2PositionSolverManifold=function(){};l.prototype.b2PositionSolverManifold=function(){this.m_normal=new E;this.m_separations=new Vector_a2j_Number(H.b2_maxManifoldPoints);this.m_points=new Vector(H.b2_maxManifoldPoints);for(var a=0;aNumber.MIN_VALUE*Number.MIN_VALUE?(e=Math.sqrt(e),this.m_normal.x= +f/e,this.m_normal.y=s/e):(this.m_normal.x=1,this.m_normal.y=0);this.m_points[0].x=0.5*(h+d);this.m_points[0].y=0.5*(c+b);this.m_separations[0]=f*this.m_normal.x+s*this.m_normal.y-a.radius;break;case I.e_faceA:b=a.bodyA.m_xf.R;f=a.localPlaneNormal;this.m_normal.x=b.col1.x*f.x+b.col2.x*f.y;this.m_normal.y=b.col1.y*f.x+b.col2.y*f.y;b=a.bodyA.m_xf.R;f=a.localPoint;d=a.bodyA.m_xf.position.x+(b.col1.x*f.x+b.col2.x*f.y);s=a.bodyA.m_xf.position.y+(b.col1.y*f.x+b.col2.y*f.y);b=a.bodyB.m_xf.R;for(h=0;hthis.maxTimestep&&0n.b2_linearSlop?this.m_u.Multiply(1/c):this.m_u.SetZero();h=d*this.m_u.y-f*this.m_u.x;var j=b*this.m_u.y-k*this.m_u.x;h=g.m_invMass+g.m_invI* +h*h+e.m_invMass+e.m_invI*j*j;this.m_mass=0!=h?1/h:0;if(0h*h&&(this.m_linearImpulse.Normalize(),this.m_linearImpulse.Multiply(h));h=m.SubtractVV(this.m_linearImpulse,c);j.x-=l*h.x;j.y-=l*h.y;f-=r*(t*h.y-q*h.x);b.x+=n*h.x;b.y+=n*h.y;k+=p*(x*h.y-w*h.x);g.m_angularVelocity=f;d.m_angularVelocity=k};q.prototype.SolvePositionConstraints=function(){return!0};Box2D.inherit(K,Box2D.Dynamics.Joints.b2JointDef);K.prototype.__super=Box2D.Dynamics.Joints.b2JointDef.prototype;K.b2FrictionJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, +arguments);this.localAnchorA=new e;this.localAnchorB=new e};K.prototype.b2FrictionJointDef=function(){this.__super.b2JointDef.call(this);this.type=t.e_frictionJoint;this.maxTorque=this.maxForce=0};K.prototype.Initialize=function(a,h,c){this.bodyA=a;this.bodyB=h;this.localAnchorA.SetV(this.bodyA.GetLocalPoint(c));this.localAnchorB.SetV(this.bodyB.GetLocalPoint(c))};Box2D.inherit(D,Box2D.Dynamics.Joints.b2Joint);D.prototype.__super=Box2D.Dynamics.Joints.b2Joint.prototype;D.b2GearJoint=function(){Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, +arguments);this.m_groundAnchor1=new e;this.m_groundAnchor2=new e;this.m_localAnchor1=new e;this.m_localAnchor2=new e;this.m_J=new A};D.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)};D.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)};D.prototype.GetReactionForce=function(a){void 0===a&&(a=0);return new e(a*this.m_impulse*this.m_J.linearB.x,a*this.m_impulse*this.m_J.linearB.y)};D.prototype.GetReactionTorque=function(a){void 0=== +a&&(a=0);var h=this.m_bodyB.m_xf.R,c=this.m_localAnchor1.x-this.m_bodyB.m_sweep.localCenter.x,g=this.m_localAnchor1.y-this.m_bodyB.m_sweep.localCenter.y,d=h.col1.x*c+h.col2.x*g,g=h.col1.y*c+h.col2.y*g;return a*(this.m_impulse*this.m_J.angularB-d*this.m_impulse*this.m_J.linearB.y+g*this.m_impulse*this.m_J.linearB.x)};D.prototype.GetRatio=function(){return this.m_ratio};D.prototype.SetRatio=function(a){void 0===a&&(a=0);this.m_ratio=a};D.prototype.b2GearJoint=function(a){this.__super.b2Joint.call(this, +a);var h=parseInt(a.joint1.m_type),c=parseInt(a.joint2.m_type);this.m_prismatic2=this.m_revolute2=this.m_prismatic1=this.m_revolute1=null;var g=0,d=0;this.m_ground1=a.joint1.GetBodyA();this.m_bodyA=a.joint1.GetBodyB();h==t.e_revoluteJoint?(this.m_revolute1=a.joint1 instanceof E?a.joint1:null,this.m_groundAnchor1.SetV(this.m_revolute1.m_localAnchor1),this.m_localAnchor1.SetV(this.m_revolute1.m_localAnchor2),g=this.m_revolute1.GetJointAngle()):(this.m_prismatic1=a.joint1 instanceof F?a.joint1:null, +this.m_groundAnchor1.SetV(this.m_prismatic1.m_localAnchor1),this.m_localAnchor1.SetV(this.m_prismatic1.m_localAnchor2),g=this.m_prismatic1.GetJointTranslation());this.m_ground2=a.joint2.GetBodyA();this.m_bodyB=a.joint2.GetBodyB();c==t.e_revoluteJoint?(this.m_revolute2=a.joint2 instanceof E?a.joint2:null,this.m_groundAnchor2.SetV(this.m_revolute2.m_localAnchor1),this.m_localAnchor2.SetV(this.m_revolute2.m_localAnchor2),d=this.m_revolute2.GetJointAngle()):(this.m_prismatic2=a.joint2 instanceof F?a.joint2: +null,this.m_groundAnchor2.SetV(this.m_prismatic2.m_localAnchor1),this.m_localAnchor2.SetV(this.m_prismatic2.m_localAnchor2),d=this.m_prismatic2.GetJointTranslation());this.m_ratio=a.ratio;this.m_constant=g+this.m_ratio*d;this.m_impulse=0};D.prototype.InitVelocityConstraints=function(a){var h=this.m_ground1,c=this.m_ground2,g=this.m_bodyA,d=this.m_bodyB,e=0,f=0,b=0,k=0,j=b=0,m=0;this.m_J.SetZero();this.m_revolute1?(this.m_J.angularA=-1,m+=g.m_invI):(h=h.m_xf.R,f=this.m_prismatic1.m_localXAxis1,e=h.col1.x* +f.x+h.col2.x*f.y,f=h.col1.y*f.x+h.col2.y*f.y,h=g.m_xf.R,b=this.m_localAnchor1.x-g.m_sweep.localCenter.x,k=this.m_localAnchor1.y-g.m_sweep.localCenter.y,j=h.col1.x*b+h.col2.x*k,k=h.col1.y*b+h.col2.y*k,b=j*f-k*e,this.m_J.linearA.Set(-e,-f),this.m_J.angularA=-b,m+=g.m_invMass+g.m_invI*b*b);this.m_revolute2?(this.m_J.angularB=-this.m_ratio,m+=this.m_ratio*this.m_ratio*d.m_invI):(h=c.m_xf.R,f=this.m_prismatic2.m_localXAxis1,e=h.col1.x*f.x+h.col2.x*f.y,f=h.col1.y*f.x+h.col2.y*f.y,h=d.m_xf.R,b=this.m_localAnchor2.x- +d.m_sweep.localCenter.x,k=this.m_localAnchor2.y-d.m_sweep.localCenter.y,j=h.col1.x*b+h.col2.x*k,k=h.col1.y*b+h.col2.y*k,b=j*f-k*e,this.m_J.linearB.Set(-this.m_ratio*e,-this.m_ratio*f),this.m_J.angularB=-this.m_ratio*b,m+=this.m_ratio*this.m_ratio*(d.m_invMass+d.m_invI*b*b));this.m_mass=0Number.MIN_VALUE?1/this.m_motorMass:0;this.m_perp.SetV(m.MulMV(j.R,this.m_localYAxis1));this.m_s1=(g+f)*this.m_perp.y-(e+b)*this.m_perp.x;this.m_s2=k*this.m_perp.y-l*this.m_perp.x;j=this.m_invMassA;f=this.m_invMassB;b=this.m_invIA;k=this.m_invIB;this.m_K.col1.x=j+f+b*this.m_s1* +this.m_s1+k*this.m_s2*this.m_s2;this.m_K.col1.y=b*this.m_s1*this.m_a1+k*this.m_s2*this.m_a2;this.m_K.col2.x=this.m_K.col1.y;this.m_K.col2.y=j+f+b*this.m_a1*this.m_a1+k*this.m_a2*this.m_a2;this.m_enableLimit?(g=this.m_axis.x*g+this.m_axis.y*e,m.Abs(this.m_upperTranslation-this.m_lowerTranslation)<2*n.b2_linearSlop?this.m_limitState=t.e_equalLimits:g<=this.m_lowerTranslation?this.m_limitState!=t.e_atLowerLimit&&(this.m_limitState=t.e_atLowerLimit,this.m_impulse.y=0):g>=this.m_upperTranslation?this.m_limitState!= +t.e_atUpperLimit&&(this.m_limitState=t.e_atUpperLimit,this.m_impulse.y=0):(this.m_limitState=t.e_inactiveLimit,this.m_impulse.y=0)):this.m_limitState=t.e_inactiveLimit;!1==this.m_enableMotor&&(this.m_motorImpulse=0);a.warmStarting?(this.m_impulse.x*=a.dtRatio,this.m_impulse.y*=a.dtRatio,this.m_motorImpulse*=a.dtRatio,a=this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.y)*this.m_axis.x,g=this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+this.m_impulse.y)*this.m_axis.y,e=this.m_impulse.x* +this.m_s1+(this.m_motorImpulse+this.m_impulse.y)*this.m_a1,j=this.m_impulse.x*this.m_s2+(this.m_motorImpulse+this.m_impulse.y)*this.m_a2,c.m_linearVelocity.x-=this.m_invMassA*a,c.m_linearVelocity.y-=this.m_invMassA*g,c.m_angularVelocity-=this.m_invIA*e,d.m_linearVelocity.x+=this.m_invMassB*a,d.m_linearVelocity.y+=this.m_invMassB*g,d.m_angularVelocity+=this.m_invIB*j):(this.m_impulse.SetZero(),this.m_motorImpulse=0)};d.prototype.SolveVelocityConstraints=function(a){var c=this.m_bodyA,d=this.m_bodyB, +g=c.m_linearVelocity,j=c.m_angularVelocity,l=d.m_linearVelocity,f=d.m_angularVelocity,b=0,k=0,v=0,n=0;this.m_enableMotor&&this.m_limitState!=t.e_equalLimits&&(n=this.m_motorMass*(this.m_motorSpeed-(this.m_axis.x*(l.x-g.x)+this.m_axis.y*(l.y-g.y)+this.m_a2*f-this.m_a1*j)),b=this.m_motorImpulse,k=a.dt*this.m_maxMotorForce,this.m_motorImpulse=m.Clamp(this.m_motorImpulse+n,-k,k),n=this.m_motorImpulse-b,b=n*this.m_axis.x,k=n*this.m_axis.y,v=n*this.m_a1,n*=this.m_a2,g.x-=this.m_invMassA*b,g.y-=this.m_invMassA* +k,j-=this.m_invIA*v,l.x+=this.m_invMassB*b,l.y+=this.m_invMassB*k,f+=this.m_invIB*n);k=this.m_perp.x*(l.x-g.x)+this.m_perp.y*(l.y-g.y)+this.m_s2*f-this.m_s1*j;this.m_enableLimit&&this.m_limitState!=t.e_inactiveLimit?(v=this.m_axis.x*(l.x-g.x)+this.m_axis.y*(l.y-g.y)+this.m_a2*f-this.m_a1*j,b=this.m_impulse.Copy(),a=this.m_K.Solve(new e,-k,-v),this.m_impulse.Add(a),this.m_limitState==t.e_atLowerLimit?this.m_impulse.y=m.Max(this.m_impulse.y,0):this.m_limitState==t.e_atUpperLimit&&(this.m_impulse.y= +m.Min(this.m_impulse.y,0)),k=-k-(this.m_impulse.y-b.y)*this.m_K.col2.x,v=0,v=0!=this.m_K.col1.x?k/this.m_K.col1.x+b.x:b.x,this.m_impulse.x=v,a.x=this.m_impulse.x-b.x,a.y=this.m_impulse.y-b.y,b=a.x*this.m_perp.x+a.y*this.m_axis.x,k=a.x*this.m_perp.y+a.y*this.m_axis.y,v=a.x*this.m_s1+a.y*this.m_a1,n=a.x*this.m_s2+a.y*this.m_a2):(a=0,a=0!=this.m_K.col1.x?-k/this.m_K.col1.x:0,this.m_impulse.x+=a,b=a*this.m_perp.x,k=a*this.m_perp.y,v=a*this.m_s1,n=a*this.m_s2);g.x-=this.m_invMassA*b;g.y-=this.m_invMassA* +k;j-=this.m_invIA*v;l.x+=this.m_invMassB*b;l.y+=this.m_invMassB*k;f+=this.m_invIB*n;c.m_linearVelocity.SetV(g);c.m_angularVelocity=j;d.m_linearVelocity.SetV(l);d.m_angularVelocity=f};d.prototype.SolvePositionConstraints=function(){var a=this.m_bodyA,c=this.m_bodyB,d=a.m_sweep.c,g=a.m_sweep.a,j=c.m_sweep.c,l=c.m_sweep.a,f,b=0,k=0,v=0,p=0,t=f=0,q=0,k=!1,x=0,w=r.FromAngle(g),v=r.FromAngle(l);f=w;var q=this.m_localAnchor1.x-this.m_localCenterA.x,A=this.m_localAnchor1.y-this.m_localCenterA.y,b=f.col1.x* +q+f.col2.x*A,A=f.col1.y*q+f.col2.y*A,q=b;f=v;v=this.m_localAnchor2.x-this.m_localCenterB.x;p=this.m_localAnchor2.y-this.m_localCenterB.y;b=f.col1.x*v+f.col2.x*p;p=f.col1.y*v+f.col2.y*p;v=b;f=j.x+v-d.x-q;b=j.y+p-d.y-A;if(this.m_enableLimit){this.m_axis=m.MulMV(w,this.m_localXAxis1);this.m_a1=(f+q)*this.m_axis.y-(b+A)*this.m_axis.x;this.m_a2=v*this.m_axis.y-p*this.m_axis.x;var z=this.m_axis.x*f+this.m_axis.y*b;m.Abs(this.m_upperTranslation-this.m_lowerTranslation)<2*n.b2_linearSlop?(x=m.Clamp(z,-n.b2_maxLinearCorrection, +n.b2_maxLinearCorrection),t=m.Abs(z),k=!0):z<=this.m_lowerTranslation?(x=m.Clamp(z-this.m_lowerTranslation+n.b2_linearSlop,-n.b2_maxLinearCorrection,0),t=this.m_lowerTranslation-z,k=!0):z>=this.m_upperTranslation&&(x=m.Clamp(z-this.m_upperTranslation+n.b2_linearSlop,0,n.b2_maxLinearCorrection),t=z-this.m_upperTranslation,k=!0)}this.m_perp=m.MulMV(w,this.m_localYAxis1);this.m_s1=(f+q)*this.m_perp.y-(b+A)*this.m_perp.x;this.m_s2=v*this.m_perp.y-p*this.m_perp.x;w=new e;A=this.m_perp.x*f+this.m_perp.y* +b;t=m.Max(t,m.Abs(A));q=0;k?(k=this.m_invMassA,v=this.m_invMassB,p=this.m_invIA,f=this.m_invIB,this.m_K.col1.x=k+v+p*this.m_s1*this.m_s1+f*this.m_s2*this.m_s2,this.m_K.col1.y=p*this.m_s1*this.m_a1+f*this.m_s2*this.m_a2,this.m_K.col2.x=this.m_K.col1.y,this.m_K.col2.y=k+v+p*this.m_a1*this.m_a1+f*this.m_a2*this.m_a2,this.m_K.Solve(w,-A,-x)):(k=this.m_invMassA,v=this.m_invMassB,p=this.m_invIA,f=this.m_invIB,x=k+v+p*this.m_s1*this.m_s1+f*this.m_s2*this.m_s2,w.x=0!=x?-A/x:0,w.y=0);x=w.x*this.m_perp.x+w.y* +this.m_axis.x;k=w.x*this.m_perp.y+w.y*this.m_axis.y;A=w.x*this.m_s1+w.y*this.m_a1;w=w.x*this.m_s2+w.y*this.m_a2;d.x-=this.m_invMassA*x;d.y-=this.m_invMassA*k;g-=this.m_invIA*A;j.x+=this.m_invMassB*x;j.y+=this.m_invMassB*k;l+=this.m_invIB*w;a.m_sweep.a=g;c.m_sweep.a=l;a.SynchronizeTransform();c.SynchronizeTransform();return t<=n.b2_linearSlop&&q<=n.b2_angularSlop};Box2D.inherit(z,Box2D.Dynamics.Joints.b2JointDef);z.prototype.__super=Box2D.Dynamics.Joints.b2JointDef.prototype;z.b2LineJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, +arguments);this.localAnchorA=new e;this.localAnchorB=new e;this.localAxisA=new e};z.prototype.b2LineJointDef=function(){this.__super.b2JointDef.call(this);this.type=t.e_lineJoint;this.localAxisA.Set(1,0);this.enableLimit=!1;this.upperTranslation=this.lowerTranslation=0;this.enableMotor=!1;this.motorSpeed=this.maxMotorForce=0};z.prototype.Initialize=function(a,c,d,g){this.bodyA=a;this.bodyB=c;this.localAnchorA=this.bodyA.GetLocalPoint(d);this.localAnchorB=this.bodyB.GetLocalPoint(d);this.localAxisA= +this.bodyA.GetLocalVector(g)};Box2D.inherit(l,Box2D.Dynamics.Joints.b2Joint);l.prototype.__super=Box2D.Dynamics.Joints.b2Joint.prototype;l.b2MouseJoint=function(){Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments);this.K=new r;this.K1=new r;this.K2=new r;this.m_localAnchor=new e;this.m_target=new e;this.m_impulse=new e;this.m_mass=new r;this.m_C=new e};l.prototype.GetAnchorA=function(){return this.m_target};l.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor)}; +l.prototype.GetReactionForce=function(a){void 0===a&&(a=0);return new e(a*this.m_impulse.x,a*this.m_impulse.y)};l.prototype.GetReactionTorque=function(){return 0};l.prototype.GetTarget=function(){return this.m_target};l.prototype.SetTarget=function(a){!1==this.m_bodyB.IsAwake()&&this.m_bodyB.SetAwake(!0);this.m_target=a};l.prototype.GetMaxForce=function(){return this.m_maxForce};l.prototype.SetMaxForce=function(a){void 0===a&&(a=0);this.m_maxForce=a};l.prototype.GetFrequency=function(){return this.m_frequencyHz}; +l.prototype.SetFrequency=function(a){void 0===a&&(a=0);this.m_frequencyHz=a};l.prototype.GetDampingRatio=function(){return this.m_dampingRatio};l.prototype.SetDampingRatio=function(a){void 0===a&&(a=0);this.m_dampingRatio=a};l.prototype.b2MouseJoint=function(a){this.__super.b2Joint.call(this,a);this.m_target.SetV(a.target);var c=this.m_target.x-this.m_bodyB.m_xf.position.x,d=this.m_target.y-this.m_bodyB.m_xf.position.y,g=this.m_bodyB.m_xf.R;this.m_localAnchor.x=c*g.col1.x+d*g.col1.y;this.m_localAnchor.y= +c*g.col2.x+d*g.col2.y;this.m_maxForce=a.maxForce;this.m_impulse.SetZero();this.m_frequencyHz=a.frequencyHz;this.m_dampingRatio=a.dampingRatio;this.m_gamma=this.m_beta=0};l.prototype.InitVelocityConstraints=function(a){var c=this.m_bodyB,d=c.GetMass(),g=2*Math.PI*this.m_frequencyHz,e=d*g*g;this.m_gamma=a.dt*(2*d*this.m_dampingRatio*g+a.dt*e);this.m_gamma=0!=this.m_gamma?1/this.m_gamma:0;this.m_beta=a.dt*e*this.m_gamma;var e=c.m_xf.R,d=this.m_localAnchor.x-c.m_sweep.localCenter.x,g=this.m_localAnchor.y- +c.m_sweep.localCenter.y,j=e.col1.x*d+e.col2.x*g,g=e.col1.y*d+e.col2.y*g,d=j,e=c.m_invMass,j=c.m_invI;this.K1.col1.x=e;this.K1.col2.x=0;this.K1.col1.y=0;this.K1.col2.y=e;this.K2.col1.x=j*g*g;this.K2.col2.x=-j*d*g;this.K2.col1.y=-j*d*g;this.K2.col2.y=j*d*d;this.K.SetM(this.K1);this.K.AddM(this.K2);this.K.col1.x+=this.m_gamma;this.K.col2.y+=this.m_gamma;this.K.GetInverse(this.m_mass);this.m_C.x=c.m_sweep.c.x+d-this.m_target.x;this.m_C.y=c.m_sweep.c.y+g-this.m_target.y;c.m_angularVelocity*=0.98;this.m_impulse.x*= +a.dtRatio;this.m_impulse.y*=a.dtRatio;c.m_linearVelocity.x+=e*this.m_impulse.x;c.m_linearVelocity.y+=e*this.m_impulse.y;c.m_angularVelocity+=j*(d*this.m_impulse.y-g*this.m_impulse.x)};l.prototype.SolveVelocityConstraints=function(a){var c=this.m_bodyB,d,g=0,e=0;d=c.m_xf.R;var j=this.m_localAnchor.x-c.m_sweep.localCenter.x,f=this.m_localAnchor.y-c.m_sweep.localCenter.y,g=d.col1.x*j+d.col2.x*f,f=d.col1.y*j+d.col2.y*f,j=g,g=c.m_linearVelocity.x+-c.m_angularVelocity*f,b=c.m_linearVelocity.y+c.m_angularVelocity* +j;d=this.m_mass;g=g+this.m_beta*this.m_C.x+this.m_gamma*this.m_impulse.x;e=b+this.m_beta*this.m_C.y+this.m_gamma*this.m_impulse.y;b=-(d.col1.x*g+d.col2.x*e);e=-(d.col1.y*g+d.col2.y*e);d=this.m_impulse.x;g=this.m_impulse.y;this.m_impulse.x+=b;this.m_impulse.y+=e;a=a.dt*this.m_maxForce;this.m_impulse.LengthSquared()>a*a&&this.m_impulse.Multiply(a/this.m_impulse.Length());b=this.m_impulse.x-d;e=this.m_impulse.y-g;c.m_linearVelocity.x+=c.m_invMass*b;c.m_linearVelocity.y+=c.m_invMass*e;c.m_angularVelocity+= +c.m_invI*(j*e-f*b)};l.prototype.SolvePositionConstraints=function(){return!0};Box2D.inherit(C,Box2D.Dynamics.Joints.b2JointDef);C.prototype.__super=Box2D.Dynamics.Joints.b2JointDef.prototype;C.b2MouseJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments);this.target=new e};C.prototype.b2MouseJointDef=function(){this.__super.b2JointDef.call(this);this.type=t.e_mouseJoint;this.maxForce=0;this.frequencyHz=5;this.dampingRatio=0.7};Box2D.inherit(F,Box2D.Dynamics.Joints.b2Joint); +F.prototype.__super=Box2D.Dynamics.Joints.b2Joint.prototype;F.b2PrismaticJoint=function(){Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments);this.m_localAnchor1=new e;this.m_localAnchor2=new e;this.m_localXAxis1=new e;this.m_localYAxis1=new e;this.m_axis=new e;this.m_perp=new e;this.m_K=new p;this.m_impulse=new j};F.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)};F.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)}; +F.prototype.GetReactionForce=function(a){void 0===a&&(a=0);return new e(a*(this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.x),a*(this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.y))};F.prototype.GetReactionTorque=function(a){void 0===a&&(a=0);return a*this.m_impulse.y};F.prototype.GetJointTranslation=function(){var a=this.m_bodyA,c=this.m_bodyB,d=a.GetWorldPoint(this.m_localAnchor1),g=c.GetWorldPoint(this.m_localAnchor2),c=g.x-d.x, +d=g.y-d.y,a=a.GetWorldVector(this.m_localXAxis1);return a.x*c+a.y*d};F.prototype.GetJointSpeed=function(){var a=this.m_bodyA,c=this.m_bodyB,d;d=a.m_xf.R;var g=this.m_localAnchor1.x-a.m_sweep.localCenter.x,e=this.m_localAnchor1.y-a.m_sweep.localCenter.y,j=d.col1.x*g+d.col2.x*e,e=d.col1.y*g+d.col2.y*e,g=j;d=c.m_xf.R;var f=this.m_localAnchor2.x-c.m_sweep.localCenter.x,b=this.m_localAnchor2.y-c.m_sweep.localCenter.y,j=d.col1.x*f+d.col2.x*b,b=d.col1.y*f+d.col2.y*b,f=j;d=c.m_sweep.c.x+f-(a.m_sweep.c.x+ +g);var j=c.m_sweep.c.y+b-(a.m_sweep.c.y+e),k=a.GetWorldVector(this.m_localXAxis1),m=a.m_linearVelocity,l=c.m_linearVelocity,a=a.m_angularVelocity,c=c.m_angularVelocity;return d*-a*k.y+j*a*k.x+(k.x*(l.x+-c*b-m.x- -a*e)+k.y*(l.y+c*f-m.y-a*g))};F.prototype.IsLimitEnabled=function(){return this.m_enableLimit};F.prototype.EnableLimit=function(a){this.m_bodyA.SetAwake(!0);this.m_bodyB.SetAwake(!0);this.m_enableLimit=a};F.prototype.GetLowerLimit=function(){return this.m_lowerTranslation};F.prototype.GetUpperLimit= +function(){return this.m_upperTranslation};F.prototype.SetLimits=function(a,c){void 0===a&&(a=0);void 0===c&&(c=0);this.m_bodyA.SetAwake(!0);this.m_bodyB.SetAwake(!0);this.m_lowerTranslation=a;this.m_upperTranslation=c};F.prototype.IsMotorEnabled=function(){return this.m_enableMotor};F.prototype.EnableMotor=function(a){this.m_bodyA.SetAwake(!0);this.m_bodyB.SetAwake(!0);this.m_enableMotor=a};F.prototype.SetMotorSpeed=function(a){void 0===a&&(a=0);this.m_bodyA.SetAwake(!0);this.m_bodyB.SetAwake(!0); +this.m_motorSpeed=a};F.prototype.GetMotorSpeed=function(){return this.m_motorSpeed};F.prototype.SetMaxMotorForce=function(a){void 0===a&&(a=0);this.m_bodyA.SetAwake(!0);this.m_bodyB.SetAwake(!0);this.m_maxMotorForce=a};F.prototype.GetMotorForce=function(){return this.m_motorImpulse};F.prototype.b2PrismaticJoint=function(a){this.__super.b2Joint.call(this,a);this.m_localAnchor1.SetV(a.localAnchorA);this.m_localAnchor2.SetV(a.localAnchorB);this.m_localXAxis1.SetV(a.localAxisA);this.m_localYAxis1.x=-this.m_localXAxis1.y; +this.m_localYAxis1.y=this.m_localXAxis1.x;this.m_refAngle=a.referenceAngle;this.m_impulse.SetZero();this.m_motorImpulse=this.m_motorMass=0;this.m_lowerTranslation=a.lowerTranslation;this.m_upperTranslation=a.upperTranslation;this.m_maxMotorForce=a.maxMotorForce;this.m_motorSpeed=a.motorSpeed;this.m_enableLimit=a.enableLimit;this.m_enableMotor=a.enableMotor;this.m_limitState=t.e_inactiveLimit;this.m_axis.SetZero();this.m_perp.SetZero()};F.prototype.InitVelocityConstraints=function(a){var c=this.m_bodyA, +d=this.m_bodyB,g,e=0;this.m_localCenterA.SetV(c.GetLocalCenter());this.m_localCenterB.SetV(d.GetLocalCenter());var j=c.GetTransform();d.GetTransform();g=c.m_xf.R;var f=this.m_localAnchor1.x-this.m_localCenterA.x,b=this.m_localAnchor1.y-this.m_localCenterA.y,e=g.col1.x*f+g.col2.x*b,b=g.col1.y*f+g.col2.y*b,f=e;g=d.m_xf.R;var k=this.m_localAnchor2.x-this.m_localCenterB.x,l=this.m_localAnchor2.y-this.m_localCenterB.y,e=g.col1.x*k+g.col2.x*l,l=g.col1.y*k+g.col2.y*l,k=e;g=d.m_sweep.c.x+k-c.m_sweep.c.x- +f;e=d.m_sweep.c.y+l-c.m_sweep.c.y-b;this.m_invMassA=c.m_invMass;this.m_invMassB=d.m_invMass;this.m_invIA=c.m_invI;this.m_invIB=d.m_invI;this.m_axis.SetV(m.MulMV(j.R,this.m_localXAxis1));this.m_a1=(g+f)*this.m_axis.y-(e+b)*this.m_axis.x;this.m_a2=k*this.m_axis.y-l*this.m_axis.x;this.m_motorMass=this.m_invMassA+this.m_invMassB+this.m_invIA*this.m_a1*this.m_a1+this.m_invIB*this.m_a2*this.m_a2;this.m_motorMass>Number.MIN_VALUE&&(this.m_motorMass=1/this.m_motorMass);this.m_perp.SetV(m.MulMV(j.R,this.m_localYAxis1)); +this.m_s1=(g+f)*this.m_perp.y-(e+b)*this.m_perp.x;this.m_s2=k*this.m_perp.y-l*this.m_perp.x;j=this.m_invMassA;f=this.m_invMassB;b=this.m_invIA;k=this.m_invIB;this.m_K.col1.x=j+f+b*this.m_s1*this.m_s1+k*this.m_s2*this.m_s2;this.m_K.col1.y=b*this.m_s1+k*this.m_s2;this.m_K.col1.z=b*this.m_s1*this.m_a1+k*this.m_s2*this.m_a2;this.m_K.col2.x=this.m_K.col1.y;this.m_K.col2.y=b+k;this.m_K.col2.z=b*this.m_a1+k*this.m_a2;this.m_K.col3.x=this.m_K.col1.z;this.m_K.col3.y=this.m_K.col2.z;this.m_K.col3.z=j+f+b*this.m_a1* +this.m_a1+k*this.m_a2*this.m_a2;this.m_enableLimit?(g=this.m_axis.x*g+this.m_axis.y*e,m.Abs(this.m_upperTranslation-this.m_lowerTranslation)<2*n.b2_linearSlop?this.m_limitState=t.e_equalLimits:g<=this.m_lowerTranslation?this.m_limitState!=t.e_atLowerLimit&&(this.m_limitState=t.e_atLowerLimit,this.m_impulse.z=0):g>=this.m_upperTranslation?this.m_limitState!=t.e_atUpperLimit&&(this.m_limitState=t.e_atUpperLimit,this.m_impulse.z=0):(this.m_limitState=t.e_inactiveLimit,this.m_impulse.z=0)):this.m_limitState= +t.e_inactiveLimit;!1==this.m_enableMotor&&(this.m_motorImpulse=0);a.warmStarting?(this.m_impulse.x*=a.dtRatio,this.m_impulse.y*=a.dtRatio,this.m_motorImpulse*=a.dtRatio,a=this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.x,g=this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.y,e=this.m_impulse.x*this.m_s1+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a1,j=this.m_impulse.x*this.m_s2+this.m_impulse.y+(this.m_motorImpulse+ +this.m_impulse.z)*this.m_a2,c.m_linearVelocity.x-=this.m_invMassA*a,c.m_linearVelocity.y-=this.m_invMassA*g,c.m_angularVelocity-=this.m_invIA*e,d.m_linearVelocity.x+=this.m_invMassB*a,d.m_linearVelocity.y+=this.m_invMassB*g,d.m_angularVelocity+=this.m_invIB*j):(this.m_impulse.SetZero(),this.m_motorImpulse=0)};F.prototype.SolveVelocityConstraints=function(a){var c=this.m_bodyA,d=this.m_bodyB,g=c.m_linearVelocity,l=c.m_angularVelocity,n=d.m_linearVelocity,f=d.m_angularVelocity,b=0,k=0,v=0,r=0;this.m_enableMotor&& +this.m_limitState!=t.e_equalLimits&&(r=this.m_motorMass*(this.m_motorSpeed-(this.m_axis.x*(n.x-g.x)+this.m_axis.y*(n.y-g.y)+this.m_a2*f-this.m_a1*l)),b=this.m_motorImpulse,a=a.dt*this.m_maxMotorForce,this.m_motorImpulse=m.Clamp(this.m_motorImpulse+r,-a,a),r=this.m_motorImpulse-b,b=r*this.m_axis.x,k=r*this.m_axis.y,v=r*this.m_a1,r*=this.m_a2,g.x-=this.m_invMassA*b,g.y-=this.m_invMassA*k,l-=this.m_invIA*v,n.x+=this.m_invMassB*b,n.y+=this.m_invMassB*k,f+=this.m_invIB*r);v=this.m_perp.x*(n.x-g.x)+this.m_perp.y* +(n.y-g.y)+this.m_s2*f-this.m_s1*l;k=f-l;this.m_enableLimit&&this.m_limitState!=t.e_inactiveLimit?(a=this.m_axis.x*(n.x-g.x)+this.m_axis.y*(n.y-g.y)+this.m_a2*f-this.m_a1*l,b=this.m_impulse.Copy(),a=this.m_K.Solve33(new j,-v,-k,-a),this.m_impulse.Add(a),this.m_limitState==t.e_atLowerLimit?this.m_impulse.z=m.Max(this.m_impulse.z,0):this.m_limitState==t.e_atUpperLimit&&(this.m_impulse.z=m.Min(this.m_impulse.z,0)),v=-v-(this.m_impulse.z-b.z)*this.m_K.col3.x,k=-k-(this.m_impulse.z-b.z)*this.m_K.col3.y, +k=this.m_K.Solve22(new e,v,k),k.x+=b.x,k.y+=b.y,this.m_impulse.x=k.x,this.m_impulse.y=k.y,a.x=this.m_impulse.x-b.x,a.y=this.m_impulse.y-b.y,a.z=this.m_impulse.z-b.z,b=a.x*this.m_perp.x+a.z*this.m_axis.x,k=a.x*this.m_perp.y+a.z*this.m_axis.y,v=a.x*this.m_s1+a.y+a.z*this.m_a1,r=a.x*this.m_s2+a.y+a.z*this.m_a2):(a=this.m_K.Solve22(new e,-v,-k),this.m_impulse.x+=a.x,this.m_impulse.y+=a.y,b=a.x*this.m_perp.x,k=a.x*this.m_perp.y,v=a.x*this.m_s1+a.y,r=a.x*this.m_s2+a.y);g.x-=this.m_invMassA*b;g.y-=this.m_invMassA* +k;l-=this.m_invIA*v;n.x+=this.m_invMassB*b;n.y+=this.m_invMassB*k;f+=this.m_invIB*r;c.m_linearVelocity.SetV(g);c.m_angularVelocity=l;d.m_linearVelocity.SetV(n);d.m_angularVelocity=f};F.prototype.SolvePositionConstraints=function(){var a=this.m_bodyA,c=this.m_bodyB,d=a.m_sweep.c,g=a.m_sweep.a,l=c.m_sweep.c,p=c.m_sweep.a,f,b=0,k=0,v=0,t=b=f=0,q=0,k=!1,x=0,w=r.FromAngle(g),A=r.FromAngle(p);f=w;var q=this.m_localAnchor1.x-this.m_localCenterA.x,z=this.m_localAnchor1.y-this.m_localCenterA.y,b=f.col1.x* +q+f.col2.x*z,z=f.col1.y*q+f.col2.y*z,q=b;f=A;A=this.m_localAnchor2.x-this.m_localCenterB.x;v=this.m_localAnchor2.y-this.m_localCenterB.y;b=f.col1.x*A+f.col2.x*v;v=f.col1.y*A+f.col2.y*v;A=b;f=l.x+A-d.x-q;b=l.y+v-d.y-z;if(this.m_enableLimit){this.m_axis=m.MulMV(w,this.m_localXAxis1);this.m_a1=(f+q)*this.m_axis.y-(b+z)*this.m_axis.x;this.m_a2=A*this.m_axis.y-v*this.m_axis.x;var B=this.m_axis.x*f+this.m_axis.y*b;m.Abs(this.m_upperTranslation-this.m_lowerTranslation)<2*n.b2_linearSlop?(x=m.Clamp(B,-n.b2_maxLinearCorrection, +n.b2_maxLinearCorrection),t=m.Abs(B),k=!0):B<=this.m_lowerTranslation?(x=m.Clamp(B-this.m_lowerTranslation+n.b2_linearSlop,-n.b2_maxLinearCorrection,0),t=this.m_lowerTranslation-B,k=!0):B>=this.m_upperTranslation&&(x=m.Clamp(B-this.m_upperTranslation+n.b2_linearSlop,0,n.b2_maxLinearCorrection),t=B-this.m_upperTranslation,k=!0)}this.m_perp=m.MulMV(w,this.m_localYAxis1);this.m_s1=(f+q)*this.m_perp.y-(b+z)*this.m_perp.x;this.m_s2=A*this.m_perp.y-v*this.m_perp.x;w=new j;z=this.m_perp.x*f+this.m_perp.y* +b;A=p-g-this.m_refAngle;t=m.Max(t,m.Abs(z));q=m.Abs(A);k?(k=this.m_invMassA,v=this.m_invMassB,f=this.m_invIA,b=this.m_invIB,this.m_K.col1.x=k+v+f*this.m_s1*this.m_s1+b*this.m_s2*this.m_s2,this.m_K.col1.y=f*this.m_s1+b*this.m_s2,this.m_K.col1.z=f*this.m_s1*this.m_a1+b*this.m_s2*this.m_a2,this.m_K.col2.x=this.m_K.col1.y,this.m_K.col2.y=f+b,this.m_K.col2.z=f*this.m_a1+b*this.m_a2,this.m_K.col3.x=this.m_K.col1.z,this.m_K.col3.y=this.m_K.col2.z,this.m_K.col3.z=k+v+f*this.m_a1*this.m_a1+b*this.m_a2*this.m_a2, +this.m_K.Solve33(w,-z,-A,-x)):(k=this.m_invMassA,v=this.m_invMassB,f=this.m_invIA,b=this.m_invIB,x=f*this.m_s1+b*this.m_s2,B=f+b,this.m_K.col1.Set(k+v+f*this.m_s1*this.m_s1+b*this.m_s2*this.m_s2,x,0),this.m_K.col2.Set(x,B,0),x=this.m_K.Solve22(new e,-z,-A),w.x=x.x,w.y=x.y,w.z=0);x=w.x*this.m_perp.x+w.z*this.m_axis.x;k=w.x*this.m_perp.y+w.z*this.m_axis.y;z=w.x*this.m_s1+w.y+w.z*this.m_a1;w=w.x*this.m_s2+w.y+w.z*this.m_a2;d.x-=this.m_invMassA*x;d.y-=this.m_invMassA*k;g-=this.m_invIA*z;l.x+=this.m_invMassB* +x;l.y+=this.m_invMassB*k;p+=this.m_invIB*w;a.m_sweep.a=g;c.m_sweep.a=p;a.SynchronizeTransform();c.SynchronizeTransform();return t<=n.b2_linearSlop&&q<=n.b2_angularSlop};Box2D.inherit(H,Box2D.Dynamics.Joints.b2JointDef);H.prototype.__super=Box2D.Dynamics.Joints.b2JointDef.prototype;H.b2PrismaticJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments);this.localAnchorA=new e;this.localAnchorB=new e;this.localAxisA=new e};H.prototype.b2PrismaticJointDef=function(){this.__super.b2JointDef.call(this); +this.type=t.e_prismaticJoint;this.localAxisA.Set(1,0);this.referenceAngle=0;this.enableLimit=!1;this.upperTranslation=this.lowerTranslation=0;this.enableMotor=!1;this.motorSpeed=this.maxMotorForce=0};H.prototype.Initialize=function(a,c,d,e){this.bodyA=a;this.bodyB=c;this.localAnchorA=this.bodyA.GetLocalPoint(d);this.localAnchorB=this.bodyB.GetLocalPoint(d);this.localAxisA=this.bodyA.GetLocalVector(e);this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()};Box2D.inherit(B,Box2D.Dynamics.Joints.b2Joint); +B.prototype.__super=Box2D.Dynamics.Joints.b2Joint.prototype;B.b2PulleyJoint=function(){Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments);this.m_groundAnchor1=new e;this.m_groundAnchor2=new e;this.m_localAnchor1=new e;this.m_localAnchor2=new e;this.m_u1=new e;this.m_u2=new e};B.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchor1)};B.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchor2)};B.prototype.GetReactionForce=function(a){void 0=== +a&&(a=0);return new e(a*this.m_impulse*this.m_u2.x,a*this.m_impulse*this.m_u2.y)};B.prototype.GetReactionTorque=function(){return 0};B.prototype.GetGroundAnchorA=function(){var a=this.m_ground.m_xf.position.Copy();a.Add(this.m_groundAnchor1);return a};B.prototype.GetGroundAnchorB=function(){var a=this.m_ground.m_xf.position.Copy();a.Add(this.m_groundAnchor2);return a};B.prototype.GetLength1=function(){var a=this.m_bodyA.GetWorldPoint(this.m_localAnchor1),c=a.x-(this.m_ground.m_xf.position.x+this.m_groundAnchor1.x), +a=a.y-(this.m_ground.m_xf.position.y+this.m_groundAnchor1.y);return Math.sqrt(c*c+a*a)};B.prototype.GetLength2=function(){var a=this.m_bodyB.GetWorldPoint(this.m_localAnchor2),c=a.x-(this.m_ground.m_xf.position.x+this.m_groundAnchor2.x),a=a.y-(this.m_ground.m_xf.position.y+this.m_groundAnchor2.y);return Math.sqrt(c*c+a*a)};B.prototype.GetRatio=function(){return this.m_ratio};B.prototype.b2PulleyJoint=function(a){this.__super.b2Joint.call(this,a);this.m_ground=this.m_bodyA.m_world.m_groundBody;this.m_groundAnchor1.x= +a.groundAnchorA.x-this.m_ground.m_xf.position.x;this.m_groundAnchor1.y=a.groundAnchorA.y-this.m_ground.m_xf.position.y;this.m_groundAnchor2.x=a.groundAnchorB.x-this.m_ground.m_xf.position.x;this.m_groundAnchor2.y=a.groundAnchorB.y-this.m_ground.m_xf.position.y;this.m_localAnchor1.SetV(a.localAnchorA);this.m_localAnchor2.SetV(a.localAnchorB);this.m_ratio=a.ratio;this.m_constant=a.lengthA+this.m_ratio*a.lengthB;this.m_maxLength1=m.Min(a.maxLengthA,this.m_constant-this.m_ratio*B.b2_minPulleyLength); +this.m_maxLength2=m.Min(a.maxLengthB,(this.m_constant-B.b2_minPulleyLength)/this.m_ratio);this.m_limitImpulse2=this.m_limitImpulse1=this.m_impulse=0};B.prototype.InitVelocityConstraints=function(a){var c=this.m_bodyA,d=this.m_bodyB,e;e=c.m_xf.R;var j=this.m_localAnchor1.x-c.m_sweep.localCenter.x,m=this.m_localAnchor1.y-c.m_sweep.localCenter.y,f=e.col1.x*j+e.col2.x*m,m=e.col1.y*j+e.col2.y*m,j=f;e=d.m_xf.R;var b=this.m_localAnchor2.x-d.m_sweep.localCenter.x,k=this.m_localAnchor2.y-d.m_sweep.localCenter.y, +f=e.col1.x*b+e.col2.x*k,k=e.col1.y*b+e.col2.y*k,b=f;e=d.m_sweep.c.x+b;var f=d.m_sweep.c.y+k,l=this.m_ground.m_xf.position.x+this.m_groundAnchor2.x,r=this.m_ground.m_xf.position.y+this.m_groundAnchor2.y;this.m_u1.Set(c.m_sweep.c.x+j-(this.m_ground.m_xf.position.x+this.m_groundAnchor1.x),c.m_sweep.c.y+m-(this.m_ground.m_xf.position.y+this.m_groundAnchor1.y));this.m_u2.Set(e-l,f-r);e=this.m_u1.Length();f=this.m_u2.Length();e>n.b2_linearSlop?this.m_u1.Multiply(1/e):this.m_u1.SetZero();f>n.b2_linearSlop? +this.m_u2.Multiply(1/f):this.m_u2.SetZero();0n.b2_linearSlop?this.m_u1.Multiply(1/d):this.m_u1.SetZero(),p>n.b2_linearSlop?this.m_u2.Multiply(1/p):this.m_u2.SetZero(),d=this.m_constant-d-this.m_ratio*p,x=m.Max(x,-d),d=m.Clamp(d+n.b2_linearSlop,-n.b2_maxLinearCorrection,0),w=-this.m_pulleyMass*d,d=-w*this.m_u1.x,p=-w*this.m_u1.y,q=-this.m_ratio*w*this.m_u2.x,w=-this.m_ratio*w*this.m_u2.y, +a.m_sweep.c.x+=a.m_invMass*d,a.m_sweep.c.y+=a.m_invMass*p,a.m_sweep.a+=a.m_invI*(b*p-k*d),c.m_sweep.c.x+=c.m_invMass*q,c.m_sweep.c.y+=c.m_invMass*w,c.m_sweep.a+=c.m_invI*(v*w-r*q),a.SynchronizeTransform(),c.SynchronizeTransform());this.m_limitState1==t.e_atUpperLimit&&(d=a.m_xf.R,b=this.m_localAnchor1.x-a.m_sweep.localCenter.x,k=this.m_localAnchor1.y-a.m_sweep.localCenter.y,p=d.col1.x*b+d.col2.x*k,k=d.col1.y*b+d.col2.y*k,b=p,d=a.m_sweep.c.x+b,p=a.m_sweep.c.y+k,this.m_u1.Set(d-e,p-j),d=this.m_u1.Length(), +d>n.b2_linearSlop?(this.m_u1.x*=1/d,this.m_u1.y*=1/d):this.m_u1.SetZero(),d=this.m_maxLength1-d,x=m.Max(x,-d),d=m.Clamp(d+n.b2_linearSlop,-n.b2_maxLinearCorrection,0),w=-this.m_limitMass1*d,d=-w*this.m_u1.x,p=-w*this.m_u1.y,a.m_sweep.c.x+=a.m_invMass*d,a.m_sweep.c.y+=a.m_invMass*p,a.m_sweep.a+=a.m_invI*(b*p-k*d),a.SynchronizeTransform());this.m_limitState2==t.e_atUpperLimit&&(d=c.m_xf.R,v=this.m_localAnchor2.x-c.m_sweep.localCenter.x,r=this.m_localAnchor2.y-c.m_sweep.localCenter.y,p=d.col1.x*v+d.col2.x* +r,r=d.col1.y*v+d.col2.y*r,v=p,q=c.m_sweep.c.x+v,w=c.m_sweep.c.y+r,this.m_u2.Set(q-l,w-f),p=this.m_u2.Length(),p>n.b2_linearSlop?(this.m_u2.x*=1/p,this.m_u2.y*=1/p):this.m_u2.SetZero(),d=this.m_maxLength2-p,x=m.Max(x,-d),d=m.Clamp(d+n.b2_linearSlop,-n.b2_maxLinearCorrection,0),w=-this.m_limitMass2*d,q=-w*this.m_u2.x,w=-w*this.m_u2.y,c.m_sweep.c.x+=c.m_invMass*q,c.m_sweep.c.y+=c.m_invMass*w,c.m_sweep.a+=c.m_invI*(v*w-r*q),c.SynchronizeTransform());return x=this.m_upperAngle?(this.m_limitState!= +t.e_atUpperLimit&&(this.m_impulse.z=0),this.m_limitState=t.e_atUpperLimit):(this.m_limitState=t.e_inactiveLimit,this.m_impulse.z=0)}else this.m_limitState=t.e_inactiveLimit;a.warmStarting?(this.m_impulse.x*=a.dtRatio,this.m_impulse.y*=a.dtRatio,this.m_motorImpulse*=a.dtRatio,a=this.m_impulse.x,q=this.m_impulse.y,c.m_linearVelocity.x-=e*a,c.m_linearVelocity.y-=e*q,c.m_angularVelocity-=r*(l*q-f*a+this.m_motorImpulse+this.m_impulse.z),d.m_linearVelocity.x+=j*a,d.m_linearVelocity.y+=j*q,d.m_angularVelocity+= +p*(b*q-k*a+this.m_motorImpulse+this.m_impulse.z)):(this.m_impulse.SetZero(),this.m_motorImpulse=0)};E.prototype.SolveVelocityConstraints=function(a){var c=this.m_bodyA,d=this.m_bodyB,e=0,j=e=0,l=0,f=0,b=0,k=c.m_linearVelocity,n=c.m_angularVelocity,r=d.m_linearVelocity,p=d.m_angularVelocity,q=c.m_invMass,w=d.m_invMass,x=c.m_invI,A=d.m_invI;this.m_enableMotor&&this.m_limitState!=t.e_equalLimits&&(j=this.m_motorMass*-(p-n-this.m_motorSpeed),l=this.m_motorImpulse,f=a.dt*this.m_maxMotorTorque,this.m_motorImpulse= +m.Clamp(this.m_motorImpulse+j,-f,f),j=this.m_motorImpulse-l,n-=x*j,p+=A*j);if(this.m_enableLimit&&this.m_limitState!=t.e_inactiveLimit){var a=c.m_xf.R,j=this.m_localAnchor1.x-c.m_sweep.localCenter.x,l=this.m_localAnchor1.y-c.m_sweep.localCenter.y,e=a.col1.x*j+a.col2.x*l,l=a.col1.y*j+a.col2.y*l,j=e,a=d.m_xf.R,f=this.m_localAnchor2.x-d.m_sweep.localCenter.x,b=this.m_localAnchor2.y-d.m_sweep.localCenter.y,e=a.col1.x*f+a.col2.x*b,b=a.col1.y*f+a.col2.y*b,f=e,a=r.x+-p*b-k.x- -n*l,z=r.y+p*f-k.y-n*j;this.m_mass.Solve33(this.impulse3, +-a,-z,-(p-n));this.m_limitState==t.e_equalLimits?this.m_impulse.Add(this.impulse3):this.m_limitState==t.e_atLowerLimit?(e=this.m_impulse.z+this.impulse3.z,0>e&&(this.m_mass.Solve22(this.reduced,-a,-z),this.impulse3.x=this.reduced.x,this.impulse3.y=this.reduced.y,this.impulse3.z=-this.m_impulse.z,this.m_impulse.x+=this.reduced.x,this.m_impulse.y+=this.reduced.y,this.m_impulse.z=0)):this.m_limitState==t.e_atUpperLimit&&(e=this.m_impulse.z+this.impulse3.z,0z*z&&(q=1/(l+w),f=q*-f,b=q*-b,d.m_sweep.c.x-=0.5*l*f,d.m_sweep.c.y-=0.5*l*b,e.m_sweep.c.x+=0.5*w*f,e.m_sweep.c.y+=0.5*w*b,f=e.m_sweep.c.x+r-d.m_sweep.c.x- +k,b=e.m_sweep.c.y+p-d.m_sweep.c.y-a);this.K1.col1.x=l+w;this.K1.col2.x=0;this.K1.col1.y=0;this.K1.col2.y=l+w;this.K2.col1.x=x*a*a;this.K2.col2.x=-x*k*a;this.K2.col1.y=-x*k*a;this.K2.col2.y=x*k*k;this.K3.col1.x=A*p*p;this.K3.col2.x=-A*r*p;this.K3.col1.y=-A*r*p;this.K3.col2.y=A*r*r;this.K.SetM(this.K1);this.K.AddM(this.K2);this.K.AddM(this.K3);this.K.Solve(E.tImpulse,-f,-b);f=E.tImpulse.x;b=E.tImpulse.y;d.m_sweep.c.x-=d.m_invMass*f;d.m_sweep.c.y-=d.m_invMass*b;d.m_sweep.a-=d.m_invI*(k*b-a*f);e.m_sweep.c.x+= +e.m_invMass*f;e.m_sweep.c.y+=e.m_invMass*b;e.m_sweep.a+=e.m_invI*(r*b-p*f);d.SynchronizeTransform();e.SynchronizeTransform();return c<=n.b2_linearSlop&&j<=n.b2_angularSlop};Box2D.postDefs.push(function(){Box2D.Dynamics.Joints.b2RevoluteJoint.tImpulse=new e});Box2D.inherit(G,Box2D.Dynamics.Joints.b2JointDef);G.prototype.__super=Box2D.Dynamics.Joints.b2JointDef.prototype;G.b2RevoluteJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments);this.localAnchorA=new e;this.localAnchorB= +new e};G.prototype.b2RevoluteJointDef=function(){this.__super.b2JointDef.call(this);this.type=t.e_revoluteJoint;this.localAnchorA.Set(0,0);this.localAnchorB.Set(0,0);this.motorSpeed=this.maxMotorTorque=this.upperAngle=this.lowerAngle=this.referenceAngle=0;this.enableMotor=this.enableLimit=!1};G.prototype.Initialize=function(a,c,d){this.bodyA=a;this.bodyB=c;this.localAnchorA=this.bodyA.GetLocalPoint(d);this.localAnchorB=this.bodyB.GetLocalPoint(d);this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()}; +Box2D.inherit(N,Box2D.Dynamics.Joints.b2Joint);N.prototype.__super=Box2D.Dynamics.Joints.b2Joint.prototype;N.b2WeldJoint=function(){Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this,arguments);this.m_localAnchorA=new e;this.m_localAnchorB=new e;this.m_impulse=new j;this.m_mass=new p};N.prototype.GetAnchorA=function(){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA)};N.prototype.GetAnchorB=function(){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB)};N.prototype.GetReactionForce=function(a){void 0=== +a&&(a=0);return new e(a*this.m_impulse.x,a*this.m_impulse.y)};N.prototype.GetReactionTorque=function(a){void 0===a&&(a=0);return a*this.m_impulse.z};N.prototype.b2WeldJoint=function(a){this.__super.b2Joint.call(this,a);this.m_localAnchorA.SetV(a.localAnchorA);this.m_localAnchorB.SetV(a.localAnchorB);this.m_referenceAngle=a.referenceAngle;this.m_impulse.SetZero();this.m_mass=new p};N.prototype.InitVelocityConstraints=function(a){var c,d=0,e=this.m_bodyA,j=this.m_bodyB;c=e.m_xf.R;var l=this.m_localAnchorA.x- +e.m_sweep.localCenter.x,f=this.m_localAnchorA.y-e.m_sweep.localCenter.y,d=c.col1.x*l+c.col2.x*f,f=c.col1.y*l+c.col2.y*f,l=d;c=j.m_xf.R;var b=this.m_localAnchorB.x-j.m_sweep.localCenter.x,k=this.m_localAnchorB.y-j.m_sweep.localCenter.y,d=c.col1.x*b+c.col2.x*k,k=c.col1.y*b+c.col2.y*k,b=d;c=e.m_invMass;var d=j.m_invMass,m=e.m_invI,n=j.m_invI;this.m_mass.col1.x=c+d+f*f*m+k*k*n;this.m_mass.col2.x=-f*l*m-k*b*n;this.m_mass.col3.x=-f*m-k*n;this.m_mass.col1.y=this.m_mass.col2.x;this.m_mass.col2.y=c+d+l*l* +m+b*b*n;this.m_mass.col3.y=l*m+b*n;this.m_mass.col1.z=this.m_mass.col3.x;this.m_mass.col2.z=this.m_mass.col3.y;this.m_mass.col3.z=m+n;a.warmStarting?(this.m_impulse.x*=a.dtRatio,this.m_impulse.y*=a.dtRatio,this.m_impulse.z*=a.dtRatio,e.m_linearVelocity.x-=c*this.m_impulse.x,e.m_linearVelocity.y-=c*this.m_impulse.y,e.m_angularVelocity-=m*(l*this.m_impulse.y-f*this.m_impulse.x+this.m_impulse.z),j.m_linearVelocity.x+=d*this.m_impulse.x,j.m_linearVelocity.y+=d*this.m_impulse.y,j.m_angularVelocity+=n* +(b*this.m_impulse.y-k*this.m_impulse.x+this.m_impulse.z)):this.m_impulse.SetZero()};N.prototype.SolveVelocityConstraints=function(){var a,c=0,d=this.m_bodyA,e=this.m_bodyB,l=d.m_linearVelocity,m=d.m_angularVelocity,f=e.m_linearVelocity,b=e.m_angularVelocity,k=d.m_invMass,n=e.m_invMass,r=d.m_invI,p=e.m_invI;a=d.m_xf.R;var q=this.m_localAnchorA.x-d.m_sweep.localCenter.x,t=this.m_localAnchorA.y-d.m_sweep.localCenter.y,c=a.col1.x*q+a.col2.x*t,t=a.col1.y*q+a.col2.y*t,q=c;a=e.m_xf.R;var w=this.m_localAnchorB.x- +e.m_sweep.localCenter.x,x=this.m_localAnchorB.y-e.m_sweep.localCenter.y,c=a.col1.x*w+a.col2.x*x,x=a.col1.y*w+a.col2.y*x,w=c;a=f.x-b*x-l.x+m*t;var c=f.y+b*w-l.y-m*q,A=b-m,z=new j;this.m_mass.Solve33(z,-a,-c,-A);this.m_impulse.Add(z);l.x-=k*z.x;l.y-=k*z.y;m-=r*(q*z.y-t*z.x+z.z);f.x+=n*z.x;f.y+=n*z.y;b+=p*(w*z.y-x*z.x+z.z);d.m_angularVelocity=m;e.m_angularVelocity=b};N.prototype.SolvePositionConstraints=function(){var a,c=0,d=this.m_bodyA,e=this.m_bodyB;a=d.m_xf.R;var l=this.m_localAnchorA.x-d.m_sweep.localCenter.x, +r=this.m_localAnchorA.y-d.m_sweep.localCenter.y,c=a.col1.x*l+a.col2.x*r,r=a.col1.y*l+a.col2.y*r,l=c;a=e.m_xf.R;var f=this.m_localAnchorB.x-e.m_sweep.localCenter.x,b=this.m_localAnchorB.y-e.m_sweep.localCenter.y,c=a.col1.x*f+a.col2.x*b,b=a.col1.y*f+a.col2.y*b,f=c;a=d.m_invMass;var c=e.m_invMass,k=d.m_invI,p=e.m_invI,q=e.m_sweep.c.x+f-d.m_sweep.c.x-l,t=e.m_sweep.c.y+b-d.m_sweep.c.y-r,w=e.m_sweep.a-d.m_sweep.a-this.m_referenceAngle,x=10*n.b2_linearSlop,z=Math.sqrt(q*q+t*t),A=m.Abs(w);z>x&&(k*=1,p*=1); +this.m_mass.col1.x=a+c+r*r*k+b*b*p;this.m_mass.col2.x=-r*l*k-b*f*p;this.m_mass.col3.x=-r*k-b*p;this.m_mass.col1.y=this.m_mass.col2.x;this.m_mass.col2.y=a+c+l*l*k+f*f*p;this.m_mass.col3.y=l*k+f*p;this.m_mass.col1.z=this.m_mass.col3.x;this.m_mass.col2.z=this.m_mass.col3.y;this.m_mass.col3.z=k+p;x=new j;this.m_mass.Solve33(x,-q,-t,-w);d.m_sweep.c.x-=a*x.x;d.m_sweep.c.y-=a*x.y;d.m_sweep.a-=k*(l*x.y-r*x.x+x.z);e.m_sweep.c.x+=c*x.x;e.m_sweep.c.y+=c*x.y;e.m_sweep.a+=p*(f*x.y-b*x.x+x.z);d.SynchronizeTransform(); +e.SynchronizeTransform();return z<=n.b2_linearSlop&&A<=n.b2_angularSlop};Box2D.inherit(I,Box2D.Dynamics.Joints.b2JointDef);I.prototype.__super=Box2D.Dynamics.Joints.b2JointDef.prototype;I.b2WeldJointDef=function(){Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this,arguments);this.localAnchorA=new e;this.localAnchorB=new e};I.prototype.b2WeldJointDef=function(){this.__super.b2JointDef.call(this);this.type=t.e_weldJoint;this.referenceAngle=0};I.prototype.Initialize=function(a,c,d){this.bodyA=a; +this.bodyB=c;this.localAnchorA.SetV(this.bodyA.GetLocalPoint(d));this.localAnchorB.SetV(this.bodyB.GetLocalPoint(d));this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()}})(); +(function(){var n=Box2D.Dynamics.b2DebugDraw;n.b2DebugDraw=function(){this.m_xformScale=this.m_fillAlpha=this.m_alpha=this.m_lineThickness=this.m_drawScale=1;var n=this;this.m_sprite={graphics:{clear:function(){n.m_ctx.clearRect(0,0,n.m_ctx.canvas.width,n.m_ctx.canvas.height)}}}};n.prototype._color=function(n,p){return"rgba("+((n&16711680)>>16)+","+((n&65280)>>8)+","+(n&255)+","+p+")"};n.prototype.b2DebugDraw=function(){this.m_drawFlags=0};n.prototype.SetFlags=function(n){void 0===n&&(n=0);this.m_drawFlags= +n};n.prototype.GetFlags=function(){return this.m_drawFlags};n.prototype.AppendFlags=function(n){void 0===n&&(n=0);this.m_drawFlags|=n};n.prototype.ClearFlags=function(n){void 0===n&&(n=0);this.m_drawFlags&=~n};n.prototype.SetSprite=function(n){this.m_ctx=n};n.prototype.GetSprite=function(){return this.m_ctx};n.prototype.SetDrawScale=function(n){void 0===n&&(n=0);this.m_drawScale=n};n.prototype.GetDrawScale=function(){return this.m_drawScale};n.prototype.SetLineThickness=function(n){void 0===n&&(n= +0);this.m_lineThickness=n;this.m_ctx.strokeWidth=n};n.prototype.GetLineThickness=function(){return this.m_lineThickness};n.prototype.SetAlpha=function(n){void 0===n&&(n=0);this.m_alpha=n};n.prototype.GetAlpha=function(){return this.m_alpha};n.prototype.SetFillAlpha=function(n){void 0===n&&(n=0);this.m_fillAlpha=n};n.prototype.GetFillAlpha=function(){return this.m_fillAlpha};n.prototype.SetXFormScale=function(n){void 0===n&&(n=0);this.m_xformScale=n};n.prototype.GetXFormScale=function(){return this.m_xformScale}; +n.prototype.DrawPolygon=function(n,p,m){if(p){var e=this.m_ctx,j=this.m_drawScale;e.beginPath();e.strokeStyle=this._color(m.color,this.m_alpha);e.moveTo(n[0].x*j,n[0].y*j);for(m=1;m>4,d=(d&15)<<4|f>>2,e=(f&3)<<6|g,b.push(String.fromCharCode(c)),64!=f&&b.push(String.fromCharCode(d)),64!=g&&b.push(String.fromCharCode(e));return b=b.join("")}; +cc.Codec.Base64.decodeAsArray=function(a,b){var c=this.decode(a),d=[],e,f,g;e=0;for(g=c.length/b;e>=1;0==this.bb&&(this.bb=this.readByte(),a=this.bb&1,this.bb=this.bb>>1|128);return a}; +cc.Codec.GZip.prototype.readBits=function(a){for(var b=0,c=a;c--;)b=b<<1|this.readBit();a&&(b=cc.Codec.GZip.bitReverse[b]>>8-a);return b};cc.Codec.GZip.prototype.flushBuffer=function(){this.bIdx=0};cc.Codec.GZip.prototype.addBuffer=function(a){this.buf32k[this.bIdx++]=a;this.outputArr.push(String.fromCharCode(a));32768==this.bIdx&&(this.bIdx=0)}; +cc.Codec.GZip.prototype.IsPat=function(){for(;;){if(this.fpos[this.len]>=this.fmax)return-1;if(this.flens[this.fpos[this.len]]==this.len)return this.fpos[this.len]++;this.fpos[this.len]++}}; +cc.Codec.GZip.prototype.Rec=function(){var a=this.Places[this.treepos],b;if(17==this.len)return-1;this.treepos++;this.len++;b=this.IsPat();if(0<=b)a.b0=b;else if(a.b0=32768,this.Rec())return-1;b=this.IsPat();if(0<=b)a.b1=b,a.jump=null;else if(a.b1=32768,a.jump=this.Places[this.treepos],a.jumppos=this.treepos,this.Rec())return-1;this.len--;return 0}; +cc.Codec.GZip.prototype.CreateTree=function(a,b,c){this.Places=a;this.treepos=0;this.flens=c;this.fmax=b;for(a=0;17>a;a++)this.fpos[a]=0;this.len=0;return this.Rec()?-1:0};cc.Codec.GZip.prototype.DecodeValue=function(a){for(var b,c,d=0,e=a[d];;)if(b=this.readBit()){if(!(e.b1&32768))return e.b1;e=e.jump;b=a.length;for(c=0;c>1,23c)this.addBuffer(c); +else if(256==c)break;else{var f;c-=257;e=this.readBits(cc.Codec.GZip.cplext[c])+cc.Codec.GZip.cplens[c];c=cc.Codec.GZip.bitReverse[this.readBits(5)]>>3;8c;c++)g[c]=0; +for(c=0;cc)g[d++]=c;else if(16==c){var j;c=3+this.readBits(2);if(d+c>e)return this.flushBuffer(),1;for(j=d?g[d-1]:0;c--;)g[d++]=j}else{c=17==c?3+this.readBits(3):11+this.readBits(7);if(d+c>e)return this.flushBuffer(), +1;for(;c--;)g[d++]=0}e=this.literalTree.length;for(d=0;d>8&255;b.b=a>>16&255;return b};cc.c3=cc.c3b; +cc.white=function(){return new cc.Color3B(255,255,255)};cc.yellow=function(){return new cc.Color3B(255,255,0)};cc.blue=function(){return new cc.Color3B(0,0,255)};cc.green=function(){return new cc.Color3B(0,255,0)};cc.red=function(){return new cc.Color3B(255,0,0)};cc.magenta=function(){return new cc.Color3B(255,0,255)};cc.black=function(){return new cc.Color3B(0,0,0)};cc.orange=function(){return new cc.Color3B(255,127,0)};cc.gray=function(){return new cc.Color3B(166,166,166)}; +cc.Color4B=function(a,b,c,d){this.r=a;this.g=b;this.b=c;this.a=d};cc.c4b=function(a,b,c,d){return new cc.Color4B(a,b,c,d)};cc.c4=cc.c4b;cc.Color4F=function(a,b,c,d){this.r=a;this.g=b;this.b=c;this.a=d};cc.c4f=function(a,b,c,d){return new cc.Color4F(a,b,c,d)};cc.c4FFromccc3B=function(a){return new cc.Color4F(a.r/255,a.g/255,a.b/255,1)};cc.c4FFromccc4B=function(a){return new cc.Color4F(a.r/255,a.g/255,a.b/255,a.a/255)};cc.c4FEqual=function(a,b){return a.r==b.r&&a.g==b.g&&a.b==b.b&&a.a==b.a}; +cc.Vertex2F=function(a,b){this.x=a||0;this.y=b||0};cc.Vertex2=function(a,b){return new cc.Vertex2F(a,b)};cc.Vertex3F=function(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0};cc.vertex3=function(a,b,c){return new cc.Vertex3F(a,b,c)};cc.Tex2F=function(a,b){this.u=a||0;this.v=b||0};cc.tex2=function(a,b){return new cc.Tex2F(a,b)};cc.PointSprite=function(a,b,c){this.pos=a||new cc.Vertex2F(0,0);this.color=b||new cc.Color4B(0,0,0,0);this.size=c||0}; +cc.Quad2=function(a,b,c,d){this.tl=a||new cc.Vertex2F(0,0);this.tr=b||new cc.Vertex2F(0,0);this.bl=c||new cc.Vertex2F(0,0);this.br=d||new cc.Vertex2F(0,0)};cc.Quad3=function(a,b,c,d){this.bl=a||new cc.Vertex3F(0,0,0);this.br=b||new cc.Vertex3F(0,0,0);this.tl=c||new cc.Vertex3F(0,0,0);this.tr=d||new cc.Vertex3F(0,0,0)};cc.GridSize=function(a,b){this.x=a;this.y=b};cc.g=function(a,b){return new cc.GridSize(a,b)}; +cc.V2F_C4B_T2F=function(a,b,c){this.vertices=a||new cc.Vertex2F(0,0);this.colors=b||new cc.Color4B(0,0,0,0);this.texCoords=c||new cc.Tex2F(0,0)};cc.V2F_C4F_T2F=function(a,b,c){this.vertices=a||new cc.Vertex2F(0,0);this.colors=b||new cc.Color4F(0,0,0,0);this.texCoords=c||new cc.Tex2F(0,0)};cc.V3F_C4B_T2F=function(a,b,c){this.vertices=a||new cc.Vertex3F(0,0,0);this.colors=b||new cc.Color4B(0,0,0,0);this.texCoords=c||new cc.Tex2F(0,0)}; +cc.V2F_C4B_T2F_Quad=function(a,b,c,d){this.bl=a||new cc.V2F_C4B_T2F;this.br=b||new cc.V2F_C4B_T2F;this.tl=c||new cc.V2F_C4B_T2F;this.tr=d||new cc.V2F_C4B_T2F}; +cc.V2F_C4B_T2F_QuadZero=function(){return new cc.V2F_C4B_T2F_Quad(new cc.V2F_C4B_T2F(new cc.Vertex2F(0,0),new cc.Color4B(0,0,0,255),new cc.Tex2F(0,0)),new cc.V2F_C4B_T2F(new cc.Vertex2F(0,0),new cc.Color4B(0,0,0,255),new cc.Tex2F(0,0)),new cc.V2F_C4B_T2F(new cc.Vertex2F(0,0),new cc.Color4B(0,0,0,255),new cc.Tex2F(0,0)),new cc.V2F_C4B_T2F(new cc.Vertex2F(0,0),new cc.Color4B(0,0,0,255),new cc.Tex2F(0,0)))}; +cc.V3F_C4B_T2F_Quad=function(a,b,c,d){this.tl=a||new cc.V3F_C4B_T2F;this.bl=b||new cc.V3F_C4B_T2F;this.tr=c||new cc.V3F_C4B_T2F;this.br=d||new cc.V3F_C4B_T2F}; +cc.V3F_C4B_T2F_QuadZero=function(){return new cc.V3F_C4B_T2F_Quad(new cc.V3F_C4B_T2F(new cc.Vertex3F(0,0,0),new cc.Color4B(0,0,0,255),new cc.Tex2F(0,0)),new cc.V3F_C4B_T2F(new cc.Vertex3F(0,0,0),new cc.Color4B(0,0,0,255),new cc.Tex2F(0,0)),new cc.V3F_C4B_T2F(new cc.Vertex3F(0,0,0),new cc.Color4B(0,0,0,255),new cc.Tex2F(0,0)),new cc.V3F_C4B_T2F(new cc.Vertex3F(0,0,0),new cc.Color4B(0,0,0,255),new cc.Tex2F(0,0)))}; +cc.V2F_C4F_T2F_Quad=function(a,b,c,d){this.bl=a||new cc.V2F_C4F_T2F;this.br=b||new cc.V2F_C4F_T2F;this.tl=c||new cc.V2F_C4F_T2F;this.tr=d||new cc.V2F_C4F_T2F};cc.BlendFunc=function(a,b){this.src=a;this.dst=b};cc.TEXT_ALIGNMENT_LEFT=0;cc.TEXT_ALIGNMENT_CENTER=1;cc.TEXT_ALIGNMENT_RIGHT=2;cc.VERTICAL_TEXT_ALIGNMENT_TOP=0;cc.VERTICAL_TEXT_ALIGNMENT_CENTER=1;cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM=2;cc.Point=function(a,b){this.x=a||0;this.y=b||0};cc.p=function(a,b){return{x:a,y:b}};cc.Point.CCPointEqualToPoint=function(a,b){return a.x==b.x&&a.y==b.y};cc.Size=function(a,b){this.width=a||0;this.height=b||0};cc.Size.CCSizeEqualToSize=function(a,b){return a.width==b.width&&a.height==b.height}; +cc.Rect=function(a,b,c,d){switch(arguments.length){case 0:this.origin=cc.p(0,0);this.size=cc.size(0,0);break;case 1:if(a)if(a instanceof cc.Rect)this.origin=cc.p(a.origin.x,a.origin.y),this.size=cc.size(a.size.width,a.size.height);else throw"unknown argument type";else this.origin=cc.p(0,0),this.size=cc.size(0,0);break;case 2:this.origin=a?cc.p(a.x,a.y):cc.p(0,0);this.size=b?cc.size(b.width,b.height):cc.size(0,0);break;case 4:this.origin=cc.p(a||0,b||0);this.size=cc.size(c||0,d||0);break;default:throw"unknown argument type"; +}};cc.Rect.CCRectEqualToRect=function(a,b){return cc.Point.CCPointEqualToPoint(a.origin,b.origin)&&cc.Size.CCSizeEqualToSize(a.size,b.size)};cc.Rect.CCRectContainsRect=function(a,b){return!a||!b||a.origin.x>=b.origin.x||a.origin.y>=b.origin.y||a.origin.x+a.size.width<=b.origin.x+b.size.width||a.origin.y+a.size.height<=b.origin.y+b.size.height?!1:!0};cc.Rect.CCRectGetMaxX=function(a){return a.origin.x+a.size.width};cc.Rect.CCRectGetMidX=function(a){return a.origin.x+a.size.width/2}; +cc.Rect.CCRectGetMinX=function(a){return a.origin.x};cc.Rect.CCRectGetMaxY=function(a){return a.origin.y+a.size.height};cc.Rect.CCRectGetMidY=function(a){return a.origin.y+a.size.height/2};cc.Rect.CCRectGetMinY=function(a){return a.origin.y};cc.Rect.CCRectContainsPoint=function(a,b){var c=!1;b.x>=cc.Rect.CCRectGetMinX(a)&&(b.x<=cc.Rect.CCRectGetMaxX(a)&&b.y>=cc.Rect.CCRectGetMinY(a)&&b.y<=cc.Rect.CCRectGetMaxY(a))&&(c=!0);return c}; +cc.Rect.CCRectIntersectsRect=function(a,b){return!(cc.Rect.CCRectGetMaxX(a)d))if(c=a.substr(c+1,d-c-1),0!=c.length){var d=c.indexOf("{"),e=c.indexOf("}");-1!=d||-1!=e||(b=c.split(","))}}return b}; +cc.RectFromString=function(a){var b=cc.RectZero();if(a){var c=a.indexOf("{")+1,d=a.lastIndexOf("}",a.length);-1==c||-1==d||(a=a.substring(c,d),c=a.indexOf("}"),-1!=c&&(c=a.indexOf(",",c),-1!=c&&(b=a.substr(0,c),a=a.substr(c+1,a.length-c),c=cc.splitWithForm(b),b=cc.splitWithForm(a),a=parseFloat(c[0]),c=parseFloat(c[1]),d=parseFloat(b[0]),b=parseFloat(b[1]),b=cc.rect(a,c,d,b))))}return b}; +cc.PointFromString=function(a){var b=cc.PointZero();try{if(""==a)return b;var c=cc.splitWithForm(a),d=parseFloat(c[0]),e=parseFloat(c[1]),b=cc.p(d,e)}catch(f){}return b};cc.SizeFromString=function(a){var b=cc.SizeZero();try{if(""==a)return b;var c=cc.splitWithForm(a),d=parseFloat(c[0]),e=parseFloat(c[1]),b=cc.size(d,e)}catch(f){}return b};cc.AffineTransform=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.d=d;this.tx=e;this.ty=f};cc.__AffineTransformMake=function(a,b,c,d,e,f){return new cc.AffineTransform(a,b,c,d,e,f)};cc.AffineTransformMake=function(a,b,c,d,e,f){return new cc.AffineTransform(a,b,c,d,e,f)};cc.__PointApplyAffineTransform=function(a,b){var c=cc.p(0,0);c.x=b.a*a.x+b.c*a.y+b.tx;c.y=b.b*a.x+b.d*a.y+b.ty;return c};cc.PointApplyAffineTransform=function(a,b){return cc.__PointApplyAffineTransform(a,b)}; +cc.__SizeApplyAffineTransform=function(a,b){var c=cc.size(0,0);c.width=b.a*a.width+b.c*a.height;c.height=b.b*a.width+b.d*a.height;return c};cc.SizeApplyAffineTransform=function(a,b){return cc.__SizeApplyAffineTransform(a,b)};cc.AffineTransformMakeIdentity=function(){return cc.__AffineTransformMake(1,0,0,1,0,0)};cc.AffineTransformIdentity=function(){return cc.AffineTransformMakeIdentity()}; +cc.RectApplyAffineTransform=function(a,b){var c=cc.Rect.CCRectGetMinY(a),d=cc.Rect.CCRectGetMinX(a),e=cc.Rect.CCRectGetMaxX(a),f=cc.Rect.CCRectGetMaxY(a),g=cc.PointApplyAffineTransform(cc.p(d,c),b),c=cc.PointApplyAffineTransform(cc.p(e,c),b),d=cc.PointApplyAffineTransform(cc.p(d,f),b),h=cc.PointApplyAffineTransform(cc.p(e,f),b),e=Math.min(Math.min(g.x,c.x),Math.min(d.x,h.x)),f=Math.max(Math.max(g.x,c.x),Math.max(d.x,h.x)),j=Math.min(Math.min(g.y,c.y),Math.min(d.y,h.y)),g=Math.max(Math.max(g.y,c.y), +Math.max(d.y,h.y));return cc.rect(e,j,f-e,g-j)};cc.AffineTransformTranslate=function(a,b,c){return cc.__AffineTransformMake(a.a,a.b,a.c,a.d,a.tx+a.a*b+a.c*c,a.ty+a.b*b+a.d*c)};cc.AffineTransformScale=function(a,b,c){return cc.__AffineTransformMake(a.a*b,a.b*b,a.c*c,a.d*c,a.tx,a.ty)};cc.AffineTransformRotate=function(a,b){var c=Math.sin(b),d=Math.cos(b);return cc.__AffineTransformMake(a.a*d+a.c*c,a.b*d+a.d*c,a.c*d-a.a*c,a.d*d-a.b*c,a.tx,a.ty)}; +cc.AffineTransformConcat=function(a,b){return cc.__AffineTransformMake(a.a*b.a+a.b*b.c,a.a*b.b+a.b*b.d,a.c*b.a+a.d*b.c,a.c*b.b+a.d*b.d,a.tx*b.a+a.ty*b.c+b.tx,a.tx*b.b+a.ty*b.d+b.ty)};cc.AffineTransformEqualToTransform=function(a,b){return a.a==b.a&&a.b==b.b&&a.c==b.c&&a.d==b.d&&a.tx==b.tx&&a.ty==b.ty};cc.AffineTransformInvert=function(a){var b=1/(a.a*a.d-a.b*a.c);return cc.__AffineTransformMake(b*a.d,-b*a.b,-b*a.c,b*a.a,b*(a.c*a.ty-a.d*a.tx),b*(a.b*a.tx-a.a*a.ty))};cc.POINT_EPSILON=parseFloat("1.192092896e-07F");cc.pNeg=function(a){return cc.p(-a.x,-a.y)};cc.pAdd=function(a,b){return cc.p(a.x+b.x,a.y+b.y)};cc.pSub=function(a,b){return cc.p(a.x-b.x,a.y-b.y)};cc.pMult=function(a,b){return cc.p(a.x*b,a.y*b)};cc.pMidpoint=function(a,b){return cc.pMult(cc.pAdd(a,b),0.5)};cc.pDot=function(a,b){return a.x*b.x+a.y*b.y};cc.pCross=function(a,b){return a.x*b.y-a.y*b.x};cc.pPerp=function(a){return cc.p(-a.y,a.x)};cc.pRPerp=function(a){return cc.p(a.y,-a.x)}; +cc.pProject=function(a,b){return cc.pMult(b,cc.pDot(a,b)/cc.pDot(b,b))};cc.pRotate=function(a,b){return cc.p(a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x)};cc.pUnrotate=function(a,b){return cc.p(a.x*b.x+a.y*b.y,a.y*b.x-a.x*b.y)};cc.pLengthSQ=function(a){return cc.pDot(a,a)};cc.pLength=function(a){return Math.sqrt(cc.pLengthSQ(a))};cc.pDistance=function(a,b){return cc.pLength(cc.pSub(a,b))};cc.pNormalize=function(a){return cc.pMult(a,1/cc.pLength(a))};cc.pForAngle=function(a){return cc.p(Math.cos(a),Math.sin(a))}; +cc.pToAngle=function(a){return Math.atan2(a.y,a.x)};cc.clampf=function(a,b,c){if(b>c)var d=b,b=c,c=d;return a=e.x&&0<=e.y&&1>=e.y?!0:!1}; +cc.pIntersectPoint=function(a,b,c,d){var e=cc.p(0,0);return cc.pLineIntersect(a,b,c,d,e)?(c=cc.p(0,0),c.x=a.x+e.x*(b.x-a.x),c.y=a.y+e.x*(b.y-a.y),c):cc.PointZero()};cc.pSameAs=function(a,b){return a.x&&b.x?a.x==b.x&&a.y==b.y:!1};cc.NODE_TAG_INVALID=-1;cc.NODE_ON_ENTER=null;cc.NODE_ON_EXIT=null;cc.saveContext=function(){cc.renderContextType==cc.CANVAS&&cc.renderContext.save()};cc.restoreContext=function(){cc.renderContextType==cc.CANVAS&&cc.renderContext.restore()};cc.s_globalOrderOfArrival=1; +cc.Node=cc.Class.extend({_zOrder:0,_vertexZ:0,_rotation:0,_scaleX:1,_scaleY:1,_position:cc.p(0,0),_skewX:0,_skewY:0,_children:null,_camera:null,_grid:null,_isVisible:!0,_anchorPoint:cc.p(0,0),_anchorPointInPoints:cc.p(0,0),_contentSize:cc.SizeZero(),_isRunning:!1,_parent:null,_ignoreAnchorPointForPosition:!1,_tag:cc.NODE_TAG_INVALID,_userData:null,_userObject:null,_isTransformDirty:!0,_isInverseDirty:!0,_isCacheDirty:!0,_isTransformGLDirty:null,_transform:null,_inverse:null,_reorderChildDirty:!1, +_shaderProgram:null,_orderOfArrival:0,_glServerState:null,_actionManager:null,_scheduler:null,ctor:function(){cc.NODE_TRANSFORM_USING_AFFINE_MATRIX&&(this._isTransformGLDirty=!0);this._anchorPoint=cc.p(0,0);this._anchorPointInPoints=cc.p(0,0);this._contentSize=cc.size(0,0);this._position=cc.p(0,0);var a=cc.Director.getInstance();this._actionManager=a.getActionManager();this.getActionManager=function(){return this._actionManager};this._scheduler=a.getScheduler();this.getScheduler=function(){return this._scheduler}}, +_arrayMakeObjectsPerformSelector:function(a,b){if(a&&0!=a.length){var c;switch(b){case cc.Node.StateCallbackType.onEnter:for(c=0;c"},_childrenAlloc:function(){this._children=[]},getChildByTag:function(a){cc.Assert(a!=cc.NODE_TAG_INVALID,"Invalid tag");if(null!=this._children)for(var b=0;bb){this._children=cc.ArrayAppendObjectToIndex(this._children,a,c);break}}a._setZOrder(b)},reorderChild:function(a,b){cc.Assert(null!=a,"Child must be non-nil");this._reorderChildDirty=!0;a.setOrderOfArrival(cc.s_globalOrderOfArrival++);a._setZOrder(b);this.setNodeDirty()},sortAllChildren:function(){if(this._reorderChildDirty){var a, +b,c=this._children.length;for(a=0;athis._children[b]._zOrder)this._children[b].visit(a);else break;this.draw(a);if(this._children)for(;bthis._children[b]._zOrder)this._children[b].visit(a);else break;this.draw(a);if(this._children)for(;bd.startPos.y?d.target.setRotation(-b+d.startRot):d.target.setRotation(b+d.startRot);d.updateNumbers()}else"scale"==d.mode?(c=a.clientY-d.initialpos.y,b=a.clientX-d.initialpos.x, +e=d.target.getScaleX(),k=d.target.getScaleY(),d.target.setScale(e-b/150,k+c/150),d.initialpos={x:a.clientX,y:a.clientY},d.updateNumbers()):"skew"==d.mode&&(c=a.clientY-d.initialpos.y,b=a.clientX-d.initialpos.x,e=d.target.getSkewX(),k=d.target.getSkewY(),d.target.setSkewX(e-b/4),d.target.setSkewY(k+c/4),d.initialpos={x:a.clientX,y:a.clientY},d.updateNumbers())});d.find("#CCCloseButton").addEventListener("click",function(){d.mode=null;d.style.display="none";d.mouseDown=!1});document.addEventListener("mouseup", +function(){d.mode=null;d.mouseDown=!1})}a[b].dom.ccnode=a[b];var e=a[b];a[b].dom.addEventListener("mouseover",function(){cc.DOM.tooltip.mouseDown||(cc.$.findpos(this),cc.DOM.tooltip.style.display="block",cc.DOM.tooltip.prependTo(this),cc.DOM.tooltip.target=e,this.style.zIndex=999999,cc.DOM.tooltip.updateNumbers())});a[b].dom.addEventListener("mouseout",function(){this.style.zIndex=this.ccnode._zOrder})}};cc.AtlasNode=cc.Node.extend({RGBAProtocol:!0,_itemsPerRow:0,_itemsPerColumn:0,_itemWidth:0,_itemHeight:0,_colorUnmodified:cc.c3b(0,0,0),_textureAtlas:null,_isOpacityModifyRGB:!1,_blendFunc:{src:cc.BLEND_SRC,dst:cc.BLEND_DST},_opacity:0,_color:null,_originalTexture:null,_quadsToDraw:0,_uniformColor:0,initWithTileFile:function(a,b,c,d){cc.Assert(null!=a,"title should not be null");this._itemWidth=b;this._itemHeight=c;this._opacity=255;this._color=cc.white();this._colorUnmodified=cc.white();this._isOpacityModifyRGB= +!0;this._blendFunc.src=cc.BLEND_SRC;this._blendFunc.dst=cc.BLEND_DST;b=new cc.TextureAtlas;b.initWithFile(a,d);this.setTextureAtlas(b);cc.renderContextType==cc.CANVAS&&(this._originalTexture=this._textureAtlas.getTexture());if(!this._textureAtlas)return cc.log("cocos2d: Could not initialize cc.AtlasNode. Invalid Texture."),!1;this._updateBlendFunc();this._updateOpacityModifyRGB();this._calculateMaxItems();this._quadsToDraw=d;return!0},updateAtlasValues:function(){cc.Assert(!1,"cc.AtlasNode:Abstract updateAtlasValue not overriden")}, +draw:function(){this._super()},getColor:function(){return this._isOpacityModifyRGB?this._colorUnmodified:this._color},setColor:function(a){if(!(this._color.r==a.r&&this._color.g==a.g&&this._color.b==a.b)){this._color=this._colorUnmodified=a;if(this.getTexture()&&cc.renderContextType==cc.CANVAS){var b=cc.TextureCache.getInstance().getTextureColors(this._originalTexture);if(b){var c=this._originalTexture,d=cc.rect(0,0,c.width,c.height),b=cc.generateTintImage(c,b,this._color,d),c=new Image;c.src=b.toDataURL(); +this.setTexture(c)}}this._isOpacityModifyRGB&&(this._color.r=a.r*this._opacity/255,this._color.g=a.g*this._opacity/255,this._color.b=a.b*this._opacity/255)}},getOpacity:function(){return this._opacity},setOpacity:function(a){this._opacity=a},setOpacityModifyRGB:function(a){var b=this._color;this._isOpacityModifyRGB=a;this._color=b},isOpacityModifyRGB:function(){return this._isOpacityModifyRGB},getBlendFunc:function(){return this._blendFunc},setBlendFunc:function(a,b){this._blendFunc={src:a,dst:b}}, +getTexture:function(){return this._textureAtlas.getTexture()},setTexture:function(a){this._textureAtlas.setTexture(a);this._updateBlendFunc();this._updateOpacityModifyRGB()},setTextureAtlas:function(a){this._textureAtlas=a},getTextureAtlas:function(){return this._textureAtlas},getQuadsToDraw:function(){return this._quadsToDraw},setQuadsToDraw:function(a){this._quadsToDraw=a},_calculateMaxItems:function(){var a;a=this._textureAtlas.getTexture()instanceof cc.Texture2D?this._textureAtlas.getTexture().getContentSize(): +cc.size(this._textureAtlas.getTexture().width,this._textureAtlas.getTexture().height);this._itemsPerColumn=parseInt(a.height/this._itemHeight);this._itemsPerRow=parseInt(a.width/this._itemWidth)},_updateBlendFunc:function(){},_updateOpacityModifyRGB:function(){}});cc.AtlasNode.create=function(a,b,c,d){var e=new cc.AtlasNode;return e.initWithTileFile(a,b,c,d)?e:null};cc=cc=cc||{};cc.TEXTURE_2D_PIXEL_FORMAT_AUTOMATIC=0;cc.TEXTURE_2D_PIXEL_FORMAT_RGBA8888=1;cc.TEXTURE_2D_PIXEL_FORMAT_RGB888=2;cc.TEXTURE_2D_PIXEL_FORMAT_RGB565=3;cc.TEXTURE_2D_PIXEL_FORMAT_A8=4;cc.TEXTURE_2D_PIXEL_FORMAT_I8=5;cc.TEXTURE_2D_PIXEL_FORMAT_AI88=6;cc.TEXTURE_2D_PIXEL_FORMAT_RGBA4444=7;cc.TEXTURE_2D_PIXEL_FORMAT_RGB5A1=8;cc.TEXTURE_2D_PIXEL_FORMAT_PVRTC4=9;cc.TEXTURE_2D_PIXEL_FORMAT_PVRTC2=10;cc.TEXTURE_2D_PIXEL_FORMAT_DEFAULT=cc.TEXTURE_2D_PIXEL_FORMAT_RGBA8888; +cc.TEXTURE_2D_PIXEL_FORMAT_AUTOMATIC=cc.TEXTURE_2D_PIXEL_FORMAT_AUTOMATIC;cc.TEXTURE_2D_PIXEL_FORMAT_RGBA8888=cc.TEXTURE_2D_PIXEL_FORMAT_RGBA8888;cc.TEXTURE_2D_PIXEL_FORMAT_RGB888=cc.TEXTURE_2D_PIXEL_FORMAT_RGB888;cc.TEXTURE_2D_PIXEL_FORMAT_RGB565=cc.TEXTURE_2D_PIXEL_FORMAT_RGB565;cc.TEXTURE_2D_PIXEL_FORMAT_A8=cc.TEXTURE_2D_PIXEL_FORMAT_A8;cc.TEXTURE_2D_PIXEL_FORMAT_RGBA4444=cc.TEXTURE_2D_PIXEL_FORMAT_RGBA4444;cc.TEXTURE_2D_PIXEL_FORMAT_RGB5A1=cc.TEXTURE_2D_PIXEL_FORMAT_RGB5A1; +cc.TEXTURE_2D_PIXEL_FORMAT_DEFAULT=cc.TEXTURE_2D_PIXEL_FORMAT_DEFAULT;cc.g_defaultAlphaPixelFormat=cc.TEXTURE_2D_PIXEL_FORMAT_DEFAULT;cc.PVRHaveAlphaPremultiplied_=!1;function _ccTexParams(a,b,c,d){this.minFilter=a;this.magFilter=b;this.wrapS=c;this.wrapT=d} +cc.Texture2D=cc.Class.extend({_pVRHaveAlphaPremultiplied:null,_pixelFormat:null,_pixelsWide:null,_pixelsHigh:null,_name:null,_contentSize:null,_maxS:null,_maxT:null,_hasPremultipliedAlpha:null,ctor:function(){cc.SUPPORT_PVRTC&&(this.initWithPVRTCData=function(a,b,c,d,e,f){if(!cc.Configuration.getInstance().isSupportsPVRTC())return cc.log("cocos2d: WARNING: PVRTC images is not supported."),!1;this.setAntiAliasTexParameters();new cc.GLsizei;this._contentSize=cc.size(e,e);this._pixelsHigh=this._pixelsWide= +e;this._maxT=this._maxS=1;this._hasPremultipliedAlpha=cc.PVRHaveAlphaPremultiplied_;this._pixelFormat=f;return!0})},getPixelFormat:function(){return this._pixelFormat},getPixelsWide:function(){return this._pixelsWide},getPixelsHigh:function(){return this._pixelsHigh},getName:function(){return this._name},getContentSizeInPixels:function(){var a=cc.size(0,0);a.width=this._contentSize.width/cc.CONTENT_SCALE_FACTOR();a.height=this._contentSize.height/cc.CONTENT_SCALE_FACTOR();return a},getMaxS:function(){return this._maxS}, +setMaxS:function(a){this._maxS=a},getMaxT:function(){return this._maxT},setMaxT:function(a){this._maxT=a},getHasPremultipliedAlpha:function(){return this._hasPremultipliedAlpha},description:function(){return""},releaseData:function(a){cc.free(a)},keepData:function(a){return a},initWithData:function(a,b,c,d){this.setAntiAliasTexParameters();switch(a){case cc.TEXTURE_2D_PIXEL_FORMAT_RGBA8888:break; +case cc.TEXTURE_2D_PIXEL_FORMAT_RGB888:break;case cc.TEXTURE_2D_PIXEL_FORMAT_RGBA4444:break;case cc.TEXTURE_2D_PIXEL_FORMAT_RGB5A1:break;case cc.TEXTURE_2D_PIXEL_FORMAT_RGB565:break;case cc.TEXTURE_2D_PIXEL_FORMAT_AI88:break;case cc.TEXTURE_2D_PIXEL_FORMAT_A8:break;default:cc.Assert(0,"NSInternalInconsistencyException")}this._contentSize=d;this._pixelsWide=b;this._pixelsHigh=c;this._pixelFormat=a;this._maxS=d.width/b;this._maxT=d.height/c;this._hasPremultipliedAlpha=!1;return!0},drawAtPoint:function(){}, +drawInRect:function(){},initWithImage:function(a){var b,c;if(null==a)return cc.log("cocos2d: cc.Texture2D. Can't create Texture. UIImage is nil"),!1;var d=cc.Configuration.getInstance();cc.TEXTURE_NPOT_SUPPORT?d.isSupportsNPOT()&&(b=a.getWidth(),c=a.getHeight()):(b=cc.NextPOT(a.getWidth()),c=cc.NextPOT(a.getHeight()));d=d.getMaxTextureSize();return c>d||b>d?(cc.log("cocos2d: WARNING: Image (%u x %u) is bigger than the supported %u x %u",b,c,d,d),null):this._initPremultipliedATextureWithImage(a,b, +c)},initWithString:function(a,b,c,d,e){3==arguments.length&&(d=arguments[1],e=arguments[2],b=cc.size(0,0),c=cc.TEXT_ALIGNMENT_CENTER);cc.ENABLE_CACHE_TEXTTURE_DATA&&cc.VolatileTexture.addStringTexture(this,a,b,c,d,e);var f=new cc.Image;eAlign=new cc.Image.ETextAlign;eAlign=cc.TEXT_ALIGNMENT_CENTER==c?cc.Image.ALIGN_CENTER:cc.TEXT_ALIGNMENT_LEFT==c?cc.Image.ALIGN_LEFT:cc.Image.ALIGN_RIGHT;return!f.initWithString(a,b.width,b.height,eAlign,d,e)?!1:this.initWithImage(f)},initWithPVRFile:function(a){var b= +!1,c=new cc.TexturePVR;(b=c.initWithContentsOfFile(a))?(c.setRetainName(!0),this._name=c.getName(),this._maxT=this._maxS=1,this._pixelsWide=c.getWidth(),this._pixelsHigh=c.getHeight(),this._contentSize=cc.size(this._pixelsWide,this._pixelsHigh),this._hasPremultipliedAlpha=cc.PVRHaveAlphaPremultiplied_,this._pixelFormat=c.getFormat(),this.setAntiAliasTexParameters()):cc.log("cocos2d: Couldn't load PVR image %s",a);return b},setTexParameters:function(a){cc.Assert(this._pixelsWide==cc.NextPOT(this._pixelsWide)&& +this._pixelsHigh==cc.NextPOT(this._pixelsHigh)||a.wrapS==gl.CLAMP_TO_EDGE&&a.wrapT==gl.CLAMP_TO_EDGE,"gl.CLAMP_TO_EDGE should be used in NPOT textures")},setAntiAliasTexParameters:function(){this.setTexParameters([gl.LINEAR,gl.LINEAR,gl.CLAMP_TO_EDGE,gl.CLAMP_TO_EDGE])},setAliasTexParameters:function(){this.setTexParameters([gl.NEAREST,gl.NEAREST,gl.CLAMP_TO_EDGE,gl.CLAMP_TO_EDGE])},generateMipmap:function(){cc.Assert(this._pixelsWide==cc.NextPOT(this._pixelsWide)&&this._pixelsHigh==cc.NextPOT(this._pixelsHigh), +"Mimpap texture only works in POT textures")},bitsPerPixelForFormat:function(){var a=0;switch(this._pixelFormat){case cc.TEXTURE_2D_PIXEL_FORMAT_RGBA8888:a=32;break;case cc.TEXTURE_2D_PIXEL_FORMAT_RGB565:a=16;break;case cc.TEXTURE_2D_PIXEL_FORMAT_A8:a=8;break;case cc.TEXTURE_2D_PIXEL_FORMAT_RGBA4444:a=16;break;case cc.TEXTURE_2D_PIXEL_FORMAT_RGB5A1:a=16;break;case cc.TEXTURE_2D_PIXEL_FORMAT_PVRTC4:a=4;break;case cc.TEXTURE_2D_PIXEL_FORMAT_PVRTC2:a=2;break;case cc.TEXTURE_2D_PIXEL_FORMAT_I8:a=8;break; +case cc.TEXTURE_2D_PIXEL_FORMAT_AI88:a=16;break;case cc.TEXTURE_2D_PIXEL_FORMAT_RGB888:a=24;break;default:a=-1,cc.Assert(!1,"illegal pixel format"),cc.log("bitsPerPixelForFormat: %d, cannot give useful result",this._pixelFormat)}return a},_initPremultipliedATextureWithImage:function(a,b,c){var d=null,e=null,f=null,g;g=cc.size(0,0);var h=new cc.Texture2DPixelFormat,h=new cc.size_t;g=a.hasAlpha();h=a.getBitsPerComponent();g?h=cc.g_defaultAlphaPixelFormat:8<=h?h=cc.TEXTURE_2D_PIXEL_FORMAT_RGB888:(cc.log("cocos2d: cc.Texture2D: Using RGB565 texture since image has no alpha"), +h=cc.TEXTURE_2D_PIXEL_FORMAT_RGB565);g=cc.size(a.getWidth(),a.getHeight());switch(h){case cc.TEXTURE_2D_PIXEL_FORMAT_RGBA8888:case cc.TEXTURE_2D_PIXEL_FORMAT_RGBA4444:case cc.TEXTURE_2D_PIXEL_FORMAT_RGB5A1:case cc.TEXTURE_2D_PIXEL_FORMAT_RGB565:case cc.TEXTURE_2D_PIXEL_FORMAT_A8:e=a.getData();cc.Assert(null!=e,"null image data.");if(a.getWidth()==b&&a.getHeight()==c)d=new (4*c*b),cc.memcpy(d,e,4*c*b);else for(var f=d=new (4*c*b),j=a.getHeight(),k=0;k"},addImage:function(a){cc.Assert(null!=a,"TextureCache: path MUST not be null");var b=this.textures[a.toString()];if(b)cc.Loader.getInstance().onResLoaded();else b=new Image, +b.addEventListener("load",function(){cc.Loader.getInstance().onResLoaded()}),b.addEventListener("error",function(){cc.Loader.getInstance().onResLoadingErr(a)}),b.src=a,this.textures[a.toString()]=b;if(cc.renderContextType==cc.CANVAS)return this.textures[a.toString()]},cacheImage:function(a,b){this.textures[a.toString()]||(this.textures[a.toString()]=b)},addUIImage:function(a,b){cc.Assert(null!=a,"TextureCache: image MUST not be nulll");var c=null;if(b&&this.textures.hasOwnProperty(b)&&(c=this.textures[b]))return c; +c=new cc.Texture2D;c.initWithImage(a);null!=b&&null!=c?this.textures[b]=c:cc.log("cocos2d: Couldn't add UIImage in TextureCache");return c},textureForKey:function(a){return this.textures.hasOwnProperty(a)?this.textures[a]:null},getKeyByTexture:function(a){for(var b in this.textures)if(this.textures[b]==a)return b;return null},getTextureColors:function(a){var b=this.getKeyByTexture(a);if(b)if(a instanceof HTMLImageElement)b=a.src;else return null;this._textureColorsCache.hasOwnProperty(b)||(this._textureColorsCache[b]= +cc.generateTextureCacheForColor(a));return this._textureColorsCache[b]},removeAllTextures:function(){this.textures={}},removeTexture:function(a){if(a)for(var b in this.textures)if(this.textures[b]==a){delete this.textures[b];break}},removeTextureForKey:function(a){null!=a&&this.textures[a]&&delete this.textures[a]},dumpCachedTextureInfo:function(){var a=0,b=0,c;for(c in this.textures){var d=this.textures[c],e=d.bitsPerPixelForFormat(),f=d.getPixelsWide()*d.getPixelsHigh()*e/8,b=b+f;a++;cc.log("cocos2d: '"+ +d.toString()+"' id="+d.getName()+" "+d.getPixelsWide()+" x "+d.getPixelsHigh()+" @ "+e+" bpp => "+f/1024+" KB")}cc.log("cocos2d: TextureCache dumpDebugInfo: "+a+" textures, for "+b/1024+" KB ("+(b/1048576).toFixed(2)+" MB)")},addPVRImage:function(a){cc.Assert(null!=a,"TextureCache: file image MUST not be null");if(null!=this.textures[a])return this.textures[a];var b=new cc.Texture2D;b.initWithPVRFile(a)?this.textures[a]=b:cc.log("cocos2d: Couldn't add PVRImage:"+a+" in TextureCache");return b}}); +cc.TextureCache.getInstance=function(){cc.g_sharedTextureCache||(cc.g_sharedTextureCache=new cc.TextureCache);return cc.g_sharedTextureCache};cc.TextureCache.purgeSharedTextureCache=function(){cc.g_sharedTextureCache=null};cc.TextureAtlas=cc.Class.extend({_indices:[],_buffersVBO:[0,1],_dirty:!1,_capacity:0,_texture:null,_quads:[],getTotalQuads:function(){return this._quads.length},getCapacity:function(){return this._capacity},getTexture:function(){return this._texture},setTexture:function(a){this._texture=a},getQuads:function(){return this._quads},setQuads:function(a){this._quads=a},description:function(){return""},_initIndices:function(){if(0!=this._capacity)for(var a= +0;ab?cc.ArrayAppendObjectToIndex(this._quads,c,b):cc.ArrayAppendObjectToIndex(this._quads,c,b-1);this._dirty=!0}},removeQuadAtIndex:function(a){cc.ArrayRemoveObjectAtIndex(this._quads,a);this._dirty=!0},removeAllQuads:function(){this._quads.length=0},resizeCapacity:function(a){if(a==this._capacity)return!0;this._totalQuads=Math.min(this._totalQuads,a);this._capacity=a;return!0},drawNumberOfQuads:function(){},drawQuads:function(){this.drawNumberOfQuads(this._quads.length,0)}}); +cc.TextureAtlas.create=function(a,b){var c=new cc.TextureAtlas;return c&&c.initWithFile(a,b)?c:null};cc.TextureAtlas.createWithTexture=function(a,b){var c=new cc.TextureAtlas;return c&&c.initWithTexture(a,b)?c:null};cc.IMAGE_FORMAT_JPEG=0;cc.IMAGE_FORMAT_PNG=1;cc.IMAGE_FORMAT_RAWDATA=2;cc.NextPOT=function(a){a-=1;a|=a>>1;a|=a>>2;a|=a>>4;a|=a>>8;return(a|a>>16)+1}; +cc.RenderTexture=cc.Node.extend({canvas:null,context:null,_fBO:0,_depthRenderBuffer:0,_oldFBO:0,_texture:null,_uITextureImage:null,_pixelFormat:cc.TEXTURE_2D_PIXEL_FORMAT_RGBA8888,_sprite:null,ctor:function(){this.canvas=document.createElement("canvas");this.context=this.canvas.getContext("2d");this.setAnchorPoint(cc.p(0,0))},getSprite:function(){return this._sprite},setSprite:function(a){this._sprite=a},getCanvas:function(){return this.canvas},setContentSize:function(a){a&&(this._super(a),this.canvas.width= +1.5*a.width,this.canvas.height=1.5*a.height,this.context.translate(0,this.canvas.height))},initWithWidthAndHeight:function(a,b,c,d){if(cc.renderContextType==cc.CANVAS)this.canvas.width=a||10,this.canvas.height=b||10,this.context.translate(0,this.canvas.height),this._sprite=cc.Sprite.createWithTexture(this.canvas);else{cc.Assert(this._pixelFormat!=cc.TEXTURE_2D_PIXEL_FORMAT_A8,"only RGB and RGBA formats are valid for a render texture");try{a*=cc.CONTENT_SCALE_FACTOR();b*=cc.CONTENT_SCALE_FACTOR(); +glGetIntegerv(gl.FRAMEBUFFER_BINDING,this._oldFBO);var e=0,f=0;cc.Configuration.getInstance().supportsNPOT()?(e=a,f=b):(e=cc.NextPOT(a),f=cc.NextPOT(b));for(var g=[],h=0;h<4*e*f;h++)g[h]=0;this._pixelFormat=c;this._texture=new cc.Texture2D;if(!this._texture)return!1;this._texture.initWithData(g,this._pixelFormat,e,f,cc.size(a,b));glGetIntegerv(GL_RENDERBUFFER_BINDING,void 0);glGenFramebuffers(1,this._fBO);glBindFramebuffer(GL_FRAMEBUFFER,this._fBO);glFramebufferTexture2D(gl.FRAMEBUFFER,gl.COLOR_ATTACHMENT0, +GL_TEXTURE_2D,this._texture.getName(),0);0!=this._depthRenderBuffer&&(glGenRenderbuffers(1,this._depthRenderBuffer),glBindRenderbuffer(GL_RENDERBUFFER,this._depthRenderBuffer),glRenderbufferStorage(GL_RENDERBUFFER,d,e,f),glFramebufferRenderbuffer(GL_FRAMEBUFFER,GL_DEPTH_ATTACHMENT,GL_RENDERBUFFER,this._depthRenderBuffer),d==gl.DEPTH24_STENCIL8&&glFramebufferRenderbuffer(GL_FRAMEBUFFER,GL_STENCIL_ATTACHMENT,GL_RENDERBUFFER,this._depthRenderBuffer));cc.Assert(glCheckFramebufferStatus(GL_FRAMEBUFFER)== +GL_FRAMEBUFFER_COMPLETE,"Could not attach texture to framebuffer");this._texture.setAliasTexParameters();this._sprite=cc.Sprite.createWithTexture(this._texture);this._sprite.setScaleY(-1);this.addChild(this._sprite);this._sprite.setBlendFunc(gl.ONE,gl.ONE_MINUS_SRC_ALPHA);glBindRenderbuffer(GL_RENDERBUFFER,void 0);glBindFramebuffer(GL_FRAMEBUFFER,this._oldFBO)}catch(j){return!1}}return!0},begin:function(){kmGLPushMatrix();var a=this._texture.getContentSizeInPixels(),b=cc.Director.getInstance().getWinSizeInPixels(), +c=b.width/a.width,b=b.height/a.height;glViewport(0,0,a.width,a.height);kmMat4OrthographicProjection(void 0,-1/c,1/c,-1/b,1/b,-1,1);kmGLMultMatrix(void 0);glGetIntegerv(gl.FRAMEBUFFER_BINDING,this._oldFBO);glBindFramebuffer(gl.FRAMEBUFFER,this._fBO)},beginWithClear:function(a,b,c,d,e,f){var g;switch(arguments.length){case 4:this.begin();g=[0,0,0,0];glGetFloatv(GL_COLOR_CLEAR_VALUE,g);glClearColor(a,b,c,d);glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);glClearColor(g[0],g[1],g[2],g[3]);break;case 5:this.begin(); +g=[0,0,0,0];glGetFloatv(GL_COLOR_CLEAR_VALUE,g);glGetFloatv(GL_DEPTH_CLEAR_VALUE,void 0);glClearColor(a,b,c,d);glClearDepth(e);glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);glClearColor(g[0],g[1],g[2],g[3]);glClearDepth(void 0);break;case 6:this.begin();g=[0,0,0,0];glGetFloatv(GL_COLOR_CLEAR_VALUE,g);glGetFloatv(GL_DEPTH_CLEAR_VALUE,void 0);glGetIntegerv(GL_STENCIL_CLEAR_VALUE,void 0);glClearColor(a,b,c,d);glClearDepth(e);glClearStencil(f);glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); +glClearColor(g[0],g[1],g[2],g[3]);glClearDepth(void 0);glClearStencil(void 0);break;default:throw"unknown arguments";}},end:function(){glBindFramebuffer(GL_FRAMEBUFFER,this._oldFBO);kmGLPopMatrix();var a=cc.Director.getInstance(),b=a.getWinSizeInPixels();glViewport(0,0,b.width*cc.CONTENT_SCALE_FACTOR(),b.height*cc.CONTENT_SCALE_FACTOR());a.getProjection()==cc.DIRECTOR_PROJECTION_3D&&1!=cc.CONTENT_SCALE_FACTOR()&&glViewport(-b.width/2,-b.height/2,b.width*cc.CONTENT_SCALE_FACTOR(),b.height*cc.CONTENT_SCALE_FACTOR()); +a.setProjection(a.getProjection())},clear:function(a,b,c,d){cc.renderContextType==cc.CANVAS?a?this.context.clearRect(a.origin.x,a.origin.y,a.size.width,a.size.height):this.context.clearRect(0,0,this.canvas.width,-this.canvas.height):(this.beginWithClear(a,b,c,d),this.end())},clearDepth:function(){this.begin();glGetFloatv(GL_DEPTH_CLEAR_VALUE,void 0);glClearDepth(depthValue);glClear(GL_DEPTH_BUFFER_BIT);glClearDepth(void 0);this.end()},clearStencil:function(a){glGetIntegerv(GL_STENCIL_CLEAR_VALUE, +void 0);glClearStencil(a);glClear(GL_STENCIL_BUFFER_BIT);glClearStencil(void 0)},newCCImage:function(){cc.Assert(this._pixelFormat==cc.TEXTURE_2D_PIXEL_FORMAT_RGBA8888,"only RGBA8888 can be saved as image");if(!this._texture)return null;var a=this._texture.getContentSizeInPixels(),b=a.width,a=a.height,c=null,d=null,e=new cc.Image;try{c=[];c.length=4*b*a;if(!c)return e;d=[];d.length=4*b*a;if(!d)return e;this.begin();glPixelStorei(GL_PACK_ALIGNMENT,1);glReadPixels(0,0,b,a,GL_RGBA,GL_UNSIGNED_BYTE,d); +this.end();for(var f=0;fa.x&&(b.x+=-a.x,a.x=0);1a.y&& +(b.y+=-a.y,a.y=0);1=h.width)&&0<=h.height&&0>7-(a<<1)&1,cc.PROGRESS_TEXTURE_COORDS>>7-((a<<1)+1)&1):cc.p(cc.PROGRESS_TEXTURE_COORDS>>(a<<1)+1&1,cc.PROGRESS_TEXTURE_COORDS>>(a<<1)&1):cc.PointZero()}});cc.ProgressTimer.create=function(a){var b=new cc.ProgressTimer;return b.initWithSprite(a)?b:null};cc=cc=cc||{}; +cc.GridBase=cc.Class.extend({_active:null,_reuseGrid:null,_gridSize:null,_texture:null,_step:cc.p(0,0),_grabber:null,_isTextureFlipped:null,isActive:function(){return this._active},setActive:function(a){this._active=a;if(!a){var a=cc.Director.getInstance(),b=a.getProjection();a.setProjection(b)}},getReuseGrid:function(){return this._reuseGrid},setReuseGrid:function(a){this._reuseGrid=a},getGridSize:function(){return this._gridSize},setGridSize:function(a){this._gridSize.x=parseInt(a.x);this._gridSize.y= +parseInt(a.y)},getStep:function(){return this._step},setStep:function(a){this._step=a},isTextureFlipped:function(){return this._isTextureFlipped},setIsTextureFlipped:function(a){this._isTextureFlipped!=a&&(this._isTextureFlipped=a,this.calculateVertexPoints())},initWithSize:function(a){var b=cc.Director.getInstance().getWinSizeInPixels(),c=cc.NextPOT(b.width),d=cc.NextPOT(b.height),e=cc.TEXTURE_2D_PIXEL_FORMAT_RGBA8888,f=new cc.Texture2D;f.initWithData(e,c,d,b);if(!f)return cc.log("cocos2d: CCGrid: error creating texture"), +!1;b=!0;this._active=!1;this._reuseGrid=0;this._gridSize=a;this._texture=f;this._isTextureFlipped=!1;a=this._texture.getContentSizeInPixels();this._step.x=a.width/this._gridSize.x;this._step.y=a.height/this._gridSize.y;(this._grabber=new cc.Grabber)?this._grabber.grab(this._texture):b=!1;this.calculateVertexPoints();return b},beforeDraw:function(){this.set2DProjection();this._grabber.beforeRender(this._texture)},afterDraw:function(a){this._grabber.afterRender(this._texture);this.set3DProjection(); +a.getCamera().getDirty()&&(a.getAnchorPointInPixels(),a.getCamera().locate());this.blit()},blit:function(){cc.Assert(0,"")},reuse:function(){cc.Assert(0,"")},calculateVertexPoints:function(){cc.Assert(0,"")},set2DProjection:function(){cc.Director.getInstance().getWinSizeInPixels()}});cc.GridBase.create=function(){return new cc.GridBase}; +cc.Grid3D=cc.GridBase.extend({_texCoordinates:null,_vertices:null,_originalVertices:null,_indices:null,vertex:function(a){var a=3*(a.x*(this._gridSize.y+1)+a.y),b=this._vertices;return new cc.Vertex3F(b[a],b[a+1],b[a+2])},originalVertex:function(a){var a=3*(a.x*(this._gridSize.y+1)+a.y),b=this._originalVertices;return new cc.Vertex3F(b[a],b[a+1],b[a+2])},setVertex:function(a,b){var c=3*(a.x*(this._gridSize.y+1)+a.y),d=this._vertices;d[c]=b.x;d[c+1]=b.y;d[c+2]=b.z},blit:function(){},reuse:function(){0< +this._reuseGrid&&--this._reuseGrid},calculateVertexPoints:function(){var a=this._texture.getPixelsWide(),b=this._texture.getPixelsHigh(),c=this._texture.getContentSizeInPixels().height,d=this._gridSize.x*this._gridSize.y;this._vertices=[];this._originalVertices=[];this._texCoordinates=[];this._indices=[];var e=this._vertices,f=this._texCoordinates,g=this._indices,h,j;for(h=0;h"},copyWithZone:function(){return this.copy()},copy:function(){return cc.clone(this)},isDone:function(){return!0},startWithTarget:function(a){this._target=this._originalTarget=a},stop:function(){this._target=null},step:function(){cc.log("[Action step]. override me")},update:function(){cc.log("[Action update]. override me")},getTarget:function(){return this._target}, +setTarget:function(a){this._target=a},getOriginalTarget:function(){return this._originalTarget},setOriginalTarget:function(a){this._originalTarget=a},getTag:function(){return this._tag},setTag:function(a){this._tag=a}});cc.Action.create=function(){return new cc.Action};cc.FiniteTimeAction=cc.Action.extend({_duration:0,getDuration:function(){return this._duration},setDuration:function(a){this._duration=a},reverse:function(){cc.log("cocos2d: FiniteTimeAction#reverse: Implement me");return null}}); +cc.Speed=cc.Action.extend({_speed:0,_innerAction:null,getSpeed:function(){return this._speed},setSpeed:function(a){this._speed=a},initWithAction:function(a,b){cc.Assert(null!=a,"");this._innerAction=a;this._speed=b;return!0},startWithTarget:function(a){cc.Action.prototype.startWithTarget.call(this,a);this._innerAction.startWithTarget(a)},stop:function(){this._innerAction.stop();cc.Action.prototype.stop.call(this)},step:function(a){this._innerAction.step(a*this._speed)},isDone:function(){return this._innerAction.isDone()}, +reverse:function(){return cc.Speed.create(this._innerAction.reverse(),this._speed)},setInnerAction:function(a){this._innerAction!=a&&(this._innerAction=a)},getInnerAction:function(){return this._innerAction}});cc.Speed.create=function(a,b){var c=new cc.Speed;return c&&c.initWithAction(a,b)?c:null}; +cc.Follow=cc.Action.extend({isBoundarySet:function(){return this._boundarySet},setBoudarySet:function(a){this._boundarySet=a},initWithTarget:function(a,b){cc.Assert(null!=a,"");b=b||cc.RectZero();this._followedNode=a;this._boundarySet=cc.Rect.CCRectEqualToRect(b,cc.RectZero());this._boundaryFullyCovered=!1;var c=cc.Director.getInstance().getWinSize();this._fullScreenSize=cc.p(c.width,c.height);this._halfScreenSize=cc.pMult(this._fullScreenSize,0.5);this._boundarySet&&(this.leftBoundary=-(b.origin.x+ +b.size.width-this._fullScreenSize.x),this.rightBoundary=-b.origin.x,this.topBoundary=-b.origin.y,this.bottomBoundary=-(b.origin.y+b.size.height-this._fullScreenSize.y),this.rightBoundary=this._duration},step:function(a){this._firstTick?(this._firstTick=!1,this._elapsed=0):this._elapsed+=a;a=this._elapsed/(1.192092896E-7a?a:1;this.update(0=this._nextDt){for(;a>this._nextDt&&this._totale?this._two=cc.Sequence._actionOneTwo(b,cc.DelayTime.create(d-e)):dthis._diffAngle&&(this._diffAngle+=360)},reverse:function(){cc.Assert(0, +"RotateTo reverse not implemented")},update:function(a){this._target&&this._target.setRotation(this._startAngle+this._diffAngle*a)}});cc.RotateTo.create=function(a,b){var c=new cc.RotateTo;c.initWithDuration(a,b);return c}; +cc.RotateBy=cc.ActionInterval.extend({_angle:0,_startAngle:0,initWithDuration:function(a,b){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this._angle=b,!0):!1},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a);this._startAngle=a.getRotation()},update:function(a){this._target&&this._target.setRotation(this._startAngle+this._angle*a)},reverse:function(){return cc.RotateBy.create(this._duration,-this._angle)}}); +cc.RotateBy.create=function(a,b){var c=new cc.RotateBy;c.initWithDuration(a,b);return c}; +cc.MoveTo=cc.ActionInterval.extend({initWithDuration:function(a,b){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this._endPosition=b,!0):!1},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a);this._startPosition=a.getPosition();this._delta=cc.pSub(this._endPosition,this._startPosition)},update:function(a){this._target&&this._target.setPosition(cc.p(this._startPosition.x+this._delta.x*a,this._startPosition.y+this._delta.y*a))},reverse:function(){cc.Assert(0, +"moveto reverse is not implemented")},_endPosition:cc.p(0,0),_startPosition:cc.p(0,0),_delta:cc.p(0,0)});cc.MoveTo.create=function(a,b){var c=new cc.MoveTo;c.initWithDuration(a,b);return c}; +cc.MoveBy=cc.MoveTo.extend({initWithDuration:function(a,b){return cc.MoveTo.prototype.initWithDuration.call(this,a,b)?(this._delta=b,!0):!1},startWithTarget:function(a){var b=this._delta;cc.MoveTo.prototype.startWithTarget.call(this,a);this._delta=b},reverse:function(){return cc.MoveBy.create(this._duration,cc.p(-this._delta.x,-this._delta.y))}});cc.MoveBy.create=function(a,b){var c=new cc.MoveBy;c.initWithDuration(a,b);return c}; +cc.SkewTo=cc.ActionInterval.extend({initWithDuration:function(a,b,c){var d=!1;cc.ActionInterval.prototype.initWithDuration.call(this,a)&&(this._endSkewX=b,this._endSkewY=c,d=!0);return d},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a);this._startSkewX=a.getSkewX();this._startSkewX=0this._deltaX&&(this._deltaX+=360); +this._startSkewY=a.getSkewY();this._startSkewY=0this._deltaY&&(this._deltaY+=360)},update:function(a){this._target.setSkewX(this._startSkewX+this._deltaX*a);this._target.setSkewY(this._startSkewY+this._deltaY*a)},_skewX:0,_skewY:0,_startSkewX:0,_startSkewY:0,_endSkewX:0,_endSkewY:0,_deltaX:0,_deltaY:0}); +cc.SkewTo.create=function(a,b,c){var d=new cc.SkewTo;d&&d.initWithDuration(a,b,c);return d}; +cc.SkewBy=cc.SkewTo.extend({initWithDuration:function(a,b,c){var d=!1;cc.SkewTo.prototype.initWithDuration.call(this,a,b,c)&&(this._skewX=b,this._skewY=c,d=!0);return d},startWithTarget:function(a){cc.SkewTo.prototype.startWithTarget.call(this,a);this._deltaX=this._skewX;this._deltaY=this._skewY;this._endSkewX=this._startSkewX+this._deltaX;this._endSkewY=this._startSkewY+this._deltaY},reverse:function(){return cc.SkewBy.create(this._duration,-this._skewX,-this._skewY)}}); +cc.SkewBy.create=function(a,b,c){var d=new cc.SkewBy;d&&d.initWithDuration(a,b,c);return d}; +cc.JumpBy=cc.ActionInterval.extend({initWithDuration:function(a,b,c,d){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this._delta=b,this._height=c,this._jumps=d,!0):!1},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a);this._startPosition=a.getPosition()},update:function(a){if(this._target){var b=a*this._jumps%1,b=4*this._height*b*(1-b),b=b+this._delta.y*a;this._target.setPosition(cc.p(this._startPosition.x+this._delta.x*a,this._startPosition.y+ +b))}},reverse:function(){return cc.JumpBy.create(this._duration,cc.p(-this._delta.x,-this._delta.y),this._height,this._jumps)},_startPosition:cc.p(0,0),_delta:cc.p(0,0),_height:0,_jumps:0});cc.JumpBy.create=function(a,b,c,d){var e=new cc.JumpBy;e.initWithDuration(a,b,c,d);return e};cc.JumpTo=cc.JumpBy.extend({startWithTarget:function(a){cc.JumpBy.prototype.startWithTarget.call(this,a);this._delta=cc.p(this._delta.x-this._startPosition.x,this._delta.y-this._startPosition.y)}}); +cc.JumpTo.create=function(a,b,c,d){var e=new cc.JumpTo;e.initWithDuration(a,b,c,d);return e};cc.BezierConfig=cc.Class.extend({ctor:function(){this.endPosition=cc.p(0,0);this.controlPoint_1=cc.p(0,0);this.controlPoint_2=cc.p(0,0)}});cc.bezierat=function(a,b,c,d,e){return Math.pow(1-e,3)*a+3*e*Math.pow(1-e,2)*b+3*Math.pow(e,2)*(1-e)*c+Math.pow(e,3)*d}; +cc.BezierBy=cc.ActionInterval.extend({initWithDuration:function(a,b){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this._config=b,!0):!1},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a);this._startPosition=a.getPosition()},update:function(a){if(this._target){var b=this._config.controlPoint_1.y,c=this._config.controlPoint_2.y,d=this._config.endPosition.y,e=cc.bezierat(0,this._config.controlPoint_1.x,this._config.controlPoint_2.x,this._config.endPosition.x, +a),a=cc.bezierat(0,b,c,d,a);this._target.setPosition(cc.pAdd(this._startPosition,cc.p(e,a)))}},reverse:function(){var a=new cc.BezierConfig;a.endPosition=cc.pNeg(this._config.endPosition);a.controlPoint_1=cc.pAdd(this._config.controlPoint_2,cc.pNeg(this._config.endPosition));a.controlPoint_2=cc.pAdd(this._config.controlPoint_1,cc.pNeg(this._config.endPosition));return cc.BezierBy.create(this._duration,a)},ctor:function(){this._config=new cc.BezierConfig;this._startPosition=cc.p(0,0)}}); +cc.BezierBy.create=function(a,b){var c=new cc.BezierBy;c.initWithDuration(a,b);return c};cc.BezierTo=cc.BezierBy.extend({startWithTarget:function(a){cc.BezierBy.prototype.startWithTarget.call(this,a);this._config.controlPoint_1=cc.pSub(this._config.controlPoint_1,this._startPosition);this._config.controlPoint_2=cc.pSub(this._config.controlPoint_2,this._startPosition);this._config.endPosition=cc.pSub(this._config.endPosition,this._startPosition)}}); +cc.BezierTo.create=function(a,b){var c=new cc.BezierTo;c.initWithDuration(a,b);return c}; +cc.ScaleTo=cc.ActionInterval.extend({initWithDuration:function(a,b,c){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this._endScaleX=b,this._endScaleY=null!=c?c:b,!0):!1},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a);this._startScaleX=a.getScaleX();this._startScaleY=a.getScaleY();this._deltaX=this._endScaleX-this._startScaleX;this._deltaY=this._endScaleY-this._startScaleY},update:function(a){this._target&&this._target.setScale(this._startScaleX+ +this._deltaX*a,this._startScaleY+this._deltaY*a)},_scaleX:1,_scaleY:1,_startScaleX:1,_startScaleY:1,_endScaleX:0,_endScaleY:0,_deltaX:0,_deltaY:0});cc.ScaleTo.create=function(a,b,c){var d=new cc.ScaleTo;c?d.initWithDuration(a,b,c):d.initWithDuration(a,b);return d}; +cc.ScaleBy=cc.ScaleTo.extend({startWithTarget:function(a){cc.ScaleTo.prototype.startWithTarget.call(this,a);this._deltaX=this._startScaleX*this._endScaleX-this._startScaleX;this._deltaY=this._startScaleY*this._endScaleY-this._startScaleY},reverse:function(){return cc.ScaleBy.create(this._duration,1/this._endScaleX,1/this._endScaleY)}});cc.ScaleBy.create=function(a,b,c){var d=new cc.ScaleBy;3==arguments.length?d.initWithDuration(a,b,c):d.initWithDuration(a,b);return d}; +cc.Blink=cc.ActionInterval.extend({initWithDuration:function(a,b){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this._times=b,!0):!1},update:function(a){if(this._target&&!this.isDone()){var b=1/this._times;this._target.setVisible(a%b>b/2?!0:!1)}},reverse:function(){return cc.Blink.create(this._duration,this._times)},_times:0});cc.Blink.create=function(a,b){var c=new cc.Blink;c.initWithDuration(a,b);return c}; +cc.FadeIn=cc.ActionInterval.extend({update:function(a){this._target.setOpacity(255*a)},reverse:function(){return cc.FadeOut.create(this._duration)}});cc.FadeIn.create=function(a){var b=new cc.FadeIn;b.initWithDuration(a);return b};cc.FadeOut=cc.ActionInterval.extend({update:function(a){this._target.setOpacity(255*(1-a))},reverse:function(){return cc.FadeIn.create(this._duration)}});cc.FadeOut.create=function(a){var b=new cc.FadeOut;b.initWithDuration(a);return b}; +cc.FadeTo=cc.ActionInterval.extend({initWithDuration:function(a,b){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this._toOpacity=b,!0):!1},update:function(a){this._target.setOpacity(this._fromOpacity+(this._toOpacity-this._fromOpacity)*a)},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a);this._fromOpacity=a.getOpacity()},_toOpacity:"",_fromOpacity:""});cc.FadeTo.create=function(a,b){var c=new cc.FadeTo;c.initWithDuration(a,b);return c}; +cc.TintTo=cc.ActionInterval.extend({initWithDuration:function(a,b,c,d){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this._to=cc.c3b(b,c,d),!0):!1},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a);this._from=this._target.getColor()},update:function(a){this._target.setColor(cc.c3b(this._from.r+(this._to.r-this._from.r)*a,this._from.g+(this._to.g-this._from.g)*a,this._from.b+(this._to.b-this._from.b)*a))},_to:new cc.Color3B,_from:new cc.Color3B}); +cc.TintTo.create=function(a,b,c,d){var e=new cc.TintTo;e.initWithDuration(a,b,c,d);return e}; +cc.TintBy=cc.ActionInterval.extend({initWithDuration:function(a,b,c,d){return cc.ActionInterval.prototype.initWithDuration.call(this,a)?(this._deltaR=b,this._deltaG=c,this._deltaB=d,!0):!1},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a);a.RGBAProtocol&&(a=a.getColor(),this._fromR=a.r,this._fromG=a.g,this._fromB=a.b)},update:function(a){this._target.RGBAProtocol&&this._target.setColor(cc.c3b(this._fromR+this._deltaR*a,this._fromG+this._deltaG*a,this._fromB+this._deltaB* +a))},reverse:function(){return cc.TintBy.create(this._duration,-this._deltaR,-this._deltaG,-this._deltaB)},_deltaR:0,_deltaG:0,_deltaB:0,_fromR:0,_fromG:0,_fromB:0});cc.TintBy.create=function(a,b,c,d){var e=new cc.TintBy;e.initWithDuration(a,b,c,d);return e};cc.DelayTime=cc.ActionInterval.extend({update:function(){},reverse:function(){return cc.DelayTime.create(this._duration)}});cc.DelayTime.create=function(a){var b=new cc.DelayTime;b.initWithDuration(a);return b}; +cc.ReverseTime=cc.ActionInterval.extend({initWithAction:function(a){cc.Assert(null!=a,"");cc.Assert(a!=this._other,"");return cc.ActionInterval.prototype.initWithDuration.call(this,a.getDuration())?(this._other=a,!0):!1},startWithTarget:function(a){cc.ActionInterval.prototype.startWithTarget.call(this,a);this._other.startWithTarget(a)},update:function(a){this._other&&this._other.update(1-a)},reverse:function(){return this._other.copy()},stop:function(){this._other.stop();cc.Action.prototype.stop.call(this)}, +_other:null});cc.ReverseTime.create=function(a){var b=new cc.ReverseTime;b.initWithAction(a);return b}; +cc.Animate=cc.ActionInterval.extend({_animation:null,_nextFrame:0,_origFrame:null,_executedLoops:0,_splitTimes:null,getAnimation:function(){return this._animation},setAnimation:function(a){this._animation=a},initWithAnimation:function(a){cc.Assert(null!=a,"Animate: argument Animation must be non-NULL");var b=a.getDuration();if(this.initWithDuration(b*a.getLoops())){this._nextFrame=0;this.setAnimation(a);this._origFrame=null;this._executedLoops=0;this._splitTimes=[];var c=0,d=b/a.getTotalDelayUnits(), +a=a.getFrames();cc.ArrayVerifyType(a,cc.AnimationFrame);for(var e=0;ea&&(a*=this._animation.getLoops(),(0|a)>this._executedLoops&&(this._nextFrame=0,this._executedLoops++),a%=1);for(var b= +this._animation.getFrames(),c=b.length,d=this._nextFrame;d=a&&b.actionIndex--;0==b.actions.length&&(this._currentTarget==b?this._currentTargetSalvaged=!0:this._deleteHashElement(b))},_deleteHashElement:function(a){cc.ArrayRemoveObject(this._targets,a);a&&(a.actions=null,a.target=null)},_actionAllocWithHashElement:function(a){null==a.actions&&(a.actions=[])},update:function(a){for(var b=0;ba?this._other.update(0.5*Math.pow(a,this._rate)):this._other.update(1-0.5*Math.pow(2-a,this._rate))},copyWithZone:function(){},reverse:function(){return cc.EaseInOut.create(this._other.reverse(),this._rate)}});cc.EaseInOut.create=function(a,b){var c=new cc.EaseInOut;c&&c.initWithAction(a,b);return c}; +cc.EaseExponentialIn=cc.ActionEase.extend({update:function(a){this._other.update(0==a?0:Math.pow(2,10*(a/1-1))-0.0010)},reverse:function(){return cc.EaseExponentialOut.create(this._other.reverse())},copyWithZone:function(){}});cc.EaseExponentialIn.create=function(a){var b=new cc.EaseExponentialIn;b&&b.initWithAction(a);return b}; +cc.EaseExponentialOut=cc.ActionEase.extend({update:function(a){this._other.update(1==a?1:-Math.pow(2,-10*a/1)+1)},reverse:function(){return cc.EaseExponentialIn.create(this._other.reverse())},copyWithZone:function(){}});cc.EaseExponentialOut.create=function(a){var b=new cc.EaseExponentialOut;b&&b.initWithAction(a);return b}; +cc.EaseExponentialInOut=cc.ActionEase.extend({update:function(a){a/=0.5;a=1>a?0.5*Math.pow(2,10*(a-1)):0.5*(-Math.pow(2,10*(a-1))+2);this._other.update(a)},reverse:function(){return cc.EaseExponentialInOut.create(this._other.reverse())},copyWithZone:function(){}});cc.EaseExponentialInOut.create=function(a){var b=new cc.EaseExponentialInOut;b&&b.initWithAction(a);return b}; +cc.EaseSineIn=cc.ActionEase.extend({update:function(a){this._other.update(-1*Math.cos(a*Math.PI/2)+1)},reverse:function(){return cc.EaseSineOut.create(this._other.reverse())},copyWithZone:function(){}});cc.EaseSineIn.create=function(a){var b=new cc.EaseSineIn;b&&b.initWithAction(a);return b};cc.EaseSineOut=cc.ActionEase.extend({update:function(a){this._other.update(Math.sin(a*Math.PI/2))},reverse:function(){return cc.EaseSineIn.create(this._other.reverse())},copyWithZone:function(){}}); +cc.EaseSineOut.create=function(a){var b=new cc.EaseSineOut;b&&b.initWithAction(a);return b};cc.EaseSineInOut=cc.ActionEase.extend({update:function(a){this._other.update(-0.5*(Math.cos(Math.PI*a)-1))},reverse:function(){return cc.EaseSineInOut.create(this._other.reverse())},copyWithZone:function(){}});cc.EaseSineInOut.create=function(a){var b=new cc.EaseSineInOut;b&&b.initWithAction(a);return b}; +cc.EaseElastic=cc.ActionEase.extend({getPeriod:function(){return this._period},setPeriod:function(a){this._period=a},initWithAction:function(a,b){this._super(a);this._period=null==b?3:b;return!0},reverse:function(){cc.Assert(0,"Override me");return null},copyWithZone:function(){},_period:null});cc.EaseElastic.create=function(a,b){var c=new cc.EaseElastic;c&&(null==b?c.initWithAction(a):c.initWithAction(a,b));return c}; +cc.EaseElasticIn=cc.EaseElastic.extend({update:function(a){var b=0;0==a||1==a?b=a:(b=this._period/4,a-=1,b=-Math.pow(2,10*a)*Math.sin(2*(a-b)*Math.PI/this._period));this._other.update(b)},reverse:function(){return cc.EaseElasticOut.create(this._other.reverse(),this._period)},copyWithZone:function(){}});cc.EaseElasticIn.create=function(a,b){var c=new cc.EaseElasticIn;c&&(null==b?c.initWithAction(a):c.initWithAction(a,b));return c}; +cc.EaseElasticOut=cc.EaseElastic.extend({update:function(a){var b=0;0==a||1==a?b=a:(b=this._period/4,b=Math.pow(2,-10*a)*Math.sin(2*(a-b)*Math.PI/this._period)+1);this._other.update(b)},reverse:function(){return cc.EaseElasticIn.create(this._other.reverse(),this._period)},copyWithZone:function(){}});cc.EaseElasticOut.create=function(a,b){var c=new cc.EaseElasticOut;c&&(null==b?c.initWithAction(a):c.initWithAction(a,b));return c}; +cc.EaseElasticInOut=cc.EaseElastic.extend({update:function(a){var b=0;0==a||1==a?b=a:(this._period||(this._period=0.3*1.5),b=this._period/4,a=2*a-1,b=0>a?-0.5*Math.pow(2,10*a)*Math.sin(2*(a-b)*Math.PI/this._period):0.5*Math.pow(2,-10*a)*Math.sin(2*(a-b)*Math.PI/this._period)+1);this._other.update(b)},reverse:function(){return cc.EaseInOut.create(this._other.reverse(),this._period)},copyWithZone:function(){}}); +cc.EaseElasticInOut.create=function(a,b){var c=new cc.EaseElasticInOut;c&&(null==b?c.initWithAction(a):c.initWithAction(a,b));return c};cc.EaseBounce=cc.ActionEase.extend({bounceTime:function(a){if(a<1/2.75)return 7.5625*a*a;if(a<2/2.75)return a-=1.5/2.75,7.5625*a*a+0.75;if(a<2.5/2.75)return a-=2.25/2.75,7.5625*a*a+0.9375;a-=2.625/2.75;return 7.5625*a*a+0.984375},reverse:function(){return cc.EaseBounce.create(this._other.reverse())},copyWithZone:function(){}}); +cc.EaseBounce.create=function(a){var b=new cc.EaseBounce;b&&b.initWithAction(a);return b};cc.EaseBounceIn=cc.EaseBounce.extend({update:function(a){a=1-this.bounceTime(1-a);this._other.update(a)},reverse:function(){return cc.EaseBounceOut.create(this._other.reverse())},copyWithZone:function(){}});cc.EaseBounceIn.create=function(a){var b=new cc.EaseBounceIn;b&&b.initWithAction(a);return b}; +cc.EaseBounceOut=cc.EaseBounce.extend({update:function(a){a=this.bounceTime(a);this._other.update(a)},reverse:function(){return cc.EaseBounceIn.create(this._other.reverse())},copyWithZone:function(){}});cc.EaseBounceOut.create=function(a){var b=new cc.EaseBounceOut;b&&b.initWithAction(a);return b}; +cc.EaseBounceInOut=cc.EaseBounce.extend({update:function(a){var b=0,b=0.5>a?0.5*(1-this.bounceTime(1-2*a)):0.5*this.bounceTime(2*a-1)+0.5;this._other.update(b)},reverse:function(){return cc.EaseBounceInOut.create(this._other.reverse())},copyWithZone:function(){}});cc.EaseBounceInOut.create=function(a){var b=new cc.EaseBounceInOut;b&&b.initWithAction(a);return b}; +cc.EaseBackIn=cc.ActionEase.extend({update:function(a){this._other.update(a*a*(2.70158*a-1.70158))},reverse:function(){return cc.EaseBackOut.create(this._other.reverse())},copyWithZone:function(){}});cc.EaseBackIn.create=function(a){var b=new cc.EaseBackIn;b&&b.initWithAction(a);return b};cc.EaseBackOut=cc.ActionEase.extend({update:function(a){a-=1;this._other.update(a*a*(2.70158*a+1.70158)+1)},reverse:function(){return cc.EaseBackIn.create(this._other.reverse())},copyWithZone:function(){}}); +cc.EaseBackOut.create=function(a){var b=new cc.EaseBackOut;b&&b.initWithAction(a);return b};cc.EaseBackInOut=cc.ActionEase.extend({update:function(a){a*=2;1>a?this._other.update(a*a*(3.5949095*a-2.5949095)/2):(a-=2,this._other.update(a*a*(3.5949095*a+2.5949095)/2+1))},reverse:function(){return cc.EaseBackInOut.create(this._other.reverse())},copyWithZone:function(){}});cc.EaseBackInOut.create=function(a){var b=new cc.EaseBackInOut;b&&b.initWithAction(a);return b};cc=cc=cc||{}; +cc.GridAction=cc.ActionInterval.extend({_gridSize:null,startWithTarget:function(a){this._super(a);var a=this.getGrid(),b=this._target,c=b.getGrid();c&&0a?0:a;a=a>this._controlPoints.length-1?this._controlPoints.length- +1:a;return this._controlPoints[a]},removeControlPointAtIndex:function(a){cc.ArrayRemoveObjectAtIndex(this._controlPoints,a)},count:function(){return this._controlPoints.length},reverse:function(){for(var a=[],b=this._controlPoints.length-1;0<=b;b--)a.push(cc.p(this._controlPoints[b].x,this._controlPoints[b].y));b=new cc.PointArray;b.setControlPoints(a);return b},reverseInline:function(){for(var a=this._controlPoints.length,b=0|a/2,c=0;ca;a++)this._squareColors[a].r=this._color.r/255,this._squareColors[a].g=this._color.g/255,this._squareColors[a].b=this._color.b/255,this._squareColors[a].a=this._opacity/255},setOpacityModifyRGB:function(){},isOpacityModifyRGB:function(){return!1},draw:function(a){a=a||cc.renderContext;if(cc.renderContextType==cc.CANVAS){var b=this.getContentSize().width,c=this.getContentSize().height, +d=this.getAnchorPointInPoints(),e=a.createLinearGradient(-d.x,d.y,-d.x+b,-(d.y+c));e.addColorStop(0,"rgba("+Math.round(255*this._squareColors[0].r)+","+Math.round(255*this._squareColors[0].g)+","+Math.round(255*this._squareColors[0].b)+","+this._squareColors[0].a.toFixed(4)+")");e.addColorStop(1,"rgba("+Math.round(255*this._squareColors[3].r)+","+Math.round(255*this._squareColors[3].g)+","+Math.round(255*this._squareColors[3].b)+","+this._squareColors[3].a.toFixed(4)+")");a.fillStyle=e;a.fillRect(-d.x, +d.y,b,-c)}this._super(a);cc.INCREMENT_GL_DRAWS(1)}});cc.LayerColor.create=function(a,b,c){var d=new cc.LayerColor;switch(arguments.length){case 0:d.init();break;case 1:d.initWithColor(a);break;case 3:d.initWithColor(a,b,c);break;default:d.init()}return d}; +cc.LayerGradient=cc.LayerColor.extend({_startColor:new cc.Color3B(0,0,0),_endColor:new cc.Color3B(0,0,0),_startOpacity:null,_endOpacity:null,_alongVector:null,_compressedInterpolation:!1,ctor:function(){this._startColor=new cc.Color3B(0,0,0);this._endColor=new cc.Color3B(0,0,0);this._alongVector=cc.p(0,-1);this._super()},getStartColor:function(){return this._color},setStartColor:function(a){this.setColor(a)},setEndColor:function(a){this._endColor=a;this._updateColor()},getEndColor:function(){return this._endColor}, +setStartOpacity:function(a){this._startOpacity=a;this._updateColor()},getStartOpacity:function(){return this._startOpacity},setEndOpacity:function(a){this._endOpacity=a;this._updateColor()},getEndOpacity:function(){return this._endOpacity},setVector:function(a){this.alongVector=a;this._updateColor()},getVector:function(){return this.alongVector},isCompressedInterpolation:function(){return this._compressedInterpolation},setCompressedInterpolation:function(a){this._compressedInterpolation=a;this._updateColor()}, +initWithColor:function(a,b,c){2==arguments.length&&(c=cc.p(0,-1));this._startColor.r=a.r;this._startColor.g=a.g;this._startColor.b=a.b;this._startOpacity=a.a;this._endColor.r=b.r;this._endColor.g=b.g;this._endColor.b=b.b;this._endOpacity=b.a;this.alongVector=c;this._compressedInterpolation=!0;return this._super(cc.c4b(a.r,a.g,a.b,255))},_updateColor:function(){this._super();var a=cc.pLength(this._alongVector);if(0!=a){var b=Math.sqrt(2),a=cc.p(this._alongVector.x/a,this._alongVector.y/a);if(this._compressedInterpolation)var c= +1/(Math.abs(a.x)+Math.abs(a.y)),a=cc.pMult(a,c*b);var d=this._opacity/255,c=new cc.Color4F(this._startColor.r/255,this._startColor.g/255,this._startColor.b/255,this._startOpacity*d/255),d=new cc.Color4F(this._endColor.r/255,this._endColor.g/255,this._endColor.b/255,this._endOpacity*d/255);this._squareColors[0].r=parseInt(d.r+(c.r-d.r)*((b+a.x+a.y)/(2*b)));this._squareColors[0].g=parseInt(d.g+(c.g-d.g)*((b+a.x+a.y)/(2*b)));this._squareColors[0].b=parseInt(d.b+(c.b-d.b)*((b+a.x+a.y)/(2*b)));this._squareColors[0].a= +parseInt(d.a+(c.a-d.a)*((b+a.x+a.y)/(2*b)));this._squareColors[1].r=parseInt(d.r+(c.r-d.r)*((b-a.x+a.y)/(2*b)));this._squareColors[1].g=parseInt(d.g+(c.g-d.g)*((b-a.x+a.y)/(2*b)));this._squareColors[1].b=parseInt(d.b+(c.b-d.b)*((b-a.x+a.y)/(2*b)));this._squareColors[1].a=parseInt(d.a+(c.a-d.a)*((b-a.x+a.y)/(2*b)));this._squareColors[2].r=parseInt(d.r+(c.r-d.r)*((b+a.x-a.y)/(2*b)));this._squareColors[2].g=parseInt(d.g+(c.g-d.g)*((b+a.x-a.y)/(2*b)));this._squareColors[2].b=parseInt(d.b+(c.b-d.b)*((b+ +a.x-a.y)/(2*b)));this._squareColors[2].a=parseInt(d.a+(c.a-d.a)*((b+a.x-a.y)/(2*b)));this._squareColors[3].r=parseInt(d.r+(c.r-d.r)*((b-a.x-a.y)/(2*b)));this._squareColors[3].g=parseInt(d.g+(c.g-d.g)*((b-a.x-a.y)/(2*b)));this._squareColors[3].b=parseInt(d.b+(c.b-d.b)*((b-a.x-a.y)/(2*b)));this._squareColors[3].a=parseInt(d.a+(c.a-d.a)*((b-a.x-a.y)/(2*b)))}}}); +cc.LayerGradient.create=function(a,b,c){var d=new cc.LayerGradient;switch(arguments.length){case 2:if(d&&d.initWithColor(a,b))return d;break;case 3:if(d&&d.initWithColor(a,b,c))return d;break;case 0:if(d&&d.init())return d;break;default:throw"Arguments error ";}return null}; +cc.LayerMultiplex=cc.Layer.extend({_enabledLayer:0,_layers:null,ctor:function(){this._super()},initWithLayer:function(a){this._layers=[];this._layers.push(a);this._enabledLayer=0;this.addChild(a);return!0},initWithLayers:function(a){this._layers=a;this._enabledLayer=0;this.addChild(this._layers[this._enabledLayer]);return!0},switchTo:function(a){cc.Assert(ab&&(a=b);this._layerContext.translate(0,this._layerCanvas.height);this._layerContext.scale(a,a)},getLayerCanvas:function(){return this._layerCanvas},addChild:function(a,b,c){this._isNeedUpdate= +!0;this._super(a,b,c)},removeChild:function(a,b){this._isNeedUpdate=!0;this._super(a,b)},visit:function(){if(this._isVisible&&this._isNeedUpdate){this._isNeedUpdate=!1;var a=this._layerContext;a.save();a.clearRect(0,0,this._layerCanvas.width,-this._layerCanvas.height);if(this._children&&0a.height?(a=16,b=12):(a=12,b=16);a=this.actionWithSize(cc.g(a,b));this._back?(this._inScene.setVisible(!1),this._inScene.runAction(cc.Sequence.create(cc.Show.create(), +a,cc.CallFunc.create(this,cc.TransitionScene.finish),cc.StopGrid.create()))):this._outScene.runAction(cc.Sequence.create(a,cc.CallFunc.create(this,cc.TransitionScene.finish),cc.StopGrid.create()))},_sceneOrder:function(){this.isInSceneOnTop=this._back}});cc.TransitionPageTurn.create=function(a,b,c){var d=new cc.TransitionPageTurn;d.initWithDuration(a,b,c);return d};cc.SPRITE_INDEX_NOT_INITIALIZED="0xffffffff"; +cc.generateTextureCacheForColor=function(a){var b=a.width,c=a.height,d=[],e=document.createElement("canvas");e.width=b;e.height=c;var f=e.getContext("2d");f.drawImage(a,0,0);e=document.createElement("canvas");e.width=b;e.height=c;for(var e=e.getContext("2d"),f=f.getImageData(0,0,b,c).data,g=0;3>g;g++){var h=document.createElement("canvas");h.width=b;h.height=c;var j=h.getContext("2d");e.drawImage(a,0,0);for(var k=e.getImageData(0,0,b,c),l=k.data,m=0;mc?d&&d.initWithFile(a)?d:null:d&&d.initWithFile(a,b)?d:null}; +cc.Sprite.createWithSpriteFrameName=function(a){if("string"==typeof a){var b=cc.SpriteFrameCache.getInstance().getSpriteFrame(a);if(b)a=b;else return cc.log("Invalid spriteFrameName: "+a),null}return(b=new cc.Sprite)&&b.initWithSpriteFrame(a)?b:null};cc.AnimationFrame=cc.Class.extend({_spriteFrame:null,_delayPerUnit:0,_userInfo:null,ctor:function(){this._delayPerUnit=0},copyWithZone:function(){return cc.clone(this)},copy:function(){var a=new cc.AnimationFrame;a.initWithSpriteFrame(this._spriteFrame,this._delayPerUnit,this._userInfo);return a},initWithSpriteFrame:function(a,b,c){this.setSpriteFrame(a);this.setDelayUnits(b);this.setUserInfo(c);return!0},getSpriteFrame:function(){return this._spriteFrame},setSpriteFrame:function(a){this._spriteFrame= +a},getDelayUnits:function(){return this._delayPerUnit},setDelayUnits:function(a){this._delayPerUnit=a},getUserInfo:function(){return this._userInfo},setUserInfo:function(a){this._userInfo=a}}); +cc.Animation=cc.Class.extend({_frames:null,_loops:0,_restoreOriginalFrame:!1,_duration:0,_delayPerUnit:0,_totalDelayUnits:0,ctor:function(){this._frames=[]},getFrames:function(){return this._frames},setFrames:function(a){this._frames=a},addSpriteFrame:function(a){var b=new cc.AnimationFrame;b.initWithSpriteFrame(a,1,null);this._frames.push(b);this._totalDelayUnits++},addSpriteFrameWithFileName:function(a){var a=cc.TextureCache.getInstance().addImage(a),b=cc.RectZero();b.size=a instanceof HTMLImageElement|| +a instanceof HTMLCanvasElement?cc.size(a.width,a.height):a.getContentSize();a=cc.SpriteFrame.createWithTexture(a,b);this.addSpriteFrame(a)},addSpriteFrameWithTexture:function(a,b){var c=cc.SpriteFrame.createWithTexture(a,b);this.addSpriteFrame(c)},initWithAnimationFrames:function(a,b,c){cc.ArrayVerifyType(a,cc.AnimationFrame);this._delayPerUnit=b;this._loops=c;this.setFrames([]);for(b=0;b=e,"format is not supported for cc.SpriteFrameCache addSpriteFramesWithDictionary:textureFilename:");for(var f in d){var g=d[f];if(g&&(c=this._spriteFrames[f], +!c)){if(0==e){var h=parseFloat(this._valueForKey("x",g)),j=parseFloat(this._valueForKey("y",g)),k=parseFloat(this._valueForKey("width",g)),l=parseFloat(this._valueForKey("height",g)),m=parseFloat(this._valueForKey("offsetX",g)),n=parseFloat(this._valueForKey("offsetY",g)),q=parseInt(this._valueForKey("originalWidth",g)),g=parseInt(this._valueForKey("originalHeight",g));(!q||!g)&&cc.log("cocos2d: WARNING: originalWidth/Height not found on the cc.SpriteFrame. AnchorPoint won't work as expected. Regenrate the .plist"); +q=Math.abs(q);g=Math.abs(g);c=new cc.SpriteFrame;c.initWithTexture(b,cc.rect(h,j,k,l),!1,cc.p(m,n),cc.size(q,g))}else if(1==e||2==e)h=cc.RectFromString(this._valueForKey("frame",g)),j=!1,2==e&&(j="true"==this._valueForKey("rotated",g)),k=cc.PointFromString(this._valueForKey("offset",g)),g=cc.SizeFromString(this._valueForKey("sourceSize",g)),c=new cc.SpriteFrame,c.initWithTexture(b,h,j,k,g);else if(3==e){g.hasOwnProperty("spriteSize")?(h=cc.SizeFromString(this._valueForKey("spriteSize",g)),j=cc.PointFromString(this._valueForKey("spriteOffset", +g)),k=cc.SizeFromString(this._valueForKey("spriteSourceSize",g)),l=cc.RectFromString(this._valueForKey("textureRect",g)),m="true"==this._valueForKey("textureRotated",g)):(h=cc.RectFromString(this._valueForKey("frame",g)),j=cc.PointFromString(this._valueForKey("offset",g)),k=cc.SizeFromString(this._valueForKey("sourceSize",g)),l=cc.SizeFromString(this._valueForKey("sourceSize",g)),m="true"==this._valueForKey("rotated",g));var c=g.aliases,n=f.toString(),r;for(r in c)this._spriteFramesAliases.hasOwnProperty(c[r])&& +cc.log("cocos2d: WARNING: an alias with name "+r+" already exists"),this._spriteFramesAliases[c[r]]=n;c=new cc.SpriteFrame;g.hasOwnProperty("spriteSize")?c.initWithTexture(b,cc.rect(l.origin.x,l.origin.y,h.width,h.height),m,j,k):c.initWithTexture(b,h,m,j,k)}c.isRotated()&&(g=cc.cutRotateImageToCanvas(c.getTexture(),c.getRect()),h=c.getRect(),c.setRect(cc.rect(0,0,h.size.width,h.size.height)),c.setTexture(g));this._spriteFrames[f]=c}}},addSpriteFramesWithJson:function(a){var b="",c=a.metadata;c&&(b= +this._valueForKey("textureFileName",c),b=b.toString());(b=cc.TextureCache.getInstance().addImage(b))?this._addSpriteFramesWithDictionary(a,b):cc.log("cocos2d: cc.SpriteFrameCache: Couldn't load texture")},addSpriteFrames:function(a,b){var c=cc.FileUtils.getInstance().dictionaryWithContentsOfFileThreadSafe(a);switch(arguments.length){case 1:cc.Assert(a,"plist filename should not be NULL");if(!cc.ArrayContainsObject(this._loadedFileNames,a)){var d="",e=c.metadata;e&&(d=this._valueForKey("textureFileName", +e).toString());""!=d?(e=a.lastIndexOf("/"),d=(e?a.substring(0,e+1):"")+d):(d=a,e=d.lastIndexOf(".",d.length),d=d.substr(0,e),d+=".png",cc.log("cocos2d: cc.SpriteFrameCache: Trying to use file "+d.toString()+" as texture"));(d=cc.TextureCache.getInstance().addImage(d))?this._addSpriteFramesWithDictionary(c,d):cc.log("cocos2d: cc.SpriteFrameCache: Couldn't load texture")}break;case 2:b instanceof cc.Texture2D||b instanceof HTMLImageElement||b instanceof HTMLCanvasElement?this._addSpriteFramesWithDictionary(c, +b):(cc.Assert(b,"texture name should not be null"),(d=cc.TextureCache.getInstance().addImage(b))?this._addSpriteFramesWithDictionary(c,d):cc.log("cocos2d: cc.SpriteFrameCache: couldn't load texture file. File not found "+b));break;default:throw"Argument must be non-nil ";}},addSpriteFrame:function(a,b){this._spriteFrames[b]=a},removeSpriteFrames:function(){this._spriteFrames=[];this._spriteFramesAliases=[];this._loadedFileNames={}},removeSpriteFrameByName:function(a){a&&(this._spriteFramesAliases.hasOwnProperty(a)&& +delete this._spriteFramesAliases[a],this._spriteFrames.hasOwnProperty(a)&&delete this._spriteFrames[a],this._loadedFileNames={})},removeSpriteFramesFromFile:function(a){var b=cc.FileUtils.getInstance().fullPathFromRelativePath(a),b=cc.FileUtils.getInstance().dictionaryWithContentsOfFileThreadSafe(b);this._removeSpriteFramesFromDictionary(b);cc.ArrayContainsObject(this._loadedFileNames,a)&&cc.ArrayRemoveObject(a)},_removeSpriteFramesFromDictionary:function(a){var a=a.frames,b;for(b in a)this._spriteFrames.hasOwnProperty(b)&& +delete this._spriteFrames[b]},removeSpriteFramesFromTexture:function(a){for(var b in this._spriteFrames){var c=this._spriteFrames[b];c&&c.getTexture()==a&&delete this._spriteFrames[b]}},getSpriteFrame:function(a){var b;this._spriteFrames.hasOwnProperty(a)&&(b=this._spriteFrames[a]);if(!b){var c;this._spriteFramesAliases.hasOwnProperty(a)&&(c=this._spriteFramesAliases[a]);c&&(this._spriteFrames.hasOwnProperty(c.toString())&&(b=this._spriteFrames[c.toString()]),b||cc.log("cocos2d: cc.SpriteFrameCahce: Frame "+ +a+" not found"))}return b},_valueForKey:function(a,b){return b&&b.hasOwnProperty(a)?b[a].toString():""}});cc.s_sharedSpriteFrameCache=null;cc.SpriteFrameCache.getInstance=function(){cc.s_sharedSpriteFrameCache||(cc.s_sharedSpriteFrameCache=new cc.SpriteFrameCache);return cc.s_sharedSpriteFrameCache};cc.SpriteFrameCache.purgeSharedSpriteFrameCache=function(){cc.s_sharedSpriteFrameCache=null};cc.DEFAULT_SPRITE_BATCH_CAPACITY=29; +cc.SpriteBatchNode=cc.Node.extend({_textureAtlas:new cc.TextureAtlas,_blendFunc:new cc.BlendFunc(0,0),_descendants:[],_renderTexture:null,_isUseCache:!1,_originalTexture:null,ctor:function(a){this._super();a&&this.initWithFile(a,cc.DEFAULT_SPRITE_BATCH_CAPACITY);this._renderTexture=cc.RenderTexture.create(cc.canvas.width,cc.canvas.height);this.setContentSize(cc.size(cc.canvas.width,cc.canvas.height))},setContentSize:function(a){a&&(this._super(a),this._renderTexture.setContentSize(a))},_updateBlendFunc:function(){this._textureAtlas.getTexture().hasPremultipliedAlpha()|| +(this._blendFunc.src=gl.SRC_ALPHA,this._blendFunc.dst=gl.ONE_MINUS_SRC_ALPHA)},_updateAtlasIndex:function(a,b){var c=0,d=a.getChildren();d&&(c=d.length);var e=0;if(0==c)e=a.getAtlasIndex(),a.setAtlasIndex(b),a.setOrderOfArrival(0),e!=b&&this._swap(e,b),b++;else{e=!0;0<=d[0].getZOrder()&&(e=a.getAtlasIndex(),a.setAtlasIndex(b),a.setOrderOfArrival(0),e!=b&&this._swap(e,b),b++,e=!1);for(c=0;c=b&&++d;this._descendants=cc.ArrayAppendObjectToIndex(this._descendants,a,d);this.addChild(a,b,c);this.reorderBatch(!1);return this},getTextureAtlas:function(){return this._textureAtlas},setTextureAtlas:function(a){a!=this._textureAtlas&&(this._textureAtlas=a)},getDescendants:function(){return this._descendants},initWithTexture:function(a,b){this._children= +[];this._descendants=[];this._blendFunc.src=cc.BLEND_SRC;this._blendFunc.dst=cc.BLEND_DST;this._textureAtlas=new cc.TextureAtlas;b=b||cc.DEFAULT_SPRITE_BATCH_CAPACITY;this._textureAtlas.initWithTexture(a,b);cc.renderContextType==cc.CANVAS&&(this._originalTexture=a);cc.renderContextType==cc.WEBGL&&this._updateBlendFunc();return!0},setNodeDirty:function(){this._setNodeDirtyForCache();this._isTransformDirty=this._isInverseDirty=!0;cc.NODE_TRANSFORM_USING_AFFINE_MATRIX&&(this._isTransformGLDirty=!0)}, +_setNodeDirtyForCache:function(){this._isCacheDirty=!0},initWithFile:function(a,b){var c=cc.TextureCache.getInstance().textureForKey(a);c||(c=cc.TextureCache.getInstance().addImage(a));return this.initWithTexture(c,b)},init:function(){var a=new cc.Texture2D;return this.initWithTexture(a,0)},increaseAtlasCapacity:function(){var a=4*(this._textureAtlas.getCapacity()+1)/3;cc.log("cocos2d: CCSpriteBatchNode: resizing TextureAtlas capacity from "+this._textureAtlas.getCapacity()+" to ["+a+"].");this._textureAtlas.resizeCapacity(a)|| +(cc.log("cocos2d: WARNING: Not enough memory to resize the atlas"),cc.Assert(!1,"Not enough memory to resize the atla"))},removeChildAtIndex:function(a,b){this.removeChild(this._children[a],b)},insertChild:function(a,b){a.setBatchNode(this);a.setAtlasIndex(b);a.setDirty(!0);this._textureAtlas.getTotalQuads()==this._textureAtlas.getCapacity()&&this.increaseAtlasCapacity();this._textureAtlas.insertQuad(a.getQuad(),b);this._descendants=cc.ArrayAppendObjectToIndex(this._descendants,a,b);var c=b+1;if(this._descendants&& +0e.getZOrder()&&(b=this.rebuildIndexInOrder(e,b))}a.isEqual(this)||(a.setAtlasIndex(b),b++);if(c&&0b?c.getAtlasIndex():c.getAtlasIndex()+1;if(0>f.getZOrder()&&0>b||0<=f.getZOrder()&& +0<=b)return this.highestAtlasIndexInChild(f)+1;c=a.getParent();return c.getAtlasIndex()+1},reorderBatch:function(a){this._reorderChildDirty=a},getTexture:function(){return this._textureAtlas.getTexture()},setTexture:function(a){this._textureAtlas.setTexture(a);for(var b=0;b"},setString:function(a){this._string!=a&&(this._string=a,0this._dimensions.width||this._string.indexOf("\n"))&&0!==this._dimensions.width?this._wrapText(a,this._string,-this._dimensions.width* +this._anchorPoint.x,this._dimensions.height*this._anchorPoint.y,this._dimensions.width,this._dimensions.height,1.2*this._fontSize):0==this._dimensions.width?a.fillText(this._string,-this._contentSize.width*this._anchorPoint.x,this._contentSize.height*this._anchorPoint.y):a.fillText(this._string,-this._dimensions.width*this._anchorPoint.x+b,this._dimensions.height*this._anchorPoint.y+c);cc.INCREMENT_GL_DRAWS(1)}},_wrapText:function(a,b,c,d,e,f,g){var h=this._lineCount()-1,j;switch(this._hAlignment){case cc.TEXT_ALIGNMENT_LEFT:a.textAlign= +"left";j=0;break;case cc.TEXT_ALIGNMENT_RIGHT:a.textAlign="right";j=e;break;default:a.textAlign="center",j=e/2}switch(this._vAlignment){case cc.VERTICAL_TEXT_ALIGNMENT_TOP:a.textBaseline="top";f=-f;break;case cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM:a.textBaseline="bottom";f=-g*h;break;default:a.textBaseline="middle",f=-f/2-g*h/2}b=b.split("\n");for(h=0;h=e?(a.fillText(m, +c+j,d+f+k),d+=g,m=l[n]+" "):m=q;n==l.length-1&&a.fillText(m,c+j,d+f+k)}},_lineCount:function(){if(0==this._dimensions.width)return 1;var a=cc.renderContext,b=this._string.split(" "),c="",d=0;cc.renderContext.save();for(var e=0;e=this._dimensions.width&&(d++,c=b[e]+" "),e==b.length-1&&d++;cc.renderContext.restore();return d},_updateTTF:function(){cc.renderContext.save();this._fontStyleStr=this._fontSize+"px '"+this._fontName+ +"'";cc.renderContext.font=this._fontStyleStr;var a=cc.renderContext.measureText(this._string);this.setContentSize(cc.size(a.width,this._fontSize));cc.renderContext.restore();this.setNodeDirty()}});cc.LabelTTF.create=function(){var a=new cc.LabelTTF;return a.initWithString(arguments)?a:null};cc.LabelTTF.node=function(){return cc.LabelTTF.create()};cc.LabelNode=function(a,b,c){this.pos=a;this.text=b;this.align=c};cc.LabelAutomaticWidth=-1;cc._KerningHashElement=function(a,b){this.key=a;this.amount=b};cc._FontDefHashElement=function(a,b){this.key=a||0;this.fontDef=b||new cc._BMFontDef};cc._BMFontDef=function(a,b,c,d,e){this.charID=a||0;this.rect=b||cc.rect(0,0,0.1,0.1);this.xOffset=c||0;this.yOffset=d||0;this.xAdvance=e||0};cc._BMFontPadding=function(a,b,c,d){this.left=a||0;this.top=b||0;this.right=c||0;this.bottom=d||0}; +cc.BMFontConfiguration=cc.Class.extend({bitmapFontArray:{},commonHeight:0,padding:new cc._BMFontPadding,atlasName:"",kerningDictionary:{},fontDefDictionary:null,ctor:function(){this.fontDefDictionary={};this.fontDefDictionary["0"]=new cc._FontDefHashElement},description:function(){return""},getAtlasName:function(){return this.atlasName},setAtlasName:function(a){this.atlasName=a},initWithFNTfile:function(a){cc.Assert(null!= +a&&0!=a.length,"");this._parseConfigFile(a);return!0},_parseConfigFile:function(a){var b=cc.SAXParser.getInstance().getList(a);cc.Assert(b,"cc.BMFontConfiguration._parseConfigFile | Open file error.");var c,d;d=/padding+[a-z0-9\-= ",]+/gi;(c=d.exec(b)[0])&&this._parseInfoArguments(c);d=/common lineHeight+[a-z0-9\-= ",]+/gi;(c=d.exec(b)[0])&&this._parseCommonArguments(c);d=/page id=[a-zA-Z0-9\.\-= ",]+/gi;(c=d.exec(b)[0])&&this._parseImageFileName(c,a);d=/chars c+[a-z0-9\-= ",]+/gi;d.exec(b);d=/char id=\w[a-z0-9\-= ]+/gi; +if(c=b.match(d))for(a=0;a=a)break;var n=this._string[e];g||(j=this._getLetterPosXLeft(l),g=!0);f||(h=j,f=!0);if(10==n.charCodeAt(0)){c.push("\n");b=b.concat(c);c.length=0;f=g=!1;h=j=-1;e++;d++;if(e>=a)break;n=this._string[e];j||(j=this._getLetterPosXLeft(l),g=!0);h||(h=j,f=!0)}if(32==n.charCodeAt(0))c.push(n),b=b.concat(c),c.length=0,g=!1,j=-1,e++;else if(this._getLetterPosXRight(l)-h>this._width)if(this._lineBreakWithoutSpaces){cc.utf8_trim_ws(c); +c.push("\n");b=b.concat(c);c.length=0;f=g=!1;h=j=-1;d++;if(e>=a)break;j||(j=this._getLetterPosXLeft(l),g=!0);h||(h=j,f=!0);m--}else c.push(n),-1!=b.lastIndexOf(" ")?cc.utf8_trim_ws(b):b=[],0l)&&(m=this.getChildByTag(l),null!=m)){m=m.getPosition().x+m.getContentSize().width/2;g=0;switch(this._alignment){case cc.TEXT_ALIGNMENT_CENTER:g=this.getContentSize().width/2-m/2;break;case cc.TEXT_ALIGNMENT_RIGHT:g=this.getContentSize().width-m}if(0!=g)for(m=0;ml||(l=this.getChildByTag(l),l.setPosition(cc.pAdd(l.getPosition(),cc.p(g,0))));e+=f;b++;c.length=0}}else c.push(this._string[e])}},setAlignment:function(a){this._alignment= +a;this.updateLabel()},setWidth:function(a){this._width=a;this.updateLabel()},setLineBreakWithoutSpace:function(a){this._lineBreakWithoutSpaces=a;this.updateLabel()},setScale:function(a,b){this._super(a,b);this.updateLabel()},setScaleX:function(a){this._super(a);this.updateLabel()},setScaleY:function(a){this._super(a);this.updateLabel()},setFntFile:function(a){if(null!=a&&a!=this._fntFile){var b=cc.FNTConfigLoadFile(a);cc.Assert(b,"cc.LabelBMFont: Impossible to create font. Please check file");this._fntFile= +a;this._configuration=b;this.setTexture(cc.TextureCache.getInstance().addImage(this._configuration.getAtlasName()));cc.renderContextType==cc.CANVAS&&(this._originalTexture=this.getTexture());this.createFontChars()}},getFntFile:function(){return this._fntFile},setAnchorPoint:function(a){cc.Point.CCPointEqualToPoint(a,this._anchorPoint)||(this._super(a),this.updateLabel())},_atlasNameFromFntFile:function(){},_kerningAmountForFirst:function(a,b){var c=0;if(this._configuration.kerningDictionary){var d= +this._configuration.kerningDictionary[(a<<16|b&65535).toString()];d&&(c=d.amount)}return c},_getLetterPosXLeft:function(a){return a.getPosition().x*this._scaleX+a.getContentSize().width*this._scaleX*a.getAnchorPoint().x},_getLetterPosXRight:function(a){return a.getPosition().x*this._scaleX-a.getContentSize().width*this._scaleX*a.getAnchorPoint().x}});cc.LabelBMFont.create=function(a,b,c,d,e){var f=new cc.LabelBMFont;return 0==arguments.length?f&&f.init()?f:null:f&&f.initWithString(a,b,c,d,e)?f:null}; +cc.configurations=null;cc.FNTConfigLoadFile=function(a){cc.configurations||(cc.configurations={});var b=cc.configurations[a];b||(b=cc.BMFontConfiguration.create(a));return b};cc.purgeCachedData=function(){cc.FNTConfigRemoveCache()};cc.FNTConfigRemoveCache=function(){cc.configurations&&(cc.configurations={})};cc.isspace_unicode=function(a){a=a.charCodeAt(0);return 9<=a&&13>=a||32==a||133==a||160==a||5760==a||8192<=a&&8202>=a||8232==a||8233==a||8239==a||8287==a||12288==a}; +cc.utf8_trim_ws=function(a){var b=a.length;if(!(0>=b)&&(b-=1,cc.isspace_unicode(a[b]))){for(var c=b-1;0<=c;--c)if(cc.isspace_unicode(a[c]))b=c;else break;cc.utf8_trim_from(a,b)}};cc.utf8_trim_from=function(a,b){var c=a.length;b>=c||0>b||a.splice(b,c)};cc.PARTICLE_SHAPE_MODE=0;cc.PARTICLE_TEXTURE_MODE=1;cc.PARTICLE_STAR_SHAPE=0;cc.PARTICLE_BALL_SHAPE=1;cc.PARTICLE_DURATION_INFINITY=-1;cc.PARTICLE_START_SIZE_EQUAL_TO_END_SIZE=-1;cc.PARTICLE_START_RADIUS_EQUAL_TO_END_RADIUS=-1;cc.PARTICLE_MODE_GRAVITY=0;cc.PARTICLE_MODE_RADIUS=1;cc.PARTICLE_TYPE_FREE=0;cc.PARTICLE_TYPE_RELATIVE=1;cc.PARTICLE_TYPE_GROUPED=2;cc.PARTICLE_TYPE_FREE=cc.PARTICLE_TYPE_FREE;cc.PARTICLE_TYPE_GROUPED=cc.PARTICLE_TYPE_GROUPED; +cc.Particle=function(a,b,c,d,e,f,g,h,j,k,l,m){this.pos=a?a:cc.PointZero();this.startPos=b?b:cc.PointZero();this.color=c?c:new cc.Color4F(0,0,0,1);this.deltaColor=d?d:new cc.Color4F(0,0,0,1);this.size=e||0;this.deltaSize=f||0;this.rotation=g||0;this.deltaRotation=h||0;this.timeToLive=j||0;this.atlasIndex=k||0;this.modeA=l?l:new cc.Particle.ModeA;this.modeB=m?m:new cc.Particle.ModeB;this.isChangeColor=!1;this.drawPos=cc.p(0,0)}; +cc.Particle.ModeA=function(a,b,c){this.dir=a?a:cc.PointZero();this.radialAccel=b||0;this.tangentialAccel=c||0};cc.Particle.ModeB=function(a,b,c,d){this.angle=a||0;this.degreesPerSecond=b||0;this.radius=c||0;this.deltaRadius=d||0}; +cc.ParticleSystem=cc.Node.extend({_plistFile:"",_elapsed:0,_dontTint:!1,modeA:null,modeB:null,_particles:null,_emitCounter:0,_particleIdx:0,_batchNode:null,getBatchNode:function(){return this._batchNode},setBatchNode:function(a){if(this._batchNode!=a&&(this._batchNode=a))for(a=0;a=this._totalParticles},updateQuadWithParticle:function(){},postStep:function(){},update:function(a){if(this._isActive&&this._emissionRate){var b=1/this._emissionRate;this._particleCountb;)this.addParticle(),this._emitCounter-=b;this._elapsed+=a;-1!=this._duration&&this._durationthis._textureAtlas.getCapacity()&&(this._increaseAtlasCapacityTo(this._textureAtlas.getTotalQuads()+a.getTotalParticles()),this._textureAtlas.fillWithEmptyQuadsFromIndex(this._textureAtlas.getCapacity()- +a.getTotalParticles(),a.getTotalParticles()));a.getAtlasIndex()+a.getTotalParticles()!=this._textureAtlas.getTotalQuads()&&this._textureAtlas.moveQuadsFromIndex(b,b+a.getTotalParticles());this._textureAtlas.increaseTotalQuadsWith(a.getTotalParticles());this._updateAllAtlasIndexes()},removeChild:function(a,b){null!=a&&(cc.Assert(a instanceof cc.ParticleSystem,"cc.ParticleBatchNode only supports cc.QuadParticleSystems as children"),cc.Assert(-1a)return c;return b},_getCurrentIndex:function(a,b){for(var c=!1,d=!1,e=0,f=0,g=0,h=this._children.length,j=0;jb&&!d&&(e=j,d= +!0,c&&d))break;if(a==k&&(f=j,c=!0,d||(g=-1),c&&d))break}d||(e=h);return{newIndex:e+g,oldIndex:f}},_addChildHelper:function(a,b,c){cc.Assert(null!=a,"Argument must be non-nil");cc.Assert(null==a.getParent(),"child already added. It can't be added again");this._children||(this._children=[]);var d=this._searchNewPositionInChildrenForZ(b);this._children=cc.ArrayAppendObjectToIndex(this._children,a,d);a.setTag(c);a._setZOrder(b);a.setParent(this);this._isRunning&&(a.onEnter(),a.onEnterTransitionDidFinish()); +return d},_updateBlendFunc:function(){this._textureAtlas.getTexture().hasPremultipliedAlpha()||(this._blendFunc.src=gl.SRC_ALPHA,this._blendFunc.dst=gl.ONE_MINUS_SRC_ALPHA)},_getTextureAtlas:function(){},_setTextureAtlas:function(){}});cc.ParticleBatchNode.createWithTexture=function(a,b){var c=new cc.ParticleBatchNode;return c&&c.initWithTexture(a,b)?c:null};cc.ParticleBatchNode.create=function(a,b){var c=new cc.ParticleBatchNode;return c&&c.initWithFile(a,b)?c:null};cc.ParticleSystemQuad=cc.ParticleSystem.extend({_quads:null,_indices:null,_VAOname:0,_buffersVBO:[],_pointRect:null,ctor:function(){this._super();this._buffersVBO=[0,0];this._quads=[];this._indices=[];this._pointRect=cc.RectZero()},setupIndices:function(){for(var a=0;ab.getPriority()};cc.TouchHandlerHelperData=function(a){this.type=a}; +cc.TouchDispatcher=cc.Class.extend({_targetedHandlers:null,_standardHandlers:null,_locked:!1,_toAdd:!1,_toRemove:!1,_handlersToAdd:null,_handlersToRemove:null,_toQuit:!1,_dispatchEvents:!1,_handlerHelperData:[new cc.TouchHandlerHelperData(cc.TOUCH_BEGAN),new cc.TouchHandlerHelperData(cc.TOUCH_MOVED),new cc.TouchHandlerHelperData(cc.TOUCH_ENDED),new cc.TouchHandlerHelperData(cc.TOUCH_CANCELLED)],init:function(){this._dispatchEvents=!0;this._targetedHandlers=[];this._standardHandlers=[];this._handlersToAdd= +[];this._handlersToRemove=[];this._locked=this._toQuit=this._toAdd=this._toRemove=!1;cc.TouchDispatcher.registerHtmlElementEvent(cc.canvas);return!0},isDispatchEvents:function(){return this._dispatchEvents},setDispatchEvents:function(a){this._dispatchEvents=a},addStandardDelegate:function(a,b){var c=cc.StandardTouchHandler.handlerWithDelegate(a,b);this._locked?-1!=this._handlersToRemove.indexOf(a)?cc.ArrayRemoveObject(this._handlersToRemove,a):(this._handlersToAdd.push(c),this._toAdd=!0):this._standardHandlers= +this.forceAddHandler(c,this._standardHandlers)},addTargetedDelegate:function(a,b,c){b=cc.TargetedTouchHandler.handlerWithDelegate(a,b,c);this._locked?-1!=this._handlersToRemove.indexOf(a)?cc.ArrayRemoveObject(this._handlersToRemove,a):(this._handlersToAdd.push(b),this._toAdd=!0):this._targetedHandlers=this.forceAddHandler(b,this._targetedHandlers)},forceAddHandler:function(a,b){for(var c=0,d=0;dc,"TouchDispatcher.touches()");this._locked=!0;var d=this._targetedHandlers.length,e=this._standardHandlers.length,f=d&&e,g=f?a.slice(): +a,h=this._handlerHelperData[c];if(0=b)&&this.impl._delegateWithIme&&this.impl._delegateWithIme.insertText(a,b)},dispatchDeleteBackward:function(){this.impl&&this.impl._delegateWithIme&&this.impl._delegateWithIme.deleteBackward()},getContentText:function(){if(this.impl&&this.impl._delegateWithIme){var a=this.impl._delegateWithIme.getContentText();return a?a:""}return""},dispatchKeyboardWillShow:function(a){if(this.impl)for(var b= +0;ba?a==cc.KEY.backspace?this.dispatchDeleteBackward():a==cc.KEY.enter&&this.dispatchInsertText("\n",1):255>a&&this.dispatchInsertText(String.fromCharCode(a),1)}});cc.IMEDispatcher.Impl=cc.Class.extend({_delegateWithIme:null,_delegateList:null,ctor:function(){this._delegateList=[]},findDelegate:function(a){for(var b=0;b=a?(this._inputText="",this._charCount=0,this.setString(this._placeHolder,!0)):(a=this._inputText.substring(0,a-1),this.setString(a))},removeDelegate:function(){cc.IMEDispatcher.getInstance().removeDelegate(this)},insertText:function(a){var b=a,a=b.indexOf("\n");-1cc.DIRECTOR_FPS_INTERVAL&&(this._SPFLabel.setString(this._secondsPerFrame.toFixed(3)),this._frameRate=this._frames/this._accumDt,this._accumDt=this._frames=0,this._szFPS=""+this._frameRate.toFixed(1),this._FPSLabel.setString(this._szFPS),this._drawsLabel.setString((0|cc.g_NumberOfDraws).toString())),this._FPSLabel.visit(),this._SPFLabel.visit(), +this._drawsLabel.visit()):this._createStatsLabel());cc.g_NumberOfDraws=0},updateContentScaleFactor:function(){this._openGLView.canSetContentScaleFactor()?(this._openGLView.setContentScaleFactor(this._contentScaleFactor),this._isContentScaleSupported=!0):cc.log("cocos2d: setContentScaleFactor:'is not supported on this device")},isSendCleanupToScene:function(){return this._sendCleanupToScene},getRunningScene:function(){return this._runningScene},getAnimationInterval:function(){return this._animationInterval}, +isDisplayStats:function(){return this._displayStats},setDisplayStats:function(a){this._displayStats=a},getSecondsPerFrame:function(){return this._secondsPerFrame},getOpenGLView:function(){return this._openGLView},isNextDeltaTimeZero:function(){return this._nextDeltaTimeZero},isPaused:function(){return this._paused},getTotalFrames:function(){return this._totalFrames},getProjection:function(){return this._projection},popToRootScene:function(){cc.Assert(null!=this._runningScene,"A running Scene is needed"); +var a=this._scenesStack.length;if(1==a)this._scenesStack.pop(),this.end();else{for(;1"},setDirty:function(a){this._dirty=a},getDirty:function(){return this._dirty},restore:function(){this._eyeX=this._eyeY=0;this._eyeZ=cc.Camera.getZEye();this._upX=this._centerX=this._centerY=this._centerZ=0;this._upY=1; +this._upZ=0;this._dirty=!1},locate:function(){},setEyeXYZ:function(a,b,c){this._eyeX=a*cc.CONTENT_SCALE_FACTOR;this._eyeY=b*cc.CONTENT_SCALE_FACTOR;this._eyeZ=c*cc.CONTENT_SCALE_FACTOR;this._dirty=!0},setCenterXYZ:function(a,b,c){this._centerX=a*cc.CONTENT_SCALE_FACTOR;this._centerY=b*cc.CONTENT_SCALE_FACTOR;this._centerZ=c*cc.CONTENT_SCALE_FACTOR;this._dirty=!0},setUpXYZ:function(a,b,c){this._upX=a;this._upY=b;this._upZ=c;this._dirty=!0},getEyeXYZ:function(){},getCenterXYZ:function(){},getUpXYZ:function(){}, +_DISALLOW_COPY_AND_ASSIGN:function(){}});cc.Camera.getZEye=function(){return cc.FLT_EPSILON};cc.PRIORITY_SYSTEM=-2147483648;cc.PRIORITY_NON_SYSTEM=cc.PRIORITY_SYSTEM+1;cc.ArrayVerifyType=function(a,b){if(a&&0=this._interval){if(this._selector)if("string"==typeof this._selector)this._target[this._selector](this._elapsed);else this._selector.call(this._target,this._elapsed);this._elapsed=0}}else{this._elapsed+=a;if(this._useDelay){if(this._elapsed>=this._delay){if(this._target&&this._selector)if("string"==typeof this._selector)this._target[this._selector](this._elapsed);else this._selector.call(this._target, +this._elapsed);this._elapsed-=this._delay;this._timesExecuted+=1;this._useDelay=!1}}else if(this._elapsed>=this._interval){if(this._target&&this._selector)if("string"==typeof this._selector)this._target[this._selector](this._elapsed);else this._selector.call(this._target,this._elapsed);this._elapsed=0;this._timesExecuted+=1}this._timesExecuted>this._repeat&&cc.Director.getInstance().getScheduler().unscheduleSelector(this._selector,this._target)}}}); +cc.Timer.timerWithTarget=function(a,b,c){if(2>arguments)throw Error("timerWithTarget'argument can't is null");var d=new cc.Timer;2==arguments.length?d.initWithTarget(a,b,0,cc.REPEAT_FOREVER,0):d.initWithTarget(a,b,c,cc.REPEAT_FOREVER,0);return d};cc._sharedScheduler=null; +cc.Scheduler=cc.Class.extend({_timeScale:1,_updatesNegList:null,_updates0List:null,_updatesPosList:null,_hashForUpdates:null,_hashForSelectors:null,_currentTarget:null,_currentTargetSalvaged:!1,_updateHashLocked:!1,ctor:function(){this._timeScale=1;this._updatesNegList=[];this._updates0List=[];this._updatesPosList=[];this._hashForUpdates=[];this._hashForSelectors=[];this._currentTarget=null;this._updateHashLocked=this._currentTargetSalvaged=!1},_removeHashElement:function(a){a.Timer=null;a.target= +null;cc.ArrayRemoveObject(this._hashForSelectors,a)},_findElementFromArray:function(a,b){for(var c=0;cb?this._priorityIn(this._updatesNegList,a,b,c):this._priorityIn(this._updatesPosList,a,b,c)},unscheduleSelector:function(a,b){if(!(null==b||null==a)){var c=cc.HASH_FIND_INT(this._hashForSelectors,b);if(null!=c)for(var d=0;d=d&&c.timerIndex--;0==c.timers.length&&(this._currentTarget== +c?this._currentTargetSalvaged=!0:this._removeHashElement(c));break}}}},unscheduleUpdateForTarget:function(a){null!=a&&(a=cc.HASH_FIND_INT(this._hashForUpdates,a),null!=a&&(this._updateHashLocked?a.entry.markedForDeletion=!0:this._removeUpdateFromHash(a.entry)))},unscheduleAllSelectorsForTarget:function(a){if(null!=a){var b=cc.HASH_FIND_INT(this._hashForSelectors,a);b&&(!b.currentTimerSalvaged&&cc.ArrayContainsObject(b.timers,b.currentTimer)&&(b.currentTimerSalvaged=!0),b.timers.length=0,this._currentTarget== +b?this._currentTargetSalvaged=!0:this._removeHashElement(b));this.unscheduleUpdateForTarget(a)}},unscheduleAllSelectors:function(){this.unscheduleAllSelectorsWithMinPriority(cc.PRIORITY_SYSTEM)},unscheduleAllSelectorsWithMinPriority:function(a){var b;for(b=0;ba)for(b=0;b=a)for(b=0;b=a&&this.unscheduleUpdateForTarget(this._updatesPosList[b].target)},pauseAllTargets:function(){return this.pauseAllTargetsWithMinPriority(cc.PRIORITY_SYSTEM)},pauseAllTargetsWithMinPriority:function(a){var b=[],c,d;for(c=0;ca)for(c=0;c=a)for(c=0;ca.length)throw Error("Polygon's point must greater than 2"); +b=a[0];this._renderContext.beginPath();this._renderContext.moveTo(b.x*cc.CONTENT_SCALE_FACTOR(),-b.y*cc.CONTENT_SCALE_FACTOR());for(b=1;b=f&&(g=arguments[2]);k.initWithNormalSprite(a,b,g,h,j);return k}; +cc.MenuItemImage=cc.MenuItemSprite.extend({setNormalSpriteFrame:function(a){this.setNormalImage(cc.Sprite.createWithSpriteFrameName(a))},setSelectedSpriteFrame:function(a){this.setSelectedImage(cc.Sprite.createWithSpriteFrameName(a))},setDisabledSpriteFrame:function(a){this.setDisabledImage(cc.Sprite.createWithSpriteFrameName(a))},initWithNormalImage:function(a,b,c,d,e){var f=null,g=null,h=null;a&&(f=cc.Sprite.create(a));b&&(g=cc.Sprite.create(b));c&&(h=cc.Sprite.create(c));return this.initWithNormalSprite(f, +g,h,d,e)}});cc.MenuItemImage.create=function(a,b,c,d,e){if(0==arguments.length)return cc.MenuItemImage.create(null,null,null,null,null);if(4==arguments.length)return cc.MenuItemImage.create(a,b,null,c,d);var f=new cc.MenuItemImage;return f.initWithNormalImage(a,b,c,d,e)?f:null}; +cc.MenuItemToggle=cc.MenuItem.extend({RGBAProtocol:!0,_opacity:0,getOpacity:function(){return this._opacity},setOpacity:function(a){this._opacity=a;if(this._subItems&&0a.length)return!1;this._super(a[0],a[1]);if(2==a.length)return!1; +this._subItems=[];for(var b=2;b=h||isNaN(h)?e:h;++f;f>=g&&(c+=e+5,e=f=0,++d)}cc.Assert(!f,"");var j=cc.Director.getInstance().getWinSize(),k=g=e=d=0,l=0,c=c/2;if(this._children&&0=h||isNaN(h)?e:h;m.setPosition(cc.p(l-j.width/2,c-m.getContentSize().height/2));l+=k;++f;f>=g&&(c-=e+5,e=g=f=0,++d)}}, +alignItemsInRows:function(){for(var a=[],b=0;b=m||isNaN(m)?h:m,f=f+(l.getContentSize().height+5);++j;j>=k&&(c.push(h),d.push(f),e+=h+10,h=j=0,f=-5,++g)}cc.Assert(!j,"");f=cc.Director.getInstance().getWinSize();k=h=g=0;var e=-e/2,n=0; +if(this._children&&0=m||isNaN(m)?h:m,l.setPosition(cc.p(e+c[g]/2,n-f.height/2)),n-=l.getContentSize().height+10,++j,j>=k&&(e+=h+5,h=k=j=0,++g)},registerWithTouchDispatcher:function(){cc.Director.getInstance().getTouchDispatcher().addTargetedDelegate(this,cc.MENU_HANDLER_PRIORITY,!0)},onTouchBegan:function(a){if(this._state!=cc.MENU_STATE_WAITING||!this._isVisible||!this._enabled)return!1; +for(var b=this._parent;null!=b;b=b.getParent())if(!b.isVisible())return!1;return(this._selectedItem=this._itemForTouch(a))?(this._state=cc.MENU_STATE_TRACKING_TOUCH,this._selectedItem.selected(),!0):!1},onTouchEnded:function(){cc.Assert(this._state==cc.MENU_STATE_TRACKING_TOUCH,"[Menu onTouchEnded] -- invalid state");this._selectedItem&&(this._selectedItem.unselected(),this._selectedItem.activate());this._state=cc.MENU_STATE_WAITING},onTouchCancelled:function(){cc.Assert(this._state==cc.MENU_STATE_TRACKING_TOUCH, +"[Menu onTouchCancelled] -- invalid state");this._selectedItem&&this._selectedItem.unselected();this._state=cc.MENU_STATE_WAITING},onTouchMoved:function(a){cc.Assert(this._state==cc.MENU_STATE_TRACKING_TOUCH,"[Menu onTouchMoved] -- invalid state");a=this._itemForTouch(a);a!=this._selectedItem&&(this._selectedItem&&this._selectedItem.unselected(),(this._selectedItem=a)&&this._selectedItem.selected())},onExit:function(){this._state==cc.MENU_STATE_TRACKING_TOUCH&&(this._selectedItem.unselected(),this._state= +cc.MENU_STATE_WAITING,this._selectedItem=null);this._super()},setOpacityModifyRGB:function(){},isOpacityModifyRGB:function(){return!1},_itemForTouch:function(a){a=a.getLocation();if(this._children&&0>>0>=f.firstGid)return f}}cc.log("cocos2d: Warning: TMX Layer "+a.name+" has no tiles");return null}}); +cc.TMXTiledMap.create=function(a,b){var c=new cc.TMXTiledMap;return c.initWithTMXFile(a,b)?c:null};cc.TMXLayerAttribNone=1;cc.TMXLayerAttribBase64=2;cc.TMXLayerAttribGzip=4;cc.TMXLayerAttribZlib=8;cc.TMXPropertyNone=0;cc.TMXPropertyMap=1;cc.TMXPropertyLayer=2;cc.TMXPropertyObjectGroup=3;cc.TMXPropertyObject=4;cc.TMXPropertyTile=5;cc.TMXTileHorizontalFlag=2147483648;cc.TMXTileVerticalFlag=1073741824;cc.TMXTileDiagonalFlag=536870912;cc.FlipedAll=(cc.TMXTileHorizontalFlag|cc.TMXTileVerticalFlag|cc.TMXTileDiagonalFlag)>>>0;cc.FlippedMask=~cc.FlipedAll>>>0; +cc.TMXLayerInfo=cc.Class.extend({_properties:null,name:"",_layerSize:null,_tiles:[],visible:null,_opacity:null,ownTiles:!0,_minGID:1E5,_maxGID:0,offset:cc.PointZero(),ctor:function(){this._properties=[]},getProperties:function(){return this._properties},setProperties:function(a){this._properties.push(a)}}); +cc.TMXTilesetInfo=cc.Class.extend({name:"",firstGid:0,_tileSize:cc.SizeZero(),spacing:0,margin:0,sourceImage:"",imageSize:cc.SizeZero(),rectForGID:function(a){var b=cc.RectZero();b.size=this._tileSize;var a=a&cc.FlippedMask,a=a-parseInt(this.firstGid),c=parseInt((this.imageSize.width-2*this.margin+this.spacing)/(this._tileSize.width+this.spacing));b.origin.x=parseInt(a%c*(this._tileSize.width+this.spacing)+this.margin);b.origin.y=parseInt(parseInt(a/c)*(this._tileSize.height+this.spacing)+this.margin); +return b}}); +cc.TMXMapInfo=cc.SAXParser.extend({_orientation:null,_mapSize:cc.SizeZero(),_tileSize:cc.SizeZero(),_layers:null,_tileSets:null,_objectGroups:null,_parentElement:null,_parentGID:null,_layerAttribs:0,_storingCharacters:!1,_properties:[],_TMXFileName:null,_currentString:null,_tileProperties:null,_resources:null,ctor:function(){this._tileSets=[];this._tileProperties=[];this._properties=[]},getOrientation:function(){return this._orientation},setOrientation:function(a){this._orientation=a},getMapSize:function(){return this._mapSize}, +setMapSize:function(a){this._mapSize=a},getTileSize:function(){return this._tileSize},setTileSize:function(a){this._tileSize=a},getLayers:function(){return this._layers},setLayers:function(a){this._layers.push(a)},getTilesets:function(){return this._tileSets},setTilesets:function(a){this._tileSets.push(a)},getObjectGroups:function(){return this._objectGroups},setObjectGroups:function(a){this._objectGroups.push(a)},getParentElement:function(){return this._parentElement},setParentElement:function(a){this._parentElement= +a},getParentGID:function(){return this._parentGID},setParentGID:function(a){this._parentGID=a},getLayerAttribs:function(){return this._layerAttribs},setLayerAttribs:function(a){this._layerAttribs=a},getStoringCharacters:function(){return this._storingCharacters},setStoringCharacters:function(a){this._storingCharacters=a},getProperties:function(){return this._properties},setProperties:function(a){this._properties.push(a)},initWithTMXFile:function(a,b){this._internalInit(a,b);return this.parseXMLFile(this._TMXFileName)}, +parseXMLFile:function(a){var b=cc.SAXParser.getInstance().tmxParse(a).documentElement,c=b.getAttribute("version"),d=b.getAttribute("orientation");if("map"==b.nodeName){"1.0"!=c&&null!==c&&cc.log("cocos2d: TMXFormat: Unsupported TMX version:"+c);"orthogonal"==d?this.setOrientation(cc.TMXOrientationOrtho):"isometric"==d?this.setOrientation(cc.TMXOrientationIso):"hexagonal"==d?this.setOrientation(cc.TMXOrientationHex):null!==d&&cc.log("cocos2d: TMXFomat: Unsupported orientation:"+this.getOrientation()); +var e=cc.size(0,0);e.width=parseFloat(b.getAttribute("width"));e.height=parseFloat(b.getAttribute("height"));this.setMapSize(e);e=cc.size(0,0);e.width=parseFloat(b.getAttribute("tilewidth"));e.height=parseFloat(b.getAttribute("tileheight"));this.setTileSize(e);if(c=b.querySelectorAll("map > properties > property"))for(var f=0;f property")[0])g={},h=j.getAttribute("name"),e=j.getAttribute("value"),g[h]=e,this._tileProperties[this.getParentGID()]=g}if(a=b.getElementsByTagName("layer")){c=0;for(d= +a.length;c property"))for(f= +0;f properties > property"))for(f=0;f property");if(l)for(f=0;f>>0},tileFlagAt:function(a){cc.Assert(a.x>>0},setTileGID:function(a,b,c){cc.Assert(b.x=this._tileSet.firstGid),"TMXLayer: invalid gid:"+a);this._setNodeDirtyForCache();var d=this.tileFlagAt(b), +e=this.tileGIDAt(b);if(e!=a||d!=c)if(d=(a|c)>>>0,0==a)this.removeTileAt(b);else if(0==e)this._insertTileForGID(d,b);else{var e=b.x+b.y*this._layerSize.width,f=this.getChildByTag(e);f?(a=this._tileSet.rectForGID(a),a=cc.RECT_PIXELS_TO_POINTS(a),f.setTextureRect(a,!1,a.size),c&&this._setupTileSprite(f,b,d),this._tiles[e]=d):this._updateTileForGID(d,b)}},removeTileAt:function(a){cc.Assert(a.x=a&&d.setAtlasIndex(e-1)}}}}, +positionAt:function(a){var b=cc.PointZero();switch(this._layerOrientation){case cc.TMXOrientationOrtho:b=this._positionForOrthoAt(a);break;case cc.TMXOrientationIso:b=this._positionForIsoAt(a);break;case cc.TMXOrientationHex:b=this._positionForHexAt(a)}return b=cc.POINT_PIXELS_TO_POINTS(b)},propertyNamed:function(a){return this._properties[a]},setupTiles:function(){var a=this._textureAtlas.getTexture();this._tileSet.imageSize=cc.size(a.width,a.height);this._parseInternalProperties();this._setNodeDirtyForCache(); +for(a=0;a=this._tileSet.firstGid&&this._minGID>=this._tileSet.firstGid,"TMX: Only 1 tileset per layer is supported")},addChild:function(){cc.Assert(0,"addChild: is not supported on cc.TMXLayer. Instead use setTileGID:at:/tileAt:")},removeChild:function(a, +b){if(a){cc.Assert(cc.ArrayContainsObject(this._children,a),"Tile does not belong to TMXLayer");this._setNodeDirtyForCache();var c=cc.ArrayGetIndexOfObject(this._children,a);this._tiles[this._atlasIndexArray[c]]=0;cc.ArrayRemoveObjectAtIndex(this._atlasIndexArray,c);this._super(a,b)}},getLayerName:function(){return this._layerName.toString()},setLayerName:function(a){this._layerName=a},_positionForIsoAt:function(a){return cc.p(this._mapTileSize.width/2*(this._layerSize.width+a.x-a.y-1),this._mapTileSize.height/ +2*(2*this._layerSize.height-a.x-a.y-2))},_positionForOrthoAt:function(a){101==a.x&&console.log("before:",a.x,this._mapTileSize.width,this._layerSize.height,a.y,1,this._mapTileSize.height);var b=cc.p(a.x*this._mapTileSize.width,(this._layerSize.height-a.y-1)*this._mapTileSize.height);101==a.x&&console.log("after:",b);return b},_positionForHexAt:function(a){var b=0;1==a.x%2&&(b=-this._mapTileSize.height/2);return cc.p(3*a.x*this._mapTileSize.width/4,(this._layerSize.height-a.y-1)*this._mapTileSize.height+ +b)},_calculateLayerOffset:function(a){var b=cc.PointZero();switch(this._layerOrientation){case cc.TMXOrientationOrtho:b=cc.p(a.x*this._mapTileSize.width,-a.y*this._mapTileSize.height);break;case cc.TMXOrientationIso:b=cc.p(this._mapTileSize.width/2*(a.x-a.y),this._mapTileSize.height/2*(-a.x-a.y));break;case cc.TMXOrientationHex:b=cc.p(0,0),cc.log("cocos2d:offset for hexagonal map not implemented yet")}return b},_appendTileForGID:function(a,b){var c=this._tileSet.rectForGID(a),c=cc.RECT_PIXELS_TO_POINTS(c), +d=b.x+b.y*this._layerSize.width,c=this._reusedTileWithRect(c);this._setupTileSprite(c,b,a);var e=this._atlasIndexArray.length;this.addQuadFromSprite(c,e);this._atlasIndexArray=cc.ArrayAppendObjectToIndex(this._atlasIndexArray,d,e);return c},_insertTileForGID:function(a,b){var c=this._tileSet.rectForGID(a),c=cc.RECT_PIXELS_TO_POINTS(c),d=parseInt(b.x+b.y*this._layerSize.width),c=this._reusedTileWithRect(c);this._setupTileSprite(c,b,a);var e=this._atlasIndexForNewZ(d);this.addQuadFromSprite(c,e);this._atlasIndexArray= +cc.ArrayAppendObjectToIndex(this._atlasIndexArray,d,e);if(this._children)for(var f=0,g=this._children.length;f=e&&h.setAtlasIndex(j+1)}}this._tiles[d]=a;return c},_updateTileForGID:function(a,b){var c=this._tileSet.rectForGID(a),c=cc.rect(c.origin.x/this._contentScaleFactor,c.origin.y/this._contentScaleFactor,c.size.width/this._contentScaleFactor,c.size.height/this._contentScaleFactor),d=b.x+b.y*this._layerSize.width,c=this._reusedTileWithRect(c); +this._setupTileSprite(c,b,a);var e=this._atlasIndexForExistantZ(d);c.setAtlasIndex(e);c.setDirty(!0);c.updateTransform();this._tiles[d]=a;return c},_parseInternalProperties:function(){var a=this.propertyNamed("cc_vertexz");a&&("automatic"==a?(this._useAutomaticVertexZ=!0,a=this.propertyNamed("cc_alpha_func")):this._vertexZvalue=parseInt(a));if(a=this.propertyNamed("cc_alpha_func"))this._alphaFuncValue=parseInt(a)},_setupTileSprite:function(a,b,c){var d=b.x+b.y*this._layerSize.width;a.setPosition(this.positionAt(b)); +a.setAnchorPoint(cc.PointZero());a.setOpacity(this._opacity);a.setTag(d);a.setFlipX(!1);a.setFlipY(!1);(c&cc.TMXTileDiagonalFlag)>>>0?(a.setAnchorPoint(cc.p(0.5,0.5)),a.setPosition(cc.p(this.positionAt(b).x+a.getContentSize().height/2,this.positionAt(b).y+a.getContentSize().width/2)),b=(c&(cc.TMXTileHorizontalFlag|cc.TMXTileVerticalFlag)>>>0)>>>0,b==cc.TMXTileHorizontalFlag?a.setRotation(90):b==cc.TMXTileVerticalFlag?a.setRotation(270):(b==(cc.TMXTileVerticalFlag|cc.TMXTileHorizontalFlag)>>>0?a.setRotation(90): +a.setRotation(270),a.setFlipX(!0))):((c&cc.TMXTileHorizontalFlag)>>>0&&a.setFlipX(!0),(c&cc.TMXTileVerticalFlag)>>>0&&a.setFlipY(!0))},_reusedTileWithRect:function(a){this._reusedTile=new cc.Sprite;this._reusedTile.initWithTexture(this._textureAtlas.getTexture(),a,!1);this._reusedTile.setBatchNode(this);this._reusedTile.setParent(this);return this._reusedTile},_vertexZForPos:function(a){var b=0,c=0;if(this._useAutomaticVertexZ)switch(this._layerOrientation){case cc.TMXOrientationIso:c=this._layerSize.width+ +this._layerSize.height;b=-(c-(a.x+a.y));break;case cc.TMXOrientationOrtho:b=-(this._layerSize.height-a.y);break;case cc.TMXOrientationHex:cc.Assert(0,"TMX Hexa zOrder not supported");break;default:cc.Assert(0,"TMX invalid value")}else b=this._vertexZvalue;return b},_atlasIndexForExistantZ:function(a){var b;if(this._atlasIndexArray)for(var c=0;ca?0:a)},getEffectsVolume:function(){return this._effectsVolume},setEffectsVolume:function(a){this._effectsVolume= +1a?0:a;if(this._audioList)for(var b in this._audioList)if(a=this._audioList[b])a.volume=this._effectsVolume},playEffect:function(a,b){for(var c=this._getEffectList(a),d=0;d>3;this._checkSize(c);var c=Math.pow(2,b-1)-1,e=this._readBitsOnly(a+b,1,d),f=this._readBitsOnly(a,b,d),g=0, +h=2,j=0;do for(var k=this._readByteOnly(++j,d),l=a%8||8,m=1<>=1;)k&m&&(g+=1/h),h*=2;while(a-=l);this._currentByte+=d;return f==(c<<1)+1?g?NaN:e?-Infinity:Infinity:(1+-2*e)*(f||g?!f?Math.pow(2,-c+1)*g:Math.pow(2,f-c)*(1+g):0)},_readBitsOnly:function(a,b,c){var d=(a+b)%8,e=a%8,f=c-(a>>3)-1,a=c+(-(a+b)>>3),g=f-a,b=this._readByteOnly(f,c)>>e&(1<<(g?8-e:b))-1;for(g&&d&&(b+=(this._readByteOnly(a++,c)&(1<=b.length?0==a.lastIndexOf(b):!1};cc.CCBReader.concat=function(a,b){return a+b};var PROPERTY_CCBFILE="ccbFile";cc.CCBFileLoader=cc.NodeLoader.extend({_createCCNode:function(){return cc.Node.create()},onHandlePropTypeCCBFile:function(a,b,c,d,e){c==PROPERTY_CCBFILE?a.addChild(d):this._super(a,b,c,d,e)}});cc.CCBFileLoader.loader=function(){return new cc.CCBFileLoader};var PROPERTY_ENABLED="enabled",PROPERTY_SELECTED="selected",PROPERTY_CCCONTROL="ccControl"; +cc.ControlLoader=cc.NodeLoader.extend({_createCCNode:function(){},onHandlePropTypeBlockCCControl:function(a,b,c,d,e){c==PROPERTY_CCCONTROL?a.addTargetWithActionForControlEvents(d.target,d.selCCControlHandler,d.controlEvents):this._super(a,b,c,d,e)},onHandlePropTypeCheck:function(a,b,c,d,e){c==PROPERTY_ENABLED?a.setEnabled(d):c==PROPERTY_SELECTED?a.setSelected(d):this._super(a,b,c,d,e)}}); +var PROPERTY_ZOOMONTOUCHDOWN="zoomOnTouchDown",PROPERTY_TITLE_NORMAL="title|1",PROPERTY_TITLE_HIGHLIGHTED="title|2",PROPERTY_TITLE_DISABLED="title|4",PROPERTY_TITLECOLOR_NORMAL="titleColor|1",PROPERTY_TITLECOLOR_HIGHLIGHTED="titleColor|2",PROPERTY_TITLECOLOR_DISABLED="titleColor|4",PROPERTY_TITLETTF_NORMAL="titleTTF|1",PROPERTY_TITLETTF_HIGHLIGHTED="titleTTF|2",PROPERTY_TITLETTF_DISABLED="titleTTF|4",PROPERTY_TITLETTFSIZE_NORMAL="titleTTFSize|1",PROPERTY_TITLETTFSIZE_HIGHLIGHTED="titleTTFSize|2", +PROPERTY_TITLETTFSIZE_DISABLED="titleTTFSize|4",PROPERTY_LABELANCHORPOINT="labelAnchorPoint",PROPERTY_PREFEREDSIZE="preferedSize",PROPERTY_BACKGROUNDSPRITEFRAME_NORMAL="backgroundSpriteFrame|1",PROPERTY_BACKGROUNDSPRITEFRAME_HIGHLIGHTED="backgroundSpriteFrame|2",PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED="backgroundSpriteFrame|4"; +cc.ControlButtonLoader=cc.ControlLoader.extend({_createCCNode:function(){return cc.ControlButton.create()},onHandlePropTypeCheck:function(a,b,c,d,e){c==PROPERTY_ZOOMONTOUCHDOWN?a.setZoomOnTouchDown(d):this._super(a,b,c,d,e)},onHandlePropTypeString:function(a,b,c,d,e){c==PROPERTY_TITLE_NORMAL?a.setTitleForState(d,cc.CONTROL_STATE_NORMAL):c==PROPERTY_TITLE_HIGHLIGHTED?a.setTitleForState(d,cc.CONTROL_STATE_HIGHLIGHTED):c==PROPERTY_TITLE_DISABLED?a.setTitleForState(d,cc.CONTROL_STATE_DISABLED):this._super(a, +b,c,d,e)},onHandlePropTypeFontTTF:function(a,b,c,d,e){c==PROPERTY_TITLETTF_NORMAL?a.setTitleTTFForState(d,cc.CONTROL_STATE_NORMAL):c==PROPERTY_TITLETTF_HIGHLIGHTED?a.setTitleTTFForState(d,cc.CONTROL_STATE_HIGHLIGHTED):c==PROPERTY_TITLETTF_DISABLED?a.setTitleTTFForState(d,cc.CONTROL_STATE_DISABLED):this._super(a,b,c,d,e)},onHandlePropTypeFloatScale:function(a,b,c,d,e){c==PROPERTY_TITLETTFSIZE_NORMAL?a.setTitleTTFSizeForState(d,cc.CONTROL_STATE_NORMAL):c==PROPERTY_TITLETTFSIZE_HIGHLIGHTED?a.setTitleTTFSizeForState(d, +cc.CONTROL_STATE_HIGHLIGHTED):c==PROPERTY_TITLETTFSIZE_DISABLED?a.setTitleTTFSizeForState(d,cc.CONTROL_STATE_DISABLED):this._super(a,b,c,d,e)},onHandlePropTypePoint:function(a,b,c,d,e){c==PROPERTY_LABELANCHORPOINT?a.setLabelAnchorPoint(d):this._super(a,b,c,d,e)},onHandlePropTypeSize:function(a,b,c,d,e){c==PROPERTY_PREFEREDSIZE?a.setPreferredSize(d):this._super(a,b,c,d,e)},onHandlePropTypeSpriteFrame:function(a,b,c,d,e){c==PROPERTY_BACKGROUNDSPRITEFRAME_NORMAL?null!=d&&a.setBackgroundSpriteFrameForState(d, +cc.CONTROL_STATE_NORMAL):c==PROPERTY_BACKGROUNDSPRITEFRAME_HIGHLIGHTED?null!=d&&a.setBackgroundSpriteFrameForState(d,cc.CONTROL_STATE_HIGHLIGHTED):c==PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED?null!=d&&a.setBackgroundSpriteFrameForState(d,cc.CONTROL_STATE_DISABLED):this._super(a,b,c,d,e)},onHandlePropTypeColor3:function(a,b,c,d,e){c==PROPERTY_TITLECOLOR_NORMAL?a.setTitleColorForState(d,cc.CONTROL_STATE_NORMAL):c==PROPERTY_TITLECOLOR_HIGHLIGHTED?a.setTitleColorForState(d,cc.CONTROL_STATE_HIGHLIGHTED): +c==PROPERTY_TITLECOLOR_DISABLED?a.setTitleColorForState(d,cc.CONTROL_STATE_DISABLED):this._super(a,b,c,d,e)}});cc.ControlButtonLoader.loader=function(){return new cc.ControlButtonLoader};var PROPERTY_CONTAINER="container",PROPERTY_DIRECTION="direction",PROPERTY_CLIPSTOBOUNDS="clipsToBounds",PROPERTY_BOUNCES="bounces",PROPERTY_SCALE="scale"; +cc.ScrollViewLoader=cc.NodeLoader.extend({_createCCNode:function(){return cc.ScrollView.create()},onHandlePropTypeCCBFile:function(a,b,c,d,e){c==PROPERTY_CONTAINER?a.setContainer(d):this._super(a,b,c,d,e)},onHandlePropTypeCheck:function(a,b,c,d,e){c==PROPERTY_CLIPSTOBOUNDS?a.setClippingToBounds(d):c==PROPERTY_BOUNCES?a.setBounceable(d):this._super(a,b,c,d,e)},onHandlePropTypeFloat:function(a,b,c,d,e){c==PROPERTY_SCALE?a.setScale(d):this._super(a,b,c,d,e)},onHandlePropTypeIntegerLabeled:function(a, +b,c,d,e){c==PROPERTY_DIRECTION?a.setDirection(d):this._super(a,b,c,d,e)}});cc.ScrollViewLoader.loader=function(){return new cc.ScrollViewLoader};var PROPERTY_CONTENTSIZE="contentSize",PROPERTY_SPRITEFRAME="spriteFrame",PROPERTY_COLOR="color",PROPERTY_OPACITY="opacity",PROPERTY_BLENDFUNC="blendFunc",PROPERTY_INSETLEFT="insetLeft",PROPERTY_INSETTOP="insetTop",PROPERTY_INSETRIGHT="insetRight",PROPERTY_INSETBOTTOM="insetBottom"; +cc.Scale9SpriteLoader=cc.NodeLoader.extend({_createCCNode:function(){return cc.Scale9Sprite.create()},onHandlePropTypeColor3:function(a,b,c,d,e){c==PROPERTY_COLOR?a.setColor(d):this._super(a,b,c,d,e)},onHandlePropTypeByte:function(a,b,c,d,e){c==PROPERTY_OPACITY?a.setOpacity(d):this._super(a,b,c,d,e)},onHandlePropTypeBlendFunc:function(a,b,c,d,e){c!=PROPERTY_BLENDFUNC&&this._super(a,b,c,d,e)},onHandlePropTypeSpriteFrame:function(a,b,c,d,e){c==PROPERTY_SPRITEFRAME?a.initWithSpriteFrame(d):this._super(a, +b,c,d,e)},onHandlePropTypeSize:function(a,b,c,d,e){c!=PROPERTY_CONTENTSIZE&&(c==PROPERTY_PREFEREDSIZE?a.setPreferredSize(d):this._super(a,b,c,d,e))},onHandlePropTypeFloat:function(a,b,c,d,e){c==PROPERTY_INSETLEFT?a.setInsetLeft(d):c==PROPERTY_INSETTOP?a.setInsetTop(d):c==PROPERTY_INSETRIGHT?a.setInsetRight(d):c==PROPERTY_INSETBOTTOM?a.setInsetBottom(d):this._super(a,b,c,d,e)}});cc.Scale9SpriteLoader.loader=function(){return new cc.Scale9SpriteLoader};var PROPERTY_FLIP="flip",PROPERTY_DISPLAYFRAME="displayFrame",PROPERTY_COLOR="color",PROPERTY_OPACITY="opacity",PROPERTY_BLENDFUNC="blendFunc"; +cc.SpriteLoader=cc.NodeLoader.extend({_createCCNode:function(){return new cc.Sprite},onHandlePropTypeColor3:function(a,b,c,d,e){c==PROPERTY_COLOR?a.setColor(d):this._super(a,b,c,d,e)},onHandlePropTypeByte:function(a,b,c,d,e){c==PROPERTY_OPACITY?a.setOpacity(d):this._super(a,b,c,d,e)},onHandlePropTypeBlendFunc:function(a,b,c,d,e){c==PROPERTY_BLENDFUNC?a.setBlendFunc(d):this._super(a,b,c,d,e)},onHandlePropTypeSpriteFrame:function(a,b,c,d,e){c==PROPERTY_DISPLAYFRAME?a.setDisplayFrame(d):this._super(a, +b,c,d,e)},onHandlePropTypeFlip:function(a,b,c,d,e){c==PROPERTY_FLIP?(a.setFlipX(d[0]),a.setFlipX(d[1])):this._super(a,b,c,d,e)}});cc.SpriteLoader.loader=function(){return new cc.SpriteLoader};var PROPERTY_TOUCH_ENABLED="isTouchEnabled",PROPERTY_ACCELEROMETER_ENABLED="isAccelerometerEnabled",PROPERTY_MOUSE_ENABLED="isMouseEnabled",PROPERTY_KEYBOARD_ENABLED="isKeyboardEnabled"; +cc.LayerLoader=cc.NodeLoader.extend({_createCCNode:function(){return cc.Layer.create()},onHandlePropTypeCheck:function(a,b,c,d,e){c==PROPERTY_TOUCH_ENABLED?a.setTouchEnabled(d):c==PROPERTY_ACCELEROMETER_ENABLED?a.setAccelerometerEnabled(d):c==PROPERTY_MOUSE_ENABLED?cc.log("The property '"+PROPERTY_MOUSE_ENABLED+"' is not supported!"):c==PROPERTY_KEYBOARD_ENABLED?cc.log("The property '"+PROPERTY_KEYBOARD_ENABLED+"' is not supported!"):this._super(a,b,c,d,e)}});cc.LayerLoader.loader=function(){return new cc.LayerLoader}; +cc.LayerColorLoader=cc.LayerLoader.extend({_createCCNode:function(){return cc.LayerColor.create()},onHandlePropTypeColor3:function(a,b,c,d,e){c==PROPERTY_COLOR?a.setColor(d):this._super(a,b,c,d,e)},onHandlePropTypeByte:function(a,b,c,d,e){c==PROPERTY_OPACITY?a.setOpacity(d):this._super(a,b,c,d,e)},onHandlePropTypeBlendFunc:function(a,b,c,d,e){c==PROPERTY_BLENDFUNC?a.setBlendFunc(d):this._super(a,b,c,d,e)}});cc.LayerColorLoader.loader=function(){return new cc.LayerColorLoader}; +var PROPERTY_STARTCOLOR="startColor",PROPERTY_ENDCOLOR="endColor",PROPERTY_STARTOPACITY="startOpacity",PROPERTY_ENDOPACITY="endOpacity",PROPERTY_VECTOR="vector"; +cc.LayerGradientLoader=cc.LayerLoader.extend({_createCCNode:function(){return cc.LayerGradient.create()},onHandlePropTypeColor3:function(a,b,c,d,e){c==PROPERTY_STARTCOLOR?a.setStartColor(d):c==PROPERTY_ENDCOLOR?a.setEndColor(d):this._super(a,b,c,d,e)},onHandlePropTypeByte:function(a,b,c,d,e){c==PROPERTY_STARTOPACITY?a.setStartOpacity(d):c==PROPERTY_ENDOPACITY?a.setEndOpacity(d):this._super(a,b,c,d,e)},onHandlePropTypePoint:function(a,b,c,d,e){c==PROPERTY_VECTOR?a.setVector(d):this._super(a,b,c,d, +e)},onHandlePropTypeBlendFunc:function(a,b,c,d,e){c==PROPERTY_BLENDFUNC?a.setBlendFunc(d):this._super(a,b,c,d,e)}});cc.LayerGradientLoader.loader=function(){return new cc.LayerGradientLoader};cc.MenuLoader=cc.LayerLoader.extend({_createCCNode:function(){return cc.Menu.create()}});cc.MenuLoader.loader=function(){return new cc.MenuLoader};var PROPERTY_BLOCK="block",PROPERTY_ISENABLED="isEnabled"; +cc.MenuItemLoader=cc.NodeLoader.extend({_createCCNode:function(){},onHandlePropTypeBlock:function(a,b,c,d,e){c==PROPERTY_BLOCK?null!=d&&a.setTarget(d.target,d.selMenuHander):this._super(a,b,c,d,e)},onHandlePropTypeCheck:function(a,b,c,d,e){c==PROPERTY_ISENABLED?a.setEnabled(d):this._super(a,b,c,d,e)}});var PROPERTY_NORMALDISPLAYFRAME="normalSpriteFrame",PROPERTY_SELECTEDDISPLAYFRAME="selectedSpriteFrame",PROPERTY_DISABLEDDISPLAYFRAME="disabledSpriteFrame"; +cc.MenuItemImageLoader=cc.MenuItemLoader.extend({_createCCNode:function(){return cc.MenuItemImage.create()},onHandlePropTypeSpriteFrame:function(a,b,c,d,e){c==PROPERTY_NORMALDISPLAYFRAME?null!=d&&a.setNormalSpriteFrame(d):c==PROPERTY_SELECTEDDISPLAYFRAME?null!=d&&a.setSelectedSpriteFrame(d):c==PROPERTY_DISABLEDDISPLAYFRAME?null!=d&&a.setDisabledSpriteFrame(d):this._super(a,b,c,d,e)}});cc.MenuItemImageLoader.loader=function(){return new cc.MenuItemImageLoader}; +var PROPERTY_FONTNAME="fontName",PROPERTY_FONTSIZE="fontSize",PROPERTY_HORIZONTALALIGNMENT="horizontalAlignment",PROPERTY_VERTICALALIGNMENT="verticalAlignment",PROPERTY_STRING="string",PROPERTY_DIMENSIONS="dimensions"; +cc.LabelTTFLoader=cc.NodeLoader.extend({_createCCNode:function(){return cc.LabelTTF.create()},onHandlePropTypeColor3:function(a,b,c,d,e){c==PROPERTY_COLOR?a.setColor(d):this._super(a,b,c,d,e)},onHandlePropTypeByte:function(a,b,c,d,e){c==PROPERTY_OPACITY?a.setOpacity(d):this._super(a,b,c,d,e)},onHandlePropTypeBlendFunc:function(a,b,c,d,e){c==PROPERTY_BLENDFUNC?a.setBlendFunc(d):this._super(pNode,pParent,c,d,e)},onHandlePropTypeFontTTF:function(a,b,c,d,e){c==PROPERTY_FONTNAME?a.setFontName(d):this._super(a, +b,c,d,e)},onHandlePropTypeText:function(a,b,c,d,e){c==PROPERTY_STRING?a.setString(d):this._super(a,b,c,d,e)},onHandlePropTypeFloatScale:function(a,b,c,d,e){c==PROPERTY_FONTSIZE?a.setFontSize(d):this._super(a,b,c,d,e)},onHandlePropTypeIntegerLabeled:function(a,b,c,d,e){c==PROPERTY_HORIZONTALALIGNMENT?a.setHorizontalAlignment(d):c==PROPERTY_VERTICALALIGNMENT?a.setVerticalAlignment(d):this._super(a,b,c,d,e)},onHandlePropTypeSize:function(a,b,c,d,e){c==PROPERTY_DIMENSIONS?a.setDimensions(d):this._super(a, +b,c,d,e)}});cc.LabelTTFLoader.loader=function(){return new cc.LabelTTFLoader};var PROPERTY_FNTFILE="fntFile"; +cc.LabelBMFontLoader=cc.NodeLoader.extend({_createCCNode:function(){return cc.LabelBMFont.create()},onHandlePropTypeColor3:function(a,b,c,d,e){c==PROPERTY_COLOR?a.setColor(d):this._super(a,b,c,d,e)},onHandlePropTypeByte:function(a,b,c,d,e){c==PROPERTY_OPACITY?a.setOpacity(d):this._super(a,b,c,d,e)},onHandlePropTypeBlendFunc:function(a,b,c,d,e){c==PROPERTY_BLENDFUNC?a.setBlendFunc(d):this._super(a,b,c,d,e)},onHandlePropTypeFntFile:function(a,b,c,d,e){c==PROPERTY_FNTFILE?a.setFntFile(d):this._super(a, +b,c,d,e)},onHandlePropTypeText:function(a,b,c,d,e){c==PROPERTY_STRING?a.setString(d):this._super(a,b,c,d,e)}});cc.LabelBMFontLoader.loader=function(){return new cc.LabelBMFontLoader}; +var PROPERTY_EMITERMODE="emitterMode",PROPERTY_POSVAR="posVar",PROPERTY_EMISSIONRATE="emissionRate",PROPERTY_DURATION="duration",PROPERTY_TOTALPARTICLES="totalParticles",PROPERTY_LIFE="life",PROPERTY_STARTSIZE="startSize",PROPERTY_ENDSIZE="endSize",PROPERTY_STARTSPIN="startSpin",PROPERTY_ENDSPIN="endSpin",PROPERTY_ANGLE="angle",PROPERTY_GRAVITY="gravity",PROPERTY_SPEED="speed",PROPERTY_TANGENTIALACCEL="tangentialAccel",PROPERTY_RADIALACCEL="radialAccel",PROPERTY_TEXTURE="texture",PROPERTY_STARTRADIUS= +"startRadius",PROPERTY_ENDRADIUS="endRadius",PROPERTY_ROTATEPERSECOND="rotatePerSecond"; +cc.ParticleSystemQuadLoader=cc.NodeLoader.extend({_createCCNode:function(){return cc.ParticleSystemQuad.create()},onHandlePropTypeIntegerLabeled:function(a,b,c,d,e){c==PROPERTY_EMITERMODE?a.setEmitterMode(d):this._super(a,b,c,d,e)},onHandlePropTypePoint:function(a,b,c,d,e){c==PROPERTY_POSVAR?a.setPosVar(d):c==PROPERTY_GRAVITY?a.setGravity(d):this._super(a,b,c,d,e)},onHandlePropTypeFloat:function(a,b,c,d,e){c==PROPERTY_EMISSIONRATE?a.setEmissionRate(d):c==PROPERTY_DURATION?a.setDuration(d):this._super(a, +b,c,d,e)},onHandlePropTypeInteger:function(a,b,c,d,e){c==PROPERTY_TOTALPARTICLES?a.setTotalParticles(d):this._super(a,b,c,d,e)},onHandlePropTypeFloatVar:function(a,b,c,d,e){c==PROPERTY_LIFE?(a.setLife(d[0]),a.setLifeVar(d[1])):c==PROPERTY_STARTSIZE?(a.setStartSize(d[0]),a.setStartSizeVar(d[1])):c==PROPERTY_ENDSIZE?(a.setEndSize(d[0]),a.setEndSizeVar(d[1])):c==PROPERTY_STARTSPIN?(a.setStartSpin(d[0]),a.setStartSpinVar(d[1])):c==PROPERTY_ENDSPIN?(a.setEndSpin(d[0]),a.setEndSpinVar(d[1])):c==PROPERTY_ANGLE? +(a.setAngle(d[0]),a.setAngleVar(d[1])):c==PROPERTY_SPEED?(a.setSpeed(d[0]),a.setSpeedVar(d[1])):c==PROPERTY_TANGENTIALACCEL?(a.setTangentialAccel(d[0]),a.setTangentialAccelVar(d[1])):c==PROPERTY_RADIALACCEL?(a.setRadialAccel(d[0]),a.setRadialAccelVar(d[1])):c==PROPERTY_STARTRADIUS?(a.setStartRadius(d[0]),a.setStartRadiusVar(d[1])):c==PROPERTY_ENDRADIUS?(a.setEndRadius(d[0]),a.setEndRadiusVar(d[1])):c==PROPERTY_ROTATEPERSECOND?(a.setRotatePerSecond(d[0]),a.setRotatePerSecondVar(d[1])):this._super(a, +b,c,d,e)},onHandlePropTypeColor4FVar:function(a,b,c,d,e){c==PROPERTY_STARTCOLOR?(a.setStartColor(d[0]),a.setStartColorVar(d[1])):c==PROPERTY_ENDCOLOR?(a.setEndColor(d[0]),a.setEndColorVar(d[1])):this._super(a,b,c,d,e)},onHandlePropTypeBlendFunc:function(a,b,c,d,e){c==PROPERTY_BLENDFUNC?a.setBlendFunc(d):this._super(a,b,c,d,e)},onHandlePropTypeTexture:function(a,b,c,d,e){c==PROPERTY_TEXTURE?a.setTexture(d):this._super(a,b,c,d,e)}});cc.ParticleSystemQuadLoader.loader=function(){return new cc.ParticleSystemQuadLoader};cc.CONTROL_EVENT_TOTAL_NUMBER=9;cc.CONTROL_EVENT_TOUCH_DOWN=1;cc.CONTROL_EVENT_TOUCH_DRAGINSIDE=2;cc.CONTROL_EVENT_TOUCH_DRAGOUTSIDE=4;cc.CONTROL_EVENT_TOUCH_DRAGENTER=8;cc.CONTROL_EVENT_TOUCH_DRAGEXIT=16;cc.CONTROL_EVENT_TOUCH_UPINSIDE=32;cc.CONTROL_EVENT_TOUCH_UPOUTSIDE=64;cc.CONTROL_EVENT_TOUCH_CANCEL=128;cc.CONTROL_EVENT_VALUECHANGED=256;cc.CONTROL_STATE_NORMAL=1;cc.CONTROL_STATE_HIGHLIGHTED=2;cc.CONTROL_STATE_DISABLED=4;cc.CONTROL_STATE_SELECTED=8;cc.CONTROL_STATE_INITIAL=8; +cc.Control=cc.Layer.extend({RGBAProtocol:!0,_opacity:0,_color:null,_isOpacityModifyRGB:!1,isOpacityModifyRGB:function(){return this._isOpacityModifyRGB},setOpacityModifyRGB:function(a){this._isOpacityModifyRGB=a;for(var b=this.getChildren(),c=0;c=b.width&&(b.width=a.width);0>=b.height&&(b.height=a.height);this._backgroundSprite.setContentSize(b)}a=cc.ControlUtils.CCRectUnion(this._titleLabel.getBoundingBox(),this._backgroundSprite.getBoundingBox());this.setContentSize(cc.SizeMake(a.size.width,a.size.height));this._titleLabel.setPosition(cc.p(this.getContentSize().width/ +2,this.getContentSize().height/2));this._backgroundSprite.setPosition(cc.p(this.getContentSize().width/2,this.getContentSize().height/2));this._titleLabel.setVisible(!0);this._backgroundSprite.setVisible(!0)},initWithLabelAndBackgroundSprite:function(a,b){if(this.init(!0)){cc.Assert(null!=a,"node must not be nil");cc.Assert(null!=a||a.RGBAProtocol||null!=b,"");this.setTouchEnabled(!0);this._pushed=!1;this._zoomOnTouchDown=!0;this._state=cc.CONTROL_STATE_INITIAL;this._currentTitle=null;this._zoomOnTouchDown= +this._adjustBackgroundImage=!0;this.ignoreAnchorPointForPosition(!1);this.setAnchorPoint(cc.p(0.5,0.5));this._titleLabel=a;this._backgroundSprite=b;this._titleDispatchTable={};this._titleColorDispatchTable={};this._titleLabelDispatchTable={};this._backgroundSpriteDispatchTable={};this.setColor(cc.c3(255,255,255));this.setOpacity(255);this.setOpacityModifyRGB(!0);var c=a.getString();this.setTitleForState(c,cc.CONTROL_STATE_NORMAL);this.setTitleColorForState(a.getColor(),cc.CONTROL_STATE_NORMAL);this.setTitleLabelForState(a, +cc.CONTROL_STATE_NORMAL);this.setBackgroundSpriteForState(b,cc.CONTROL_STATE_NORMAL);this._state=cc.CONTROL_STATE_NORMAL;this._marginH=24;this._marginV=12;this.m_labelAnchorPoint=new cc.Point(0.5,0.5);this.needsLayout();return!0}return!1},initWithTitleAndFontNameAndFontSize:function(a,b,c){a=cc.LabelTTF.create(a,b,c);return this.initWithLabelAndBackgroundSprite(a,cc.Scale9Sprite.create())},initWithBackgroundSprite:function(a){var b=cc.LabelTTF.create("","Arial",30);return this.initWithLabelAndBackgroundSprite(b, +a)},getAdjustBackgroundImage:function(){return this._adjustBackgroundImage},setAdjustBackgroundImage:function(a){this._adjustBackgroundImage=a;this.needsLayout()},getZoomOnTouchDown:function(){return this._zoomOnTouchDown},setZoomOnTouchDown:function(a){return this._zoomOnTouchDown=a},getPreferredSize:function(){return this._preferredSize},setPreferredSize:function(a){if(0==a.width&&0==a.height)this._adjustBackgroundImage=!0;else{this._adjustBackgroundImage=!1;for(var b in this._backgroundSpriteDispatchTable)this._backgroundSpriteDispatchTable[b].setPreferredSize(a); +this._preferredSize=a}this.needsLayout()},getLabelAnchorPoint:function(){return this._labelAnchorPoint},setLabelAnchorPoint:function(a){this.m_labelAnchorPoint=a;this._titleLabel.setAnchorPoint(a)},getCurrentTitle:function(){return this._currentTitle},getCurrentTitleColor:function(){return this._currentTitleColor},getOpacity:function(){return this._opacity},setOpacity:function(a){this._opacity=a;for(var b=this.getChildren(),c=0;ca.g?a.r:a.g;d=d>a.b?d:a.b;b.v=d;c=d-c;if(0=d?(a.g-a.b)/c:a.g>=d?2+(a.b-a.r)/c:4+(a.r-a.g)/c;b.h*=60;0>b.h&&(b.h+=360);return b}; +cc.ControlUtils.RGBfromHSV=function(a){var b,c,d,e,f=new cc.RGBA;f.a=1;if(0>=a.s){if(!a.h)return f.r=a.v,f.g=a.v,f.b=a.v,f;f.r=0;f.g=0;f.b=0;return f}b=a.h;360<=b&&(b=0);b/=60;e=0|b;d=b-e;b=a.v*(1-a.s);c=a.v*(1-a.s*d);d=a.v*(1-a.s*(1-d));switch(e){case 0:f.r=a.v;f.g=d;f.b=b;break;case 1:f.r=c;f.g=a.v;f.b=b;break;case 2:f.r=b;f.g=a.v;f.b=d;break;case 3:f.r=b;f.g=c;f.b=a.v;break;case 4:f.r=d;f.g=b;f.b=a.v;break;default:f.r=a.v,f.g=b,f.b=c}return f}; +cc.ControlUtils.CCRectUnion=function(a,b){return cc.Rect.CCRectUnion(a,b)};cc.Invocation=cc.Class.extend({_action:null,_target:null,_controlEvent:null,ctor:function(a,b,c){this._target=a;this._action=b;this._controlEvent=c},getAction:function(){return this._action},getTarget:function(){return this._target},getControlEvent:function(){return this._controlEvent},invoke:function(a){if(this._target&&this._action)if("string"==typeof this._action)this._target[this._action](a,this._controlEvent);else this._action.call(this._target,a,this._controlEvent)}});cc.POSITIONS_CENTRE=0;cc.POSITIONS_TOP=1;cc.POSITIONS_LEFT=2;cc.POSITIONS_RIGHT=3;cc.POSITIONS_BOTTOM=4;cc.POSITIONS_TOPRIGHT=5;cc.POSITIONS_TOPLEFT=6;cc.POSITIONS_BOTTOMRIGHT=7;cc.POSITIONS_BOTTOMLEFT=8; +cc.Scale9Sprite=cc.Node.extend({RGBAProtocol:!0,_spriteRect:null,_capInsetsInternal:null,_positionsAreDirty:!1,_scale9Image:null,_topLeft:null,_top:null,_topRight:null,_left:null,_centre:null,_right:null,_bottomLeft:null,_bottom:null,_bottomRight:null,_colorUnmodified:null,_isOpacityModifyRGB:!1,_originalSize:null,_preferredSize:null,_opacity:0,_color:null,_capInsets:null,_insetLeft:0,_insetTop:0,_insetRight:0,_insetBottom:0,_updateCapInset:function(){var a;a=0==this._insetLeft&&0==this._insetTop&& +0==this._insetRight&&0==this._insetBottom?cc.RectZero():cc.RectMake(this._insetLeft,this._insetTop,this._spriteRect.size.width-this._insetLeft-this._insetRight,this._spriteRect.size.height-this._insetTop-this._insetBottom);this.setCapInsets(a)},_updatePositions:function(){var a=this._contentSize,b=a.width-this._topLeft.getContentSize().width-this._topRight.getContentSize().width,a=a.height-this._topLeft.getContentSize().height-this._bottomRight.getContentSize().height,b=b/this._centre.getContentSize().width, +a=a/this._centre.getContentSize().height;this._centre.setScaleX(b);this._centre.setScaleY(a);var c=this._centre.getContentSize().width*b,d=this._centre.getContentSize().height*a,e=this._bottomLeft.getContentSize().width,f=this._bottomLeft.getContentSize().height;this._bottomLeft.setAnchorPoint(cc.p(0,0));this._bottomRight.setAnchorPoint(cc.p(0,0));this._topLeft.setAnchorPoint(cc.p(0,0));this._topRight.setAnchorPoint(cc.p(0,0));this._left.setAnchorPoint(cc.p(0,0));this._right.setAnchorPoint(cc.p(0, +0));this._top.setAnchorPoint(cc.p(0,0));this._bottom.setAnchorPoint(cc.p(0,0));this._centre.setAnchorPoint(cc.p(0,0));this._bottomLeft.setPosition(cc.p(0,0));this._bottomRight.setPosition(cc.p(e+c,0));this._topLeft.setPosition(cc.p(0,f+d));this._topRight.setPosition(cc.p(e+c,f+d));this._left.setPosition(cc.p(0,f));this._left.setScaleY(a);this._right.setPosition(cc.p(e+c,f));this._right.setScaleY(a);this._bottom.setPosition(cc.p(e,0));this._bottom.setScaleX(b);this._top.setPosition(cc.p(e,f+d));this._top.setScaleX(b); +this._centre.setPosition(cc.p(e,f))},ctor:function(){this._spriteRect=cc.RectZero();this._capInsetsInternal=cc.RectZero();this._colorUnmodified=cc.white();this._originalSize=new cc.Size(0,0);this._preferredSize=new cc.Size(0,0);this._color=cc.white();this._capInsets=cc.RectZero()},getOriginalSize:function(){return this._originalSize},setOriginalSize:function(a){this._originalSize=a},getPreferredSize:function(){return this._preferredSize},setPreferredSize:function(a){this.setContentSize(a);this._preferredSize= +a},getOpacity:function(){return this._opacity},setOpacity:function(a){this._opacity=a},getColor:function(){return this._color},setColor:function(a){this._color=a;if((a=this._scale9Image.getChildren())&&0!=a.length)for(var b=0;b=this._maximumValue&&(this._maximumValue=this._minimumValue+1);this.setValue(this._value)},getMaximumValue:function(){return this._maximumValue},setMaximumValue:function(a){this._maximumAllowedValue=this._maximumValue=a;this._maximumValue<=this._minimumValue&&(this._minimumValue=this._maximumValue-1);this.setValue(this._value)},getMinimumAllowedValue:function(){return this._minimumAllowedValue},setMinimumAllowedValue:function(a){this._minimumAllowedValue=a}, +getMaximumAllowedValue:function(){return this._maximumAllowedValue},setMaximumAllowedValue:function(a){this._maximumAllowedValue=a},getSnappingInterval:function(){return this._snappingInterval},setSnappingInterval:function(a){this._snappingInterval=a},getThumbItem:function(){return this._thumbItem},getProgressSprite:function(){return this._progressSprite},getBackgroundSprite:function(){return this._backgroundSprite},initWithSprites:function(a,b,c){return this.init()?(this.ignoreAnchorPointForPosition(!1), +this.setTouchEnabled(!0),this._backgroundSprite=a,this._progressSprite=b,this._thumbItem=c,a=cc.ControlUtils.CCRectUnion(a.getBoundingBox(),c.getBoundingBox()),a=cc.SizeMake(a.size.width+2*cc.SLIDER_MARGIN_H,a.size.height+2*cc.SLIDER_MARGIN_V),this.setContentSize(a),this._backgroundSprite.setAnchorPoint(cc.p(0.5,0.5)),this._backgroundSprite.setPosition(cc.p(a.width/2,a.height/2)),this.addChild(this._backgroundSprite),this._progressSprite.setAnchorPoint(cc.p(0,0.5)),this._progressSprite.setPosition(cc.p(0+ +cc.SLIDER_MARGIN_H,a.height/2)),this.addChild(this._progressSprite),this._thumbItem.setPosition(cc.p(0+cc.SLIDER_MARGIN_H,a.height/2)),this.addChild(this._thumbItem),this._minimumValue=0,this._maximumValue=1,this._snappingInterval=-1,this.setValue(this._minimumValue),!0):!1},sliderBegan:function(a){this._thumbItem.selected();this.setValue(this.valueForLocation(a))},sliderMoved:function(a){this.setValue(this.valueForLocation(a))},sliderEnded:function(){this._thumbItem.isSelected()&&(this._thumbItem.unselected(), +this.setValue(this.valueForLocation(this._thumbItem.getPosition())))},getTouchLocationInControl:function(a){a=a.getLocation();a=this.convertToNodeSpace(a);0>a.x?a.x=0:a.x>this._backgroundSprite.getContentSize().width+cc.SLIDER_MARGIN_H&&(a.x=this._backgroundSprite.getContentSize().width+cc.SLIDER_MARGIN_H);return a},onTouchBegan:function(a){if(!this.isTouchInside(a))return!1;a=this.getTouchLocationInControl(a);this.sliderBegan(a);return!0},onTouchMoved:function(a){a=this.getTouchLocationInControl(a); +this.sliderMoved(a)},onTouchEnded:function(){this.sliderEnded(cc.PointZero())},valueForLocation:function(a){a=(a.x-cc.SLIDER_MARGIN_H)/this._backgroundSprite.getContentSize().width;return Math.max(Math.min(this._minimumValue+a*(this._maximumValue-this._minimumValue),this._maximumAllowedValue),this._minimumAllowedValue)}}); +cc.ControlSlider.create=function(a,b,c){if("string"==typeof a){var a=cc.Sprite.create(a),b=cc.Sprite.create(b),d=cc.Sprite.create(c),c=cc.Sprite.create(c);c.setColor(cc.gray());c=cc.MenuItemSprite.create(d,c)}d=new cc.ControlSlider;d.initWithSprites(a,b,c);return d};cc.ControlSwitch=cc.Control.extend({_switchSprite:null,_initialTouchXPosition:0,_moved:!1,_on:!1,ctor:function(){},initWithMaskSprite:function(a,b,c,d,e,f){return this.init()?(cc.Assert(a,"Mask must not be nil."),cc.Assert(b,"onSprite must not be nil."),cc.Assert(c,"offSprite must not be nil."),cc.Assert(d,"thumbSprite must not be nil."),this.setTouchEnabled(!0),this._on=!0,this._switchSprite=new cc.ControlSwitchSprite,this._switchSprite.initWithMaskSprite(a,b,c,d,e,f),this._switchSprite.setPosition(cc.p(this._switchSprite.getContentSize().width/ +2,this._switchSprite.getContentSize().height/2)),this.addChild(this._switchSprite),this.ignoreAnchorPointForPosition(!1),this.setAnchorPoint(cc.p(0.5,0.5)),this.setContentSize(this._switchSprite.getContentSize()),!0):!1},setOn:function(a){this._on=a;this._switchSprite.runAction(cc.ActionTween.create(0.2,"sliderXPosition",this._switchSprite.getSliderXPosition(),this._on?this._switchSprite.getOnPosition():this._switchSprite.getOffPosition()));this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED)}, +isOn:function(){return this._on},hasMoved:function(){return this._moved},setEnabled:function(a){this._enabled=a;this._switchSprite.setOpacity(a?255:128)},locationFromTouch:function(a){a=a.getLocation();return a=this.convertToNodeSpace(a)},onTouchBegan:function(a){if(!this.isTouchInside(a)||!this.isEnabled())return!1;this._moved=!1;this._initialTouchXPosition=this.locationFromTouch(a).x-this._switchSprite.getSliderXPosition();this._switchSprite.getThumbSprite().setColor(cc.gray());this._switchSprite.needsLayout(); +return!0},onTouchMoved:function(a){a=this.locationFromTouch(a);a=cc.p(a.x-this._initialTouchXPosition,0);this._moved=!0;this._switchSprite.setSliderXPosition(a.x)},onTouchEnded:function(a){a=this.locationFromTouch(a);this._switchSprite.getThumbSprite().setColor(cc.white());this.hasMoved()?this.setOn(!(a.x=this._onPosition&&(a=this._onPosition);this._sliderXPosition=a;this.needsLayout()},getSliderXPosition:function(){return this._sliderXPosition}, +onSideWidth:function(){return this._onSprite.getContentSize().width},offSideWidth:function(){return this._offSprite.getContentSize().height},updateTweenAction:function(a,b){cc.log("key = "+b+", value = "+a);this.setSliderXPosition(a)},setOnPosition:function(a){this._onPosition=a},getOnPosition:function(){return this._onPosition},setOffPosition:function(a){this._offPosition=a},getOffPosition:function(){return this._offPosition},setMaskTexture:function(a){this._maskTexture=a},getMaskTexture:function(){return this._maskTexture}, +setTextureLocation:function(a){this._textureLocation=a},getTextureLocation:function(){return this._textureLocation},setMaskLocation:function(a){this._maskLocation=a},getMaskLocation:function(){return this._maskLocation},setOnSprite:function(a){this._onSprite=a},getOnSprite:function(){return this._onSprite},setOffSprite:function(a){this._offSprite=a},getOffSprite:function(){return this._offSprite},setThumbSprite:function(a){this._thumbSprite=a},getThumbSprite:function(){return this._thumbSprite},setOnLabel:function(a){this._onLabel= +a},getOnLabel:function(){return this._onLabel},setOffLabel:function(a){this._offLabel=a},getOffLabel:function(){return this._offLabel}});cc.ControlColourPicker=cc.Control.extend({_colorValue:null,_hsv:null,_colourPicker:null,_huePicker:null,_background:null,hueSliderValueChanged:function(a){this._hsv.h=a.getHue();a=cc.ControlUtils.RGBfromHSV(this._hsv);this._colorValue=cc.c3(0|255*a.r,0|255*a.g,0|255*a.b);this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED);this._updateControlPicker()},colourSliderValueChanged:function(a){this._hsv.s=a.getSaturation();this._hsv.v=a.getBrightness();a=cc.ControlUtils.RGBfromHSV(this._hsv); +this._colorValue=cc.c3(0|255*a.r,0|255*a.g,0|255*a.b);this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED)},getColorValue:function(){return this._colorValue},setColorValue:function(a){this._colorValue=a;var b=new cc.RGBA;b.r=a.r/255;b.g=a.g/255;b.b=a.b/255;b.a=1;this._hsv=cc.ControlUtils.HSVfromRGB(b);this._updateHueAndControlPicker()},getBackground:function(){return this._background},init:function(){if(this._super()){this.setTouchEnabled(!0);cc.SpriteFrameCache.getInstance().addSpriteFrames("extensions/CCControlColourPickerSpriteSheet.plist"); +var a=cc.SpriteBatchNode.create("extensions/CCControlColourPickerSpriteSheet.png");this.addChild(a);var b=[GL_LINEAR_MIPMAP_LINEAR,GL_LINEAR,GL_REPEAT,GL_REPEAT];a.getTexture().setAliasTexParameters();a.getTexture().setTexParameters(b);a.getTexture().generateMipmap();this._hsv.h=0;this._hsv.s=0;this._hsv.v=0;this._background=cc.ControlUtils.addSpriteToTargetWithPosAndAnchor("menuColourPanelBackground.png",a,cc.PointZero,cc.p(0.5,0.5));b=cc.pSub(this._background.getPosition(),cc.p(this._background.getContentSize().width/ +2,this._background.getContentSize().height/2));this._huePicker=cc.ControlHuePicker.create(a,cc.p(b.x+8,b.y+8));this._colourPicker=cc.ControlSaturationBrightnessPicker.create(a,cc.p(b.x+28,b.y+28));this._huePicker.addTargetWithActionForControlEvents(this,this.hueSliderValueChanged,cc.CONTROL_EVENT_VALUECHANGED);this._colourPicker.addTargetWithActionForControlEvents(this,this.colourSliderValueChanged,cc.CONTROL_EVENT_VALUECHANGED);this._updateHueAndControlPicker();this.addChild(this._huePicker);this.addChild(this._colourPicker); +this.setContentSize(this._background.getContentSize());return!0}return!1},_updateControlPicker:function(){this._huePicker.setHue(this._hsv.h);this._colourPicker.updateWithHSV(this._hsv)},_updateHueAndControlPicker:function(){this._huePicker.setHue(this._hsv.h);this._colourPicker.updateWithHSV(this._hsv);this._colourPicker.updateDraggerWithHSV(this._hsv)},onTouchBegan:function(){return!1}});cc.ControlColourPicker.create=function(){var a=new cc.ControlColourPicker;a.init();return a};cc.ControlHuePicker=cc.Control.extend({_hue:0,_huePercentage:0,_background:null,_slider:null,_startPos:null,getHue:function(){return this._hue},setHue:function(a){m_hue=a;this.setHuePercentage(m_hue/360)},getHuePercentage:function(){return this._huePercentage},setHuePercentage:function(a){this._huePercentage=a;this._hue=360*this._huePercentage;var b=this._background.getBoundingBox(),c=this._startPos.x+0.5*b.size.width,a=this._startPos.y+0.5*b.size.height,b=0.5*b.size.width-15,d=cc.DEGREES_TO_RADIANS(360* +this._huePercentage-180),c=c+b*Math.cos(d),a=a+b*Math.sin(d);this._slider.setPosition(cc.p(c,a))},getBackground:function(){return this._background},getSlider:function(){return this._slider},getStartPos:function(){return this._startPos},initWithTargetAndPos:function(a,b){return this.init()?(this.setTouchEnabled(!0),this._background=cc.ControlUtils.addSpriteToTargetWithPosAndAnchor("huePickerBackground.png",a,b,cc.p(0,0)),this._slider=cc.ControlUtils.addSpriteToTargetWithPosAndAnchor("colourPicker.png", +a,b,cc.p(0.5,0.5)),this._slider.setPosition(cc.p(b.x,b.y+0.5*this._background.getBoundingBox().size.height)),this._startPos=b,this._huePercentage=this._hue=0,!0):!1},_updateSliderPosition:function(a){var b=this._background.getBoundingBox(),a=Math.atan2(a.y-(this._startPos.y+0.5*b.size.height),a.x-(this._startPos.x+0.5*b.size.width)),a=cc.RADIANS_TO_DEGREES(a)+180;this.setHue(a);this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED)},_checkSliderPosition:function(a){return cc.Rect.CCRectContainsPoint(this._background.getBoundingBox(), +a)?(this._updateSliderPosition(a),!0):!1},onTouchBegan:function(a){a=this.getTouchLocation(a);return this._checkSliderPosition(a)},onTouchMoved:function(a){a=this.getTouchLocation(a);this._updateSliderPosition(a);this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED)}});cc.ControlHuePicker.create=function(a,b){var c=new cc.ControlHuePicker;c.initWithTargetAndPos(a,b);return c};cc.ControlSaturationBrightnessPicker=cc.Control.extend({_saturation:0,_brightness:0,_background:null,_overlay:null,_shadow:null,_slider:null,_startPos:null,_boxPos:0,_boxSize:0,getSaturation:function(){return this._saturation},getBrightness:function(){return this._brightness},getBackground:function(){return this._background},getOverlay:function(){return this._brightness},getShadow:function(){return this._shadow},getSlider:function(){return this._slider},getStartPos:function(){return this._startPos}, +initWithTargetAndPos:function(a,b){return this.init()?(this.setTouchEnabled(!0),this._background=cc.ControlUtils.addSpriteToTargetWithPosAndAnchor("colourPickerBackground.png",a,b,cc.p(0,0)),this._overlay=cc.ControlUtils.addSpriteToTargetWithPosAndAnchor("colourPickerOverlay.png",a,b,cc.p(0,0)),this._shadow=cc.ControlUtils.addSpriteToTargetWithPosAndAnchor("colourPickerShadow.png",a,b,cc.p(0,0)),this._slider=cc.ControlUtils.addSpriteToTargetWithPosAndAnchor("colourPicker.png",a,b,cc.p(0.5,0.5)),this._startPos= +b,this._boxPos=35,this._boxSize=150,!0):!1},updateWithHSV:function(a){var b=new cc.HSV;b.s=1;b.h=a.h;b.v=1;a=cc.ControlUtils.RGBfromHSV(b);this._background.setColor(cc.c3(0|255*a.r,0|255*a.g,0|255*a.b))},updateDraggerWithHSV:function(a){a=cc.PointMake(this._startPos.x+this._boxPos+this._boxSize*(1-a.s),this._startPos.y+this._boxPos+this._boxSize*a.v);this._updateSliderPosition(a)},_updateSliderPosition:function(a){var b=this._startPos.x+0.5*this._background.getBoundingBox().size.width,c=this._startPos.y+ +0.5*this._background.getBoundingBox().size.height,d=a.x-b,e=a.y-c,f=Math.sqrt(d*d+e*e),d=Math.atan2(e,d),e=0.5*this._background.getBoundingBox().size.width;f>e&&(a.x=b+e*Math.cos(d),a.y=c+e*Math.sin(d));this._slider.setPosition(a);a.xthis._startPos.x+this._boxPos+this._boxSize-1&&(a.x=this._startPos.x+this._boxPos+this._boxSize-1);a.ythis._startPos.y+this._boxPos+ +this._boxSize&&(a.y=this._startPos.y+this._boxPos+this._boxSize);this._saturation=1-Math.abs((this._startPos.x+this._boxPos-a.x)/this._boxSize);this._brightness=Math.abs((this._startPos.y+this._boxPos-a.y)/this._boxSize)},_checkSliderPosition:function(a){var b=this._startPos.x+0.5*this._background.getBoundingBox().size.width,c=this._startPos.y+0.5*this._background.getBoundingBox().size.height,b=a.x-b,c=a.y-c;return Math.sqrt(b*b+c*c)<=0.5*this._background.getBoundingBox().size.width?(this._updateSliderPosition(a), +this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED),!0):!1},onTouchBegan:function(a){a=this.getTouchLocation(a);return this._checkSliderPosition(a)},onTouchMoved:function(a){a=this.getTouchLocation(a);this._updateSliderPosition(a);this.sendActionsForControlEvents(cc.CONTROL_EVENT_VALUECHANGED)}});cc.ControlSaturationBrightnessPicker.create=function(a,b){var c=new cc.ControlSaturationBrightnessPicker;c.initWithTargetAndPos(a,b);return c};cc.Spacer=cc.Layer.extend({});cc.Spacer.verticalSpacer=function(a){var b=new cc.Spacer;b.init();b.setContentSize(cc.SizeMake(0,a));return b};cc.Spacer.horizontalSpacer=function(a){var b=new cc.Spacer;b.init();b.setContentSize(cc.SizeMake(a,0));return b}; +cc.MenuPassive=cc.Layer.extend({RGBAProtocol:!0,_color:null,_opacity:0,ctor:function(){},getColor:function(){return this._color},setColor:function(a){this._color=a;if(this._children&&0=j||null==j?f:j),++g,g>=h&&(d+=f+5,f=g=0,++e));cc.Assert(!g,"");var k=cc.Director.getInstance().getWinSize(),l=h=f=e=0,m=0,d=d/2;if(this._children&&0=j||null==j?f:j),this._children[c].setPosition(cc.p(m-k.width/2,d-this._children[c].getContentSize().height/ +2)),m+=l,++g,g>=h&&(d-=f+5,f=h=g=0,++e))},alignItemsInRows:function(a){var b=[],c;for(c=1;c=m||null==m?j:m),g+=0|this._children[c].getContentSize().height+5,++k,k>=l&&(d.push(j),e.push(g),f+=j+10,j=k=0,g=-5,++h));cc.Assert(!k, +"");g=cc.Director.getInstance().getWinSize();j=h=0;l=null;var f=-f/2,n=0;if(this._children&&0=m||null==m?j:m),this._children[c].setPosition(cc.p(f+d[h]/2,n-g.height/2)),n-=this._children[c].getContentSize().height+10,++k,k>=l&&(f+=j+5,j=l=k=0,++h))},setOpacityModifyRGB:function(){},isOpacityModifyRGB:function(){return!1}}); +cc.MenuPassive.create=function(a){0==arguments.length&&(a=null);for(var b=[],c=1;c=c&&athis._dataSource.numberOfCellsInTableView(this)-1)){var b=this._cellWithIndex(a);b&&this._moveCellOutOfSight(b);b=this._dataSource.tableCellAtIndex(this,a);this._setIndexForCell(a,b);this._addCellIfNecessary(b)}},insertCellAtIndex:function(a){if(!(a==cc.INVALID_INDEX||a>this._dataSource.numberOfCellsInTableView(this)-1)){var b;if(b=this._cellsUsed.objectWithObjectID(a))for(var c=b=this._cellsUsed.indexOfSortedObject(b);cthis._dataSource.numberOfCellsInTableView(this)-1)){var b=this._cellWithIndex(a);if(b){var c=this._cellsUsed.indexOfSortedObject(b);this._moveCellOutOfSight(b);this._indices.removeObject(a);for(a=this._cellsUsed.count()-1;a>c;a--)b=this._cellsUsed.objectAtIndex(a), +this._setIndexForCell(b.getIdx()-1,b)}}},reloadData:function(){for(var a=0;ab;)if(this._moveCellOutOfSight(e), +0this._children[b]._zOrder)this._children[b].visit(a); +else break;this.draw(a);if(this._children)for(;b= this.smokeDistance) { + this.lastSmoke = this.addObject({ + name: "smoke", + x: birdPos.x, + y: birdPos.y, + scale: Math.random() >= 0.5 ? 0.8 : 0.6 + }); + } + } + }, + onTouchesBegan: function (touch, evt) { + this.menus.forEach(function (menu) { + menu.handleTouches(touch, evt); + }); + + var currPoint = touch[0].getLocation(), + vector = cc.pSub(this.birdStartPos, currPoint); + + if ((this.isDraggingSling = (cc.pLength(vector) < this.slingRadius.max)) && !this.birdSprite.body && !this.slingRubber3) { + this.slingRubber3 = this.addObject({ + name: "sling3", + x: currPoint.x, + y: currPoint.y, + scaleY: 1.5, + scaleX: 2, + anchor: cc.p(0, 0.5), + z: 1 + }); + } + }, + onTouchesMoved: function (touch, evt) { + this.menus.forEach(function (menu) { + menu.handleTouchesMoved(touch, evt); + }); + + if (!this.isDraggingSling || this.birdSprite.body) return; + + var currPoint = touch[0].getLocation(), + vector = cc.pSub(currPoint, this.birdStartPos), + radius = cc.pLength(vector), + angle = cc.pToAngle(vector); + + angle = angle < 0 ? (Math.PI * 2) + angle : angle; + radius = MathH.clamp(radius, this.slingRadius.min, this.slingRadius.max); + if (angle <= this.slingAngle.max && angle >= this.slingAngle.min) { + radius = this.slingRadius.min; + } + + this.birdSprite.setPosition(cc.pAdd(this.birdStartPos, cc.p(radius * Math.cos(angle), radius * Math.sin(angle)))); + + var updateRubber = function (rubber, to, lengthAddon, topRubber) { + var from = rubber.getPosition(), + rubberVec = cc.pSub(to, from), + rubberAng = cc.pToAngle(rubberVec), + rubberDeg = cc.RADIANS_TO_DEGREES(rubberAng), + length = cc.pLength(rubberVec) + (lengthAddon || 8); + + rubber.setRotation(-rubberDeg); + rubber.setScaleX(-(length / rubber.getContentSize() + .width)); + + if (topRubber) { + rubber.setScaleY(1.1 - ((0.7 / this.slingRadius.max) * length)); + this.slingRubber3.setRotation(-rubberDeg); + this.slingRubber3.setPosition(cc.pAdd(from, cc.p((length) * Math.cos(rubberAng), (length) * Math.sin(rubberAng)))); + } + }.bind(this); + + var rubberToPos = this.birdSprite.getPosition(); + updateRubber(this.slingRubber2, rubberToPos, 13, true); + updateRubber(this.slingRubber1, rubberToPos, 0); + this.slingRubber1.setScaleY(this.slingRubber2.getScaleY()); + }, + onTouchesEnded: function (touch, evt) { + this.menus.forEach(function (menu) { + menu.handleTouchesEnded(touch, evt); + }); + + if (!this.birdSprite.body && this.isDraggingSling) { + this.slingRubber1.setVisible(false); + this.slingRubber2.setVisible(false); + this.slingRubber3.setVisible(false); + + b2.enablePhysicsFor({ + type: "dynamic", + shape: "circle", + sprite: this.birdSprite, + density: 15, + restitution: 0.4, + userData: new BodyUserData(GameObjectRoll.Bird, 250) + }); + + var vector = cc.pSub(this.birdStartPos, this.birdSprite.getPosition()), + impulse = cc.pMult(vector, 12), + bPos = this.birdSprite.body.GetWorldCenter(); + + this.birdSprite.body.ApplyImpulse(impulse, bPos); + + this.isDraggingSling = false; + } + }, + onKeyUp: function (e) {}, + onKeyDown: function (e) {} +}); + + +//--------------------- Scene --------------------- + +var GameScene = cc.Scene.extend({ + onEnter: function () { + this._super(); + + var layer = new GameLayer(); + layer.init(); + + this.addChild(layer); + } +}); \ No newline at end of file diff --git a/angry-birds/js/main.js b/angry-birds/js/main.js new file mode 100644 index 000000000..8380b13bb --- /dev/null +++ b/angry-birds/js/main.js @@ -0,0 +1,31 @@ +var cocos2dApp = cc.Application.extend({ + config: document.querySelector('#cocos2d-html5')['c'], + ctor: function (scene) { + this._super(); + this.startScene = scene; + cc.COCOS2D_DEBUG = this.config['COCOS2D_DEBUG']; + cc.setup(this.config['tag']); + cc.Loader.getInstance() + .onloading = function () { + cc.LoaderScene.getInstance() + .draw(); + }; + cc.Loader.getInstance() + .onload = function () { + cc.AppController.shareAppController() + .didFinishLaunchingWithOptions(); + }; + + cc.Loader.getInstance() + .preload(g_ressources); + }, + applicationDidFinishLaunching: function () { + var director = cc.Director.getInstance(); + director.setDisplayStats(this.config['showFPS']); + director.setAnimationInterval(1.0 / this.config['frameRate']); + director.runWithScene(new this.startScene()); + + return true; + } +}); +var myApp = new cocos2dApp(GameScene); diff --git a/angry-birds/js/resources.js b/angry-birds/js/resources.js new file mode 100644 index 000000000..e925e6db3 --- /dev/null +++ b/angry-birds/js/resources.js @@ -0,0 +1,13 @@ +var g_ressources = (function () { + var retval = [], + imgs = ["bg", "platform", "bird", "enemy", "sling1", "sling2", "sling3", "ground", "wood1", "wood2", "smoke", "menu_refresh", "menu_back"]; + + for (var i = 0; i < imgs.length; i++) { + retval.push({ + type: "image", + src: 'sprites/' + imgs[i] + '.png' + }); + } + + return retval; +}()); \ No newline at end of file diff --git a/angry-birds/sprites/CURSORS_SHEET_1.png b/angry-birds/sprites/CURSORS_SHEET_1.png new file mode 100644 index 000000000..815c9cd45 Binary files /dev/null and b/angry-birds/sprites/CURSORS_SHEET_1.png differ diff --git a/angry-birds/sprites/bg.png b/angry-birds/sprites/bg.png new file mode 100644 index 000000000..b53909f00 Binary files /dev/null and b/angry-birds/sprites/bg.png differ diff --git a/angry-birds/sprites/bird.png b/angry-birds/sprites/bird.png new file mode 100644 index 000000000..1b9a6627f Binary files /dev/null and b/angry-birds/sprites/bird.png differ diff --git a/angry-birds/sprites/enemy.png b/angry-birds/sprites/enemy.png new file mode 100644 index 000000000..9c0c88040 Binary files /dev/null and b/angry-birds/sprites/enemy.png differ diff --git a/angry-birds/sprites/ground.png b/angry-birds/sprites/ground.png new file mode 100644 index 000000000..afe0ff813 Binary files /dev/null and b/angry-birds/sprites/ground.png differ diff --git a/angry-birds/sprites/menu_back.png b/angry-birds/sprites/menu_back.png new file mode 100644 index 000000000..91158e363 Binary files /dev/null and b/angry-birds/sprites/menu_back.png differ diff --git a/angry-birds/sprites/menu_refresh.png b/angry-birds/sprites/menu_refresh.png new file mode 100644 index 000000000..674697ddf Binary files /dev/null and b/angry-birds/sprites/menu_refresh.png differ diff --git a/angry-birds/sprites/platform.png b/angry-birds/sprites/platform.png new file mode 100644 index 000000000..6fd84c5ec Binary files /dev/null and b/angry-birds/sprites/platform.png differ diff --git a/angry-birds/sprites/sling1.png b/angry-birds/sprites/sling1.png new file mode 100644 index 000000000..54c168abb Binary files /dev/null and b/angry-birds/sprites/sling1.png differ diff --git a/angry-birds/sprites/sling2.png b/angry-birds/sprites/sling2.png new file mode 100644 index 000000000..70ade42be Binary files /dev/null and b/angry-birds/sprites/sling2.png differ diff --git a/angry-birds/sprites/sling3.png b/angry-birds/sprites/sling3.png new file mode 100644 index 000000000..6fe8d3bc3 Binary files /dev/null and b/angry-birds/sprites/sling3.png differ diff --git a/angry-birds/sprites/smoke.png b/angry-birds/sprites/smoke.png new file mode 100644 index 000000000..7177700f9 Binary files /dev/null and b/angry-birds/sprites/smoke.png differ diff --git a/angry-birds/sprites/wood1.png b/angry-birds/sprites/wood1.png new file mode 100644 index 000000000..2ce3bd13a Binary files /dev/null and b/angry-birds/sprites/wood1.png differ diff --git a/angry-birds/sprites/wood2.png b/angry-birds/sprites/wood2.png new file mode 100644 index 000000000..5a009a8fd Binary files /dev/null and b/angry-birds/sprites/wood2.png differ