If someone can tell me why the touch event is not working for the sprite, but IS working for the image (see below) I would greatly appreciate it!
[code]
require “sprite”
local _w = display.contentWidth/2
local _h = display.contentHeight
local left= display.newImage( “left.png”, 160, 240 )
— using texturepacker sprite sheet
local sheetData = require “cannon”
local cannonSpriteData = sheetData.getSpriteSheetData()
local cannonSpriteSheet = sprite.newSpriteSheetFromData( “cannon.png”, cannonSpriteData )
local cannonSpriteSet = sprite.newSpriteSet(cannonSpriteSheet, 1, 9)
local cannonSprite = sprite.newSprite(cannonSpriteSet)
cannonSprite.x = _w
cannonSprite.y = _h - 55
function onObjectTouch( event )
print(“touch”)
end
–this touch event does NOT WORK
cannonSprite:addEventListener(“touch”, onObjectTouch)
– the sprite is displayed and the animation runs
cannonSprite:play()
–this touch event WORKS!!!
left:addEventListener( “touch”, onObjectTouch )
[/code] [import]uid: 82529 topic_id: 34332 reply_id: 334332[/import]