代码之家  ›  专栏  ›  技术社区  ›  stalwart1014

移相器从左向右移动延迟

  •  0
  • stalwart1014  · 技术社区  · 4 年前

    我想让绿色的壁架从右向左移动。下面的代码可以正常工作,并且正在朝着正确的方向移动,但是在触发重置功能之前有几秒钟的延迟。

    enter image description here

    const game = new Phaser.Game(800, 600, Phaser.AUTO, '', {
      preload: preload,
      create: create,
      update: update
    })
    
    function update(){
      moveLedge(ledge,-100)
    }
    
    function moveLedge(ledge,speed){
       ledge.body.velocity.x = speed
       if(ledge.body.x <= -(game.world.width)){
         resetLedge(ledge)
       }
     }
    
     function resetLedge(ledge){
       ledge.body.x = game.world.width
     }
    
    0 回复  |  直到 4 年前