fix(worldmap): use the new reference for key handling

Since gamecore 0.5.0, keys are available in Scene.sources[sourceid].keys 
instead of Scene.keys.
This commit is contained in:
Kazhnuz 2019-06-16 17:46:57 +02:00
parent 0b8fafb556
commit 7d3de10a97
2 changed files with 10 additions and 5 deletions

View File

@ -9,6 +9,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- **gamecore:** updated to 0.5.0
### Fixed
- **worldmap:** use gamecore 0.5.0-style key handling
## Imperium-Porcorum 0.0.1
- Initial pre-alpha released based on source status before starting port to gamecore 0.5.0

View File

@ -37,22 +37,23 @@ function WorldMap:registerDot(dot)
end
function WorldMap:update(dt)
if (self.keys["up"].isDown) and (self.cursor.canMove) then
local keys = self.sources[1].keys
if (keys["up"].isDown) and (self.cursor.canMove) then
self.cursor.y = math.max(0, self.cursor.y - 1)
self.cursor.canMove = false
end
if (self.keys["down"].isDown) and (self.cursor.canMove) then
if (keys["down"].isDown) and (self.cursor.canMove) then
self.cursor.y = math.min(12, self.cursor.y + 1)
self.cursor.canMove = false
end
if (self.keys["right"].isDown) and (self.cursor.canMove) then
if (keys["right"].isDown) and (self.cursor.canMove) then
self.cursor.x = math.min(27, self.cursor.x + 1)
self.cursor.canMove = false
end
if (self.keys["left"].isDown) and (self.cursor.canMove) then
if (keys["left"].isDown) and (self.cursor.canMove) then
self.cursor.x = math.max(0, self.cursor.x - 1)
self.cursor.canMove = false
end
@ -77,7 +78,7 @@ function WorldMap:update(dt)
self.cursor.canMove = true
end
if (self.keys["A"].isPressed) and (self.cursor.canMove) then
if (keys["A"].isPressed) and (self.cursor.canMove) then
if (self.cursor.dotAtPoint ~= nil) then
self.cursor.dotAtPoint:action()
end