Skip to content

Instantly share code, notes, and snippets.

@chrisdugne
Created February 20, 2019 00:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisdugne/1bfd2a0451ca6914865145b17bfdc27e to your computer and use it in GitHub Desktop.
Save chrisdugne/1bfd2a0451ca6914865145b17bfdc27e to your computer and use it in GitHub Desktop.
corona-stutter.lua
local spaceship = display.newGroup()
App.hud:insert(spaceship)
spaceship.y = display.contentHeight - 100
spaceship.x = display.contentWidth * 0.5
local image = display.newImage(
spaceship,
'assets/images/game/spaceship.png',
0, 0
)
----------------------------------------------------
local getTimer = system.getTimer
local latestTime = getTimer()
local way = 1
local speed = 250
local function moveSpaceship()
local ms = getTimer()
local dt = ms - latestTime
latestTime = ms
local distance = speed * dt / 1000 * way
spaceship.y = spaceship.y - distance
if(spaceship.y < 100 or spaceship.y > display.contentHeight -100) then
way = way * -1
-- Runtime:removeEventListener('enterFrame', moveSpaceship)
end
end
Runtime:addEventListener('enterFrame', moveSpaceship)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment