For some reason, i cannot return the object transmitted in the transition.to
The following function is generating a bullet and once it generated i want it to be removed after completion of the transition action. I got the following error
[blockcode]
Runtime error
/Development/starwar/library.lua:44: attempt to call method ‘removeSelf’ (a nil value)
stack traceback:
[C]: in function ‘removeSelf’
/Development/starwar/library.lua:44: in function
(tail call): ?
?: in function <?:866>
?: in function <?:214>
[/blockcode]
instantiate Bulle Function:-
[blockcode]
function instantiateBullet()
bullet = movieclip.newAnim(1,{rocketImages…“rocket2.png”})
–bullet = display.newImage(rocketImages…“rocket2.png”)
local _=lineObject
local bulletHightCeeling,bulletWidthCeeling = _.y + 1, _.width-10
print (0, 0, bulletWidthCeeling, bulletHightCeeling )
–bullet:setDrag{drag=false,bounds = {15, bulletWidthCeeling, bulletWidthCeeling, bulletHightCeeling }} --left, top, width, height
bullet.objectName=“bullet”;
bullet.isVisible = true
bullet.y = spaceShip.y - 65; bullet.x = spaceShip.x
physics.addBody(bullet,{bounce = 0.3, fraction=1.0, denisty=0.0 })
playSound(“lazer.caf”)
–bullets[#bullets+1] = bullet
bullet.collision = onCollision
bullet:addEventListener( “collision”, bullet)
nemesisGroup:insert(bullet)
print(bullet.x)
transition.to(transition.to(bullet,{time=1000, delay=10, alpha=1.0, y=28,
onComplete= function() bullet:removeSelf() end}))
return bullet
end
[/blockcode] [import]uid: 11038 topic_id: 3997 reply_id: 303997[/import]
[import]uid: 11038 topic_id: 3997 reply_id: 12160[/import]
[import]uid: 9371 topic_id: 3997 reply_id: 12179[/import]
[import]uid: 9371 topic_id: 3997 reply_id: 12186[/import]