Talking about Toony game, Game development, iOS and Users contributions.
Yesterday I blogged about Toony Flash game and I said it would be interesting to port the game to mobile devices.
Some hours later, Jason Ian Green from PodWork sent me the Corona SDK version of the prototype I made with AS3.
This is what you’ll get:
and this is main.lua
file, with the complete script:
-----------------------------------------------------------------------------------------
--
-- main.lua
--
-----------------------------------------------------------------------------------------
local toonyVector = {}
local toRemove = {}
local interface = display.newGroup()
local toonyTypes = {"square.png", "circle.png", "hexagon.png", "flower.png"}
local currentObj
local originX
local originY
local score = 0
local function onTouch(event)
if event.phase == "began" then
--print("began")
currentObj = event.target
originX = currentObj.x
originY = currentObj.y
end
if event.phase == "moved" then
--print("moved")
currentObj.x = event.x
currentObj.y = event.y
end
if event.phase == "ended" or event.phase == "cancelled" then
--print("ednded")
for n = 1, #toonyVector, 1 do
local diffx = currentObj.x - toonyVector[n].x
local diffy = currentObj.y - toonyVector[n].y
if currentObj.id == toonyVector[n].id then
if math.abs(diffx) < 20 and math.abs(diffy) < 20 then
toonyVector[n].alpha = 1.0
end
end
end
currentObj.x = originX
currentObj.y = originY
end
end
local function go(event)
for i = 1, #toonyVector, 1 do
toonyVector[i].y = toonyVector[i].y + 1
if toonyVector[i].y > 260 then
if toonyVector[i].alpha == 1.0 then
score = score + 1
print(score)
end
toonyVector[i]:removeSelf()
table.insert(toRemove,i)
end
end
for j = #toRemove, 1, -1 do
table.remove(toonyVector,j)
end
toRemove={}
end
local function newToony(event)
local rand = math.random(4)
local newToon = display.newImage( toonyTypes[rand] )
newToon.x = math.random(400) + 25
newToon.y = 25
newToon.id = rand
newToon.alpha = 0.5
table.insert(toonyVector,newToon)
end
local function main()
local tSquare = display.newImage( toonyTypes[1] )
tSquare.x=100
tSquare.y=295
tSquare.id = 1
tSquare:addEventListener( "touch", onTouch )
interface:insert(tSquare)
local tCircle = display.newImage( toonyTypes[2] )
tCircle.x=200;
tCircle.y=295;
tCircle.id = 2
tCircle:addEventListener( "touch", onTouch )
interface:insert(tCircle)
local tHexagon = display.newImage( toonyTypes[3] )
tHexagon.x=300;
tHexagon.y=295;
tHexagon.id = 3
tHexagon:addEventListener( "touch", onTouch )
interface:insert(tHexagon)
local tFlower = display.newImage( toonyTypes[4] )
tFlower.x=400;
tFlower.y=295;
tFlower.id = 4
tFlower:addEventListener( "touch", onTouch )
interface:insert(tFlower)
Runtime:addEventListener( "enterFrame", go )
timer.performWithDelay( 2000, newToony, 0 )
end
main()
You can also download the entire project to compile it on your own on Corona SDK.
If anyone wants to continue with the porting, I will be happy to host it on the blog.
Never miss an update! Subscribe, and I will bother you by email only when a new game or full source code comes out.