You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 13:52:33