HitTest trigger new scene

2019-09-05 17:50发布

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条回答
再贱就再见
2楼-- · 2019-09-05 18:22

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.

查看更多
登录 后发表回答