From 67cb930ae763388c232956cb9d35bf823c07f97d Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Thu, 30 May 2019 13:49:46 +0200 Subject: [PATCH] example/plateformer: add a basic pause button --- examples/gameplay/plateform/actors/player.lua | 5 +++++ examples/gameplay/plateform/init.lua | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/examples/gameplay/plateform/actors/player.lua b/examples/gameplay/plateform/actors/player.lua index f519d12..0b6010d 100644 --- a/examples/gameplay/plateform/actors/player.lua +++ b/examples/gameplay/plateform/actors/player.lua @@ -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) diff --git a/examples/gameplay/plateform/init.lua b/examples/gameplay/plateform/init.lua index 4ab87cc..c72ccfa 100644 --- a/examples/gameplay/plateform/init.lua +++ b/examples/gameplay/plateform/init.lua @@ -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