search

Home  >  Q&A  >  body text

c++ - 2.5D Rpg 地图移动

2.5D Rpg 地图移动

当人物移动到地图屏幕中间时 那么 就不能上下左右移动(只播放人物动画) 和只改变地图坐标即可 当地图到边界一半时人物可以移动 ,但是 当人物离开边界时 此时不知道 因该用什么条件判断 把人物 禁止 移动。因为人物移动 是用的cocos2d-x 的MoveTo 没法判断 。。。

大家有没有什么好办法。。。谢谢了

巴扎黑巴扎黑2803 days ago612

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 13:29:00

    It is best not to use methods such as MoveTo to move characters in rpg. It is best to use setPosition to give your hero a speed speed(Vec2(speedX, speedY)), and then click to trigger movement in one direction. Note that you can keep the camera still and let the background map move. Each frame (in update) goes to pos.x += or -= speedX, pos.y += or -= speedY.

    As for the peripheral positions that can be moved but the middle positions that remain unchanged: you can set up a conditional judgment in the update to move the background in the center, otherwise the hero will be moved and the hero will not be allowed to move out.

    Hope the answer is useful to you.

    reply
    0
  • Cancelreply