example/plateformer: add a basic pause button
This commit is contained in:
parent
af96232d53
commit
67cb930ae7
2 changed files with 12 additions and 2 deletions
|
@ -24,6 +24,11 @@ function Player:update(dt)
|
|||
self.xsp = 120
|
||||
end
|
||||
|
||||
if self.keys["start"].isPressed then
|
||||
self.world:switchActivity()
|
||||
self.scene:flushKeys()
|
||||
end
|
||||
|
||||
self:setDirection(self.xsp)
|
||||
|
||||
Player.super.update(self, dt)
|
||||
|
|
|
@ -39,11 +39,16 @@ function Plateformer:new()
|
|||
end
|
||||
|
||||
function Plateformer:update(dt)
|
||||
|
||||
if (self.world.isActive == false) and self.sources[1].keys["start"].isPressed then
|
||||
self.world:switchActivity()
|
||||
end
|
||||
end
|
||||
|
||||
function Plateformer:draw()
|
||||
|
||||
if (self.world.isActive == false) then
|
||||
local w, h = core.screen:getDimensions()
|
||||
love.graphics.printf("PAUSE", 0, h/2 - 16, w, "center")
|
||||
end
|
||||
end
|
||||
|
||||
return Plateformer
|
||||
|
|
Loading…
Reference in a new issue