I searched the forums and there are topics where the solution for this is spoken of, but I haven’t found the final solution.
I’m using the Samurai Fruit demo/template as a framework for an internal prototype, not-for-sale program that we can have on an iPad at a conference to draw people to our booth. Fun only to get interest in our booth.
SO … I’m using teh samurai fruit. I’m replacing all the elements to be branded for our company.
I’ve used Peach Pellen’s excellent score system to have a few items that give different scores
[code]
local background = display.newImage (“background.png”)
score = require (“score”)
local border = 5
local scoreInfo = score.getInfo()
score.init({
x = 40,
y = 5}
)
score.setScore(0)
local coin1 = display.newCircle (320,320,20)
local coin2 = display.newCircle (270,270,20)
local coin3 = display.newCircle (200,200,20)
local function addtoit10 (event)
if event.phase == “ended” then
score.setScore (score.getScore()+10)
end
end
local function addtoit25 (event)
if event.phase == “ended” then
score.setScore (score.getScore()+25)
end
end
local function addtoit50 (event)
if event.phase == “ended” then
score.setScore (score.getScore()+50)
end
end
coin1:addEventListener(“touch”, addtoit10)
coin2:addEventListener(“touch”, addtoit25)
coin3:addEventListener(“touch”, addtoit50)[/code]
So it works fine.
Then I add it to the samurau fruit example. I can get a the upper left score area to show, but when I try and add the event listener it breakssaying I’m attempting to index a global nil value.
It’s the line:
coin1.addEventListener ("touch", addtoit10)
That’s causing the error. I think because in the samuari fruit example the coins are called as random values? And not actually added like a normal item?
I have a few other questions for this project, but I’ll start with this one since it’s hurdle #1.
Thank you for any/all help! [import]uid: 97023 topic_id: 16865 reply_id: 316865[/import]