Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Tapping a moving shape
Started by ken_shek Mar 30 2019 02:30 AM

2 replies to this topic
transition
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

ken_shek

[GLOBAL: userInfoPane.html]
ken_shek
  • Observer

  • 3 posts
  • Corona SDK

Hi everybody.

Why can't I tap on the circle while it's in transition and print the coordinates?

 

local function onObjectTap( self, event )
 local TapX = event.x
    local TapY = event.y
 print ("circle tapped: (".. TapX .. "," .. TapY .. ")")
end

local myCircle = display.newCircle (300,300,200)
myCircle.tap = onObjectTap
myCircle:addEventListener( "tap", myCircle )

transition.to( myCircle, { time=2000, x=500 ,y=1000, delta=true } )

 

Can it not listen while moving?

It's fine once it finishes moving.

I'm I doing it wrong? Should I be using something else to animate/move the circle?

 

Thanks

Ken



[TOPIC: post.html]
#2

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Corona Geek

  • 1,034 posts
  • Corona SDK

Your code runs correctly and doesn't have any errors. You are probably experiencing issues due to two reasons.

First, the object moves fast in the transition and you may not have adequate time to tap the circle given the speed. Just add a zero at the end of your transition time and you'll see that it works.

Second, you are using a tap listener, not a touch listener. Tap events are simply touching/pressing down and letting go. If you move your finger or cursor while holding down, you are looking at a touch event. It is possible that you are accidentally swiping as you are trying to tap the fast moving object.



[TOPIC: post.html]
#3

ken_shek

[GLOBAL: userInfoPane.html]
ken_shek
  • Observer

  • 3 posts
  • Corona SDK

Hi XeduR @Spyric , Thanks for the reply. Yeah it does work when it's on the phone. Maybe my computer isn't fast enough to know I clicked on the circle.


[topic_controls]
[/topic_controls]