尝试在2个其他精灵碰撞时补间精灵的alpha补间
目前它没有播放补间,只是跳到一个
的alpha有没有办法让精灵补间到一个alpha并保持这种状态?
我觉得它不起作用,因为连续调用精灵功能?
function tick(){
checkCollision();
stage.update();
}
var checkCollision = function(){
if(gameState=="gameStarted"){
collision = ndgmr.checkPixelCollision(car,surfaceImg,0);
if(collision){
score++;
sprites("on");
}else{
sprites("off");
}
}
}
var sprites = function(toggleParam){
for(var i = 0; i < spriteArr.length; i++){
if(i == 2 || i == 3){
if(toggleParam=="on"){
createjs.Tween.get(spriteArr[i]).to({alpha:1}, 500);
}else{
createjs.Tween.get(spriteArr[i]).to({alpha:0}, 500);
}
}
}
}
答案 0 :(得分:0)
通过设置全局变量extraSpites
解决了这个问题extraSpites = false;
var sprites = function(toggleParam){
if(!extraSpites && toggleParam == "on"){
extraSpites = true;
createjs.Tween.get(spriteArray[2]).to({alpha:1}, 500);
createjs.Tween.get(spriteArray[3]).to({alpha:1}, 500);
return
}else if(extraSpites && toggleParam == "off"){
extraSpites = false;
createjs.Tween.get(spriteArray[2]).to({alpha:0}, 500);
createjs.Tween.get(spriteArray[3]).to({alpha:0}, 500);
return;
}
}