因此,我有函数characterBooleanFunction
,该函数包含30多个if-else语句。当我运行Scout来检查性能时,它指向该函数,该函数也是由ENTER_FRAME事件运行的。侦察员向我显示gotoAndStop
语句的成本很高。我不确定每次我运行游戏时都会如何解决,这简直太糟糕了。用户滚动屏幕上的字符,当它们打到一个标记时,它将激活characterBooleanFunction
功能。有任何想法吗?这是代码:
private function characterBooleanFunction():void
{
if (scrollCharacters.mcRandom.hit.hitTestObject(storeScreen.mcMarker) )
{
scrollCharacters.mcRandom.gotoAndStop(2);
//booleans
bRandom = true;
}else
{
scrollCharacters.mcRandom.gotoAndStop(1);
bRandom = false;
}
if (scrollCharacters.mcChinese.hit.hitTestObject(storeScreen.mcMarker) )
{
scrollCharacters.mcChinese.gotoAndStop(2);
trace("HIT CHINESE");
//booleans
bChinese = true;
}else
{
scrollCharacters.mcChinese.gotoAndStop(1);
bChinese = false;
}
if (scrollCharacters.mcPizza.hit.hitTestObject(storeScreen.mcMarker) )
{
scrollCharacters.mcPizza.gotoAndStop(2);
trace("HIT PIZZA");
//booleans
bPizza = true;
}else
{
scrollCharacters.mcPizza.gotoAndStop(1);
bPizza = false;
}
if (scrollCharacters.mcBurger.hit.hitTestObject(storeScreen.mcMarker) )
{
scrollCharacters.mcBurger.gotoAndStop(2);
//booleans
bBurger = true;
}else
{
scrollCharacters.mcBurger.gotoAndStop(1);
bBurger = false;
}
...等等。
谢谢!