Skip to main content

Tiny Tutorial

There are loads of really useful You Tube tutorials out there for the various cross platform frameworks.

In fact there are probably too many, making it hard to know where to start.
The Corona SDK site offers a good selection:
http://www.coronalabs.com/resources/tutorials/ 
and
http://www.coronalabs.com/resources/videos/ 



I followed the basic Newbies Corona SDK tutorial this evening, and had a simple "game" running in an hour or so.


 

main.lua
display.setStatusBar(display.HiddenStatusBar)
local physics = require "physics"
physics.start()
physics.setGravity(0,0)

local background =  display.newImage("background.jpg")

local green = display.newImage("green.png")
green.x = 100
green.y = 100
physics.addBody(green, "dynamic")

local red = display.newImage("red.png")
red.x = 1000
red.y = 560
physics.addBody(red, "static")

local red2 = display.newImage("red.png")
red2.x = 800
red2.y = 500
physics.addBody(red2, "static")

function touchScreen(event)
    if event.phase == "began" then
        --event.x returns the x pos of the event, likewise event.y
        print (event.x)
        transition.to(green, {time=500, x=event.x, y=event.y})
    end
end

--[[ if runtime is replaced with specific object then that is the thing responded to
-- touch event has 3 phases:
began – dispatched when the user first touches the object.
moved – dispatched whenever user moves their finger, as they are touching.
ended & cancelled – dispatched whenever user lifts their finger or touch is cancelled for whatever reason.
--]]

Runtime:addEventListener("touch", touchScreen)

function moveRed()
    
    transition.to(red, {time=2000, x = math.random(80,880), y = math.random(60, 580), onComplete = moveRed})
    transition.to(red2, {time=2000, x = math.random(80,880), y = math.random(60, 580), onComplete = moveRed})
       
end
-- put call to function below function
moveRed()

function onCollision(event)
        --print ("Collision")
        green:removeSelf()
end

Runtime:addEventListener("collision", onCollision)



Popular posts from this blog

live

Beta Beater

The Google Developer Console is really very very good.
It's logically set out, and makes it super easy to run a Beta test.
I'm on the tenth iteration of the final draft, and think I've got to a point where I can actually promote the app to Production.
The latest revision changed the icon set, and removed a load more cruft, slimming the app down to just 12.14Mb. I could strip out the iOS icons and lose a few more bytes but the original aim way back when I started on this project was to build a simple game that could be deployed cross platform, so I think I'll try and maintain just one codebase... as I really should submit this to the iTunes store too, to close the project.



Spine again - animating game assets

Laura Tallarday gave a neat demo of how to build an animation in Spine on the CoronaGeek Hangout, so I had a bash at chopping up an image and animating it.
The plan is to add some more sophisticated animations to the new game "Duck sized horse".. but as was discussed in the show adding a whole bunch of spine animated objects might hammer a mobile device... and as the aim is to have 100 tiny duck sized horses, I'd best choose another approach for them.

anyway here's a swaying viking...