Incisor中图形对象暂停运动后无法恢复的问题排查
图形对象运动恢复(resume)功能失效的问题排查与解决
我正在开发一个项目,需要设置图形对象运动并在特定时间间隔后暂停、恢复其运动,但遇到了resume功能失效的问题。运动在3秒后成功暂停,但6秒后的resume调用未生效,图形对象始终无法恢复运动。
简化后的代码如下:
class ProjectMain { init() { let graphic = new GraphicObject( nc.graphicAssets.WhiteBox, nc.mainScene, "Box" ); graphic.position.addMotion.y( -300, 300, 2 ); // create a PauseEvent nc.definePauseEvent("BoxPause"); // wait 3 seconds, then call "pause", passing BoxPause as the PauseEvent nc.waitThen( 3, nc, "pause", [nc.pauseEvents.BoxPause] ); // wait 6 seconds, then call "resume" nc.waitThen( 6, nc, "resume", nc.pauseEvents.BoxPause ); } }
问题出在resume调用的参数格式上。你调用pause时,把暂停事件放在了数组里传递([nc.pauseEvents.BoxPause]),但调用resume时直接传了事件对象,没有用数组包裹。
根据waitThen的参数规则,第四个参数如果是传递给目标方法的参数,需要以数组形式传入。修改resume的调用代码,把事件对象放在数组里:
// wait 6 seconds, then call "resume" nc.waitThen( 6, nc, "resume", [nc.pauseEvents.BoxPause] );
这样resume方法就能正确接收暂停事件参数,恢复图形对象的运动了。
内容的提问来源于stack exchange,提问作者Boston_CrazyToothStudio
相关产品推荐
相关产品推荐

