Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----------------------------------------------------------------------------------------
- --
- -- main.lua
- --
- -----------------------------------------------------------------------------------------
- -- Your code here
- -- Sprites
- local sprite = "guy.png"
- -- Sleep function (REQUIRED)
- -- Character Load
- function loadChar()
- char = display.newImage( sprite )
- x = display.contentCenterX
- y = display.contentCenterY
- char.x = x
- char.y = y + 25
- char:toFront()
- end
- -- Nexus Load
- function loadNexus()
- nexus = display.newImage( "tmpNexus.png" )
- nexus.x = display.contentCenterX
- nexus.y = display.contentCenterY
- nexus:toFront()
- end
- -- Map Load
- function loadMap()
- local background = display.newImage( "back.png" )
- background:toBack()
- end
- -- Keys Load
- function loadKeys()
- local up = display.newImage( "up.png")
- local down = display.newImage( "down.png")
- local left = display.newImage( "left.png")
- local right = display.newImage( "right.png")
- down.x = 48
- down.y = 294
- left.x = 26
- left.y = 272
- right.x = 70
- right.y = 272
- up.x = 48
- up.y = 250
- end
- function moveTouch( event )
- print( "(".. event.x .. ",".. event.y ..")" )
- -- UP
- if event.y < 262 and event.y > 236 and event.x > 32 and event.x < 64 then
- print( "UP" )
- sprite = "guy.png"
- for i = 1,5 do
- char.y = char.y - 1
- end
- end
- -- LEFT
- if event.y > 256 and event.y < 288 and event.x > 10 and event.x < 42 then
- print( "LEFT" )
- sprite = "guyLR.png"
- for i = 1,5 do
- char.x = char.x - 1
- end
- end
- -- DOWN
- if event.y > 278 and event.y < 310 and event.x > 32 and event.x < 64 then
- print( "DOWN" )
- sprite = "guy.png"
- for i = 1,5 do
- char.y = char.y + 1
- end
- end
- -- RIGHT
- if event.y > 256 and event.y < 288 and event.x > 54 and event.x < 86 then
- print( "RIGHT" )
- sprite = "guyLR.png"
- for i = 1,5 do
- char.x = char.x + 1
- end
- end
- end
- loadMap()
- loadNexus()
- loadChar()
- loadKeys()
- Runtime:addEventListener( "touch", moveTouch )
Advertisement
Add Comment
Please, Sign In to add comment