I feel that the main thing holding me back is that i cannot understand how to program a class so that all i have to do to make.. for example, squares. I want to be able to call something like makesquare() and than it will autospawn a square in a random spot that in 10 seconds, deletes itself. Like balls2 example but fully automatic so i can eventually code only 1 monster and it will be able to make 400 without this:
local ball1 = Ball.new("ball1.png")
local ball2 = Ball.new("ball2.png")
local ball3 = Ball.new("ball3.png")
local ball4 = Ball.new("ball4.png")
stage:addChild(ball1)
stage:addChild(ball2)
stage:addChild(ball3)
stage:addChild(ball4)
*100
any help would be greatly appreciated because when i understand this, i might have a shot at making things like paratroopers, minesweeper, and etec.
(If you are confused by this ^ just ask for clarification. I understand that sometimes i get confusing.)
“ The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time. ” - Tom Cargill
Comments
A class mainly in Lua is defined as a table {...}
Please consider the following code snippet which is a sample of class:
local obja = {info="class a"}
function obja:new(mt)
local mt = mt or {}
setmetatable(mt, self)
self.__index = self
return mt
end
function obja:showinfo()
print(self.info)
end
obja:showinfo()
You may add any other method or property you want. I hope this may be of a bit handy to you. Have a nice day.
I make it for you in my free time, hope you like it!
http://giderosmobile.com/forum/discussion/4769/simple-item-pool-class
Likes: Harrison