var QySprite=cc.Sprite.extend({ctor:function(e){this._super();var t=this._spriteFill=e.fill||"#ffffff",i=this._spriteSize=e.size;if("#"===t[0]){t=cc.hexToColor(t);this.setTextureRect(cc.rect(0,0,i.width,i.height));this.color=t}else this.initWithFile(t);this.fromJson(e)},fromJson:function(e){e.size&&this.setContentSize(e.size.width,e.size.height);e.anchorPoint&&this.setAnchorPoint(e.anchorPoint.x,e.anchorPoint.y);this._spriteSize=this.getContentSize();e.position&&this.setPosition(cc.p(e.position.x,qyengine.winSize.height-e.position.y));e.scale&&this.setScale(e.scale.x,e.scale.y);e.rotation&&this.setRotation(e.rotation);e.opacity&&this.setOpacity(255*e.opacity);e.keyframe&&this.setKeyFrame(e.keyframe)},setKeyFrame:function(e){if("multiImages"===e.type)this.createSequenceFrameAnimation(e.frames,e);else{this._keyframeDelay=e.delay;this._keyframeHFrameOffset=e.hFrameOffset;this._keyframeVFrameOffset=e.vFrameOffset;this._keyframeHPixelOffset=e.hPixelOffset;this._keyframeVPixelOffset=e.vPixelOffset;this._keyframeHSplit=e.hSplit;this._keyframeVSplit=e.vSplit;this._keyframeLoop=e.loop;this._keyframeTotal=e.total;this._keyframeXNum=e.xNum;this._currentFrameX=0;this._currentFrameY=0;this._loop=0;this.setTextureRect(cc.rect(this._spriteSize.width*this._currentFrameX,0,this._spriteSize.width,this._spriteSize.height));this.schedule(this.playKeyFrame.bind(this),e.delay)}},playKeyFrame:function(){this.setTextureRect(cc.rect(this._spriteSize.width*this._currentFrameX,0,this._spriteSize.width,this._spriteSize.height));this._currentFrameX+=1;if(this._currentFrameX==this._keyframeXNum){this._currentFrameX=0;if(this._keyframeLoop!==!0){this._loop+=1;this._loop===this._keyframeLoop&&this.unschedule(this.playKeyFrame)}}},createSequenceFrameAnimation:function(e,t){for(var i=new cc.Animation,s=0;s<e.length;s++)i.addSpriteFrameWithFile(e[s].url);i.setDelayPerUnit(.2);var r=cc.animate(i);this.runAction(t.loop===!0?r.repeatForever():r.repeat(t.loop))},touchListen:function(){this.touchListener||this.addTouchListener()},touchBegan:function(e){this.bindObj.dispatchEvent({type:"touchstart",mouseX:e.x-(qyengine.offsetLeft||0),mouseY:e.y-(qyengine.offsetTop||0)});return!0},addTouchListener:function(){var e=this;this.touchListener=cc.EventListener.create({event:cc.EventListener.TOUCH_ONE_BY_ONE,pad:!0,onTouchBegan:function(t,i){var s=t.getLocation(),r=i.getCurrentTarget();return cc.rectContainsPoint(r.getBoundingBox(),s)?e.touchBegan(s):!1}});cc.eventManager.addListener(this.touchListener,this)}});QySprite.prototype.setSpeed=function(e,t){this._speed={x:e,y:t};this.schedule(this.moveSpeed.bind(this),1/60);return this};QySprite.prototype.moveSpeed=function(){(0!=this._speed.x||0!=this._speed.y)&&this.runAction(cc.moveBy(1/60,cc.p(this._speed.x*(1/60),this._speed.y*(1/60))))};