问题
This is my code:
onClipEvent(enterFrame){
if(_root.char.hat.hitTest(this)){
_root.gotoAndStop(6);
_root.char._y +=50;
_root.grav = 20;
}
}
How to make the hitTest trigger new scene ?
回答1:
To go to another scene
, you can use gotoAndPlay() or gotoAndStop() :
gotoAndPlay([scene:String], frame:Object) : Void.
gotoAndStop([scene:String], frame:Object) : Void
So your code can be like this, for example :
onClipEvent(enterFrame)
{
if(_root.char.hat.hitTest(this)){
// ...
gotoAndPlay("Scene 2", 1);
}
}
Hope that can help.
来源:https://stackoverflow.com/questions/33737676/hittest-trigger-new-scene