feat: make some camera elements world-dependant

This commit is contained in:
Kazhnuz 2019-12-28 14:17:58 +01:00
parent 9b16ae4429
commit 97b3bcf80f
4 changed files with 11 additions and 3 deletions

View file

@ -83,7 +83,7 @@ end
function Player:getViewCenter() function Player:getViewCenter()
local x, y = Player.super.getViewCenter(self) local x, y = Player.super.getViewCenter(self)
return x, y-16 return self.world:getViewCenter(x, y)
end end
function Player:draw() function Player:draw()

View file

@ -30,6 +30,10 @@ function ParentWorld:addInvisibleWalls()
self.obj.collisions["invisible"](self, -16, 0, 0, 16, h, 1000) self.obj.collisions["invisible"](self, -16, 0, 0, 16, h, 1000)
end end
function ParentWorld:getViewCenter(x, y)
return x, y-16
end
function ParentWorld:draw(dt) function ParentWorld:draw(dt)
self:drawBackgroundColor() self:drawBackgroundColor()
local camNumber = self.cameras:getViewNumber() local camNumber = self.cameras:getViewNumber()

View file

@ -10,6 +10,10 @@ function ShootWorld:new(scene, mapname)
self.mapname = mapname self.mapname = mapname
end end
function ShootWorld:getViewCenter(x, y)
return x+128, y-16
end
function ShootWorld:createMapController() function ShootWorld:createMapController()
self.customMap.Shoot(self, self.maptype, self.mapname) self.customMap.Shoot(self, self.maptype, self.mapname)
self.cameras:lockY(10) self.cameras:lockY(10)

View file

@ -35,9 +35,9 @@ function MovePlayer:new(playerNumber, cameraMode)
MovePlayer.super.new(self) MovePlayer.super.new(self)
self.assets:batchImport("scenes.test_scene.assets") self.assets:batchImport("scenes.test_scene.assets")
--ShootWorld(self, "coast") ShootWorld(self, "coast")
--BattleWorld(self, "ebeach") --BattleWorld(self, "ebeach")
TestWorld(self) --TestWorld(self)
self.world:setPlayerNumber(playerNumber) self.world:setPlayerNumber(playerNumber)
self.world.cameras:setMode(cameraMode) self.world.cameras:setMode(cameraMode)