this.addChild(bg)
/*cc.spriteFrameCache.addSpriteFrames(res.animation_plist); //加载plist文件
var mExplodeFrames = [];
for (var i=1;i<17;i++)
{
var frame = cc.spriteFrameCache.getSpriteFrame("explosion_"+("00"+i).slice(-2)+".png");
mExplodeFrames.push(frame);
}
var anim = new cc.Animation(mExplodeFrames, 0.04);*/
/*cc.spriteFrameCache.addSpriteFrames(res.animation_plist);
var animFrames = [];
var str = "";
for (var i = 1; i < 35; i++) {
str = "explosion_" + (i < 10 ? ("0" + i) : i) + ".png";
animFrames.push(cc.spriteFrameCache.getSpriteFrame(str));
}
var animation = new cc.Animation(animFrames, 0.025);
cc.animationCache.addAnimation(animation, "Explosion");
var anim = cc.animationCache.getAnimation("Explosion")*/
var that = this
var listener = cc.EventListener.create({
event:cc.EventListener.TOUCH_ONE_BY_ONE,
swallowTouches:true,
onTouchBegan:function(touch, event){
var sp = new cc.Sprite()
sp.setPosition(touch.getLocation())
that.addChild(sp)
sp.runAction(cc.sequence(cc.animate(anim), cc.fadeOut(0.5))) //点击的位置播放动画
return true;
},
});
cc.eventManager.addListener(listener, this)
var BgSp = cc.Sprite.extend({
sp1:null,
sp2:null,
moveSpeed:10,
ctor:function(res){
this._super()
this.sp1 = new cc.Sprite(res)
this.sp2 = new cc.Sprite(res)
this.addChild(this.sp1)
this.addChild(this.sp2)
this.sp1.setAnchorPoint(0,0)
this.sp1.setPosition(0,0)
this.sp2.setAnchorPoint(0,0)
this.sp2.setPosition(0, this.sp2.height)
this.scheduleUpdate()
},
update:function(){
this.sp1.y-= this.moveSpeed
this.sp2.y-= this.moveSpeed
if(this.sp1.y< -this.sp1.height){
this.sp1.y = this.sp2.y+this.sp2.height
}
if(this.sp2.y< -this.sp2.height){
this.sp2.y = this.sp1.y+this.sp2.height
}
}
})