example/plateformer: add a basic pause button

This commit is contained in:
Kazhnuz 2019-05-30 13:49:46 +02:00
parent af96232d53
commit 67cb930ae7
2 changed files with 12 additions and 2 deletions

View file

@ -24,6 +24,11 @@ function Player:update(dt)
self.xsp = 120 self.xsp = 120
end end
if self.keys["start"].isPressed then
self.world:switchActivity()
self.scene:flushKeys()
end
self:setDirection(self.xsp) self:setDirection(self.xsp)
Player.super.update(self, dt) Player.super.update(self, dt)

View file

@ -39,11 +39,16 @@ function Plateformer:new()
end end
function Plateformer:update(dt) function Plateformer:update(dt)
if (self.world.isActive == false) and self.sources[1].keys["start"].isPressed then
self.world:switchActivity()
end
end end
function Plateformer:draw() 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 end
return Plateformer return Plateformer