Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

catching tap events from an image in a container
Started by jason_bullen Dec 03 2018 04:50 AM

1 reply to this topic
events containers

Best Answer davebollinger , 03 December 2018 - 08:04 AM

you don't show your "onCyborgTap" function - does it exist and is in scope at the time you add the listener??

or,.. have you double-checked your coordinates?  unless your image is very large it wouldn't be visible/tap-able at -500,-250.

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

jason_bullen

[GLOBAL: userInfoPane.html]
jason_bullen
  • Observer

  • 8 posts
  • Corona SDK

I have an image that I insert into a container.

Then I add a "tap" listener to the image.

Here is my code:

 

_group = display.newGroup();

_container = display.newContainer( 800, 400 )
_container:translate( 0, 0 );

cyborg = display.newImage( "cyborg.jpg" );
_container:insert( cyborg, true );
cyborg.x = -500;
cyborg:addEventListener( "tap", onCyborgTap );

_container.y = -250;
_group:insert( _container );

 

The "onCyborgTap" function is never executed.

If I don't add the image to the container, the function is executed as expected.

 

Please help :)



[TOPIC: post.html]
#2

davebollinger

[GLOBAL: userInfoPane.html]
davebollinger
  • Corona Geek

  • 1,259 posts
  • Enterprise

  Best Answer

you don't show your "onCyborgTap" function - does it exist and is in scope at the time you add the listener??

or,.. have you double-checked your coordinates?  unless your image is very large it wouldn't be visible/tap-able at -500,-250.




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: events, containers