我想在下面的视频中制作相机
//请先观看视频:) https://www.youtube.com/watch?v=nryuCql2k9A
我试试这个
// moveWorld is true when the game lunch
if(moveWorld){
moveWorld = false
rightHeroBorder = hero.position.x + (hero.frame.size.width * 2)
leftHeroBorder = hero.position.x - (hero.frame.size.width * 2)
}
// move world to the right
if(hero.position.x > rightHeroBorder){
let diff = hero.position.x - rightHeroBorder
rightHeroBorder = hero.position.x + 1
leftHeroBorder = hero.position.x - 1
self.world.position.x -= diff
}
// move world to the left
if(hero.position.x < leftHeroBorder){
let diff = leftHeroBorder - hero.position.x
leftHeroBorder = hero.position.x - 1
rightHeroBorder = hero.position.x + 1
self.world.position.x += diff
}
结果不是我想要的
这很难,但我不想让节点和世界居中。 希望有更多经验的人会帮助
我在询问x坐标系,但你也可以帮助y