Toony Flash game prototype ported to iPhone using Corona SDK

Read all posts about "" game

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.

Get the most popular Phaser 3 book

Through 202 pages, 32 source code examples and an Android Studio project you will learn how to build cross platform HTML5 games and create a complete game along the way.

Get the book

214 GAME PROTOTYPES EXPLAINED WITH SOURCE CODE
// 1+2=3
// 100 rounds
// 10000000
// 2 Cars
// 2048
// A Blocky Christmas
// A Jumping Block
// A Life of Logic
// Angry Birds
// Angry Birds Space
// Artillery
// Astro-PANIC!
// Avoider
// Back to Square One
// Ball Game
// Ball vs Ball
// Ball: Revamped
// Balloon Invasion
// BallPusher
// Ballz
// Bar Balance
// Bejeweled
// Biggification
// Block it
// Blockage
// Bloons
// Boids
// Bombuzal
// Boom Dots
// Bouncing Ball
// Bouncing Ball 2
// Bouncy Light
// BoxHead
// Breakout
// Bricks
// Bubble Chaos
// Bubbles 2
// Card Game
// Castle Ramble
// Chronotron
// Circle Chain
// Circle Path
// Circle Race
// Circular endless runner
// Cirplosion
// CLOCKS - The Game
// Color Hit
// Color Jump
// ColorFill
// Columns
// Concentration
// Crossy Road
// Crush the Castle
// Cube Jump
// CubesOut
// Dash N Blast
// Dashy Panda
// Deflection
// Diamond Digger Saga
// Don't touch the spikes
// Dots
// Down The Mountain
// Drag and Match
// Draw Game
// Drop Wizard
// DROP'd
// Dudeski
// Dungeon Raid
// Educational Game
// Elasticity
// Endless Runner
// Erase Box
// Eskiv
// Farm Heroes Saga
// Filler
// Flappy Bird
// Fling
// Flipping Legend
// Floaty Light
// Fuse Ballz
// GearTaker
// Gem Sweeper
// Globe
// Goat Rider
// Gold Miner
// Grindstone
// GuessNext
// Helicopter
// Hero Emblems
// Hero Slide
// Hexagonal Tiles
// HookPod
// Hop Hop Hop Underwater
// Horizontal Endless Runner
// Hundreds
// Hungry Hero
// Hurry it's Christmas
// InkTd
// Iromeku
// Jet Set Willy
// Jigsaw Game
// Knife Hit
// Knightfall
// Legends of Runeterra
// Lep's World
// Line Rider
// Lumines
// Magick
// MagOrMin
// Mass Attack
// Math Game
// Maze
// Meeblings
// Memdot
// Metro Siberia Underground
// Mike Dangers
// Mikey Hooks
// Nano War
// Nodes
// o:anquan
// One Button Game
// One Tap RPG
// Ononmin
// Pacco
// Perfect Square!
// Perfectionism
// Phyballs
// Pixel Purge
// PixelField
// Planet Revenge
// Plants Vs Zombies
// Platform
// Platform game
// Plus+Plus
// Pocket Snap
// Poker
// Pool
// Pop the Lock
// Pop to Save
// Poux
// Pudi
// Pumpkin Story
// Puppet Bird
// Pyramids of Ra
// qomp
// Quick Switch
// Racing
// Radical
// Rebuild Chile
// Renju
// Rise Above
// Risky Road
// Roguelike
// Roly Poly
// Run Around
// Rush Hour
// SameGame
// SamePhysics
// Save the Totem
// Security
// Serious Scramblers
// Shrink it
// Sling
// Slingy
// Snowflakes
// Sokoban
// Space Checkers
// Space is Key
// Spellfall
// Spinny Gun
// Splitter
// Spring Ninja
// Sproing
// Stabilize!
// Stack
// Stick Hero
// String Avoider
// Stringy
// Sudoku
// Super Mario Bros
// Surfingers
// Survival Horror
// Talesworth Adventure
// Tetris
// The Impossible Line
// The Moops - Combos of Joy
// The Next Arrow
// Threes
// Tic Tac Toe
// Timberman
// Tiny Wings
// Tipsy Tower
// Toony
// Totem Destroyer
// Tower Defense
// Trick Shot
// Tunnelball
// Turn
// Turnellio
// TwinSpin
// vvvvvv
// Warp Shift
// Way of an Idea
// Whack a Creep
// Wheel of Fortune
// Where's my Water
// Wish Upon a Star
// Word Game
// Wordle
// Worms
// Yanga
// Yeah Bunny
// Zhed
// zNumbers