All I want to accomplish is have the grabToy function happen with a 5 sec… I had put it in a timer.performWithDelay… and it gave me this error
Runtime error
?:0: attempt to index a nil value
stack traceback:
[C]: ?
?: in function ‘?’
?: in function <?:215>
Here is my code)
[lua]display.setStatusBar( display.HiddenStatusBar ) – HIDE STATUS BAR
wordArray = {}
local i = 1
local loqsprite = require(‘loq_sprite’)
local _W = display.contentWidth
local _H = display.contentHeight
local BG = display.newImageRect(“background.png”, 1024, 768)
BG.x = _W/2; BG.y = _H/2
local words = { “Play”,“Mad”}
local listener
local bfactory = loqsprite.newFactory(“boyPlaying”, “angry”)
local boy = bfactory:newSpriteGroup()
boy.x = 550; boy.y = 350
local bfactory = loqsprite.newFactory(“otherBoy”)
local otherBoy = bfactory:newSpriteGroup()
otherBoy.x = 550; otherBoy.y = 350
local function grabToy()
otherBoy:play(“otherBoy grab”)
end
–atrace(xinspect(otherBoy:getSpriteNames()))
–atrace(xinspect(boy:getSpriteNames()))
listener = function( event )
local phase = event.phase
local word = event.target
if ( phase == “ended” ) then
local function complete()
word.alpha = 0.5
local newIndex = (word.index % #words)+1
words[newIndex].alpha = 1
word:removeEventListener( “touch”, listener )
words[newIndex]:addEventListener( “touch”, listener )
end
– delay new word highlight if needed
timer.performWithDelay ( 100, complete )
– animations
if word.index == 1 then boy:play(“aniPlay boyPlaying”); otherBoy:play(“otherBoy watch”)
elseif word.index == 2 then boy:play(“aniPlay angry”); timer.performWithDelay(100, grabToy )
end
end
end
– draw words
for i=1,#words do
local word = display.newText ( words[i], 0, 0, native.systemFont, 26)
word.x, word.y = 100, 100 * i
word.index = i
words[i] = word
word.alpha = 0.5
end
words[1].alpha = 1
words[1]:addEventListener( “touch”, listener )[/lua]
Thanks for any help
[import]uid: 51459 topic_id: 18039 reply_id: 318039[/import]