2016-05-24 28 views
0

在我无止境的亚军游戏中,我试图在离开屏幕时移除一个障碍物,然后在屏幕右侧的一组共同创建一个新的障碍物。它适用于大部分。问题是,当我添加一个新的障碍时,它瞬间闪现为0,0(即场景的左下角......)。 HALP!在Marmalade Quick SDK(Lua)中,为什么我的精灵在0,0闪烁之前移动到正确的共同点?

function updateObstacle() 

    if (obstacle) then       
     if(obstacle.x < -100) then 

      (obstacle):removeFromParent() 
      obstacle = nil 
     end 
    end 

    if (obstacle) then 
     (obstacle):translate(blockSpeed * -1, 0) 
    end 
end 

function newObstacle() 
     if (gameState == gameStates.gameStarted) then 
     if not (obstacle) then 
      createObstacle() 
     end 
    end 
end 

回答