HitTest trigger new scene

[亡魂溺海] 提交于 2019-12-25 12:48:32

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!