Touch Event not firing for sprite

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]

Hello,
I don’t see any immediate errors here, but I would suggest that you utilize the new imageSheet-based sprite methods. Currently, you’re using the depreciated sprite methods, which are technically “supported” but strongly discouraged as they will receive no updates going forward.

You can read a starter tutorial about the new sprite method(s) here:
http://www.coronalabs.com/blog/2012/10/02/animated-sprites-and-methods/

If the no-response-on-touch issue is still happening after you convert over to the new methods, let me know and I’ll take a look at your code again.

Best regards,
Brent
[import]uid: 200026 topic_id: 34332 reply_id: 136464[/import]

thanks so much Brent! [import]uid: 82529 topic_id: 34332 reply_id: 136467[/import]

Hello,
I don’t see any immediate errors here, but I would suggest that you utilize the new imageSheet-based sprite methods. Currently, you’re using the depreciated sprite methods, which are technically “supported” but strongly discouraged as they will receive no updates going forward.

You can read a starter tutorial about the new sprite method(s) here:
http://www.coronalabs.com/blog/2012/10/02/animated-sprites-and-methods/

If the no-response-on-touch issue is still happening after you convert over to the new methods, let me know and I’ll take a look at your code again.

Best regards,
Brent
[import]uid: 200026 topic_id: 34332 reply_id: 136464[/import]

thanks so much Brent! [import]uid: 82529 topic_id: 34332 reply_id: 136467[/import]