Oh.
Also, this is my current code:
--characters.lua local m = {} m.units = { {img = "sprites/girl.png", timeBetweenAtk = 2350, name = "girl", cost = 75} } m.girl = {} m.girl.walking = {} local data = {width = 309, height = 494, numFrames = 10, sheetContentWidth = 1545, sheetContentHeight = 988} m.girl.walking.sheet = graphics.newImageSheet("sprites/walking-girl.png", data ) m.girl.walking.seq = {name = "walking", start = 1, count = 10, loopCount = 0, loopDirection = "forward"} m.girl.primaryAtk = {} local data = {width = 385, height = 477, numFrames = 10, sheetContentWidth = 1925, sheetContentHeight = 954} m.girl.primaryAtk.sheet = graphics.newImageSheet("sprites/melee-girl.png", data) m.girl.primaryAtk.seq = {name = "melee", start = 1, count = 10, loopCount = 0, loopDirection = "forward"} m.girl.idle = {} local data = {width = 271, height = 473, numFrames = 10, sheetContentWidth = 813, sheetContentHeight = 1892} m.girl.idle.sheet = graphics.newImageSheet("sprites/idle-girl.png", data) m.girl.idle.seq = {name = "idle", start = 1, count = 10, loopCount = 0, loopDirection = "forward"} return m
--main.lua for k = 1, #imgSet do local identifier = characters.units[k].name local function spawnCharacter(event) if event.phase == "began" then if moneyCount \< characters.units[k].cost then print("insufficient funds") else moneyCount = moneyCount - characters.units[k].cost moneyText.text = moneyCount .. " / " .. moneyWallet local unit = display.newSprite(characters.identifier.walking.sheet, characters.identifier.walking.seq) end end return true end imgSet[k]:addEventListener("touch", spawnCharacter) end
I was just trying to find a good way to spawn an individual unit if there are 10 to choose from.