Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
strange bug on iPhone with Even.MOUSE_DOWN with Event.MOUSE_MOVE - Gideros Forum

strange bug on iPhone with Even.MOUSE_DOWN with Event.MOUSE_MOVE

anneMurielleanneMurielle Member
edited February 3 in General questions
Hi,

I'm modifying an old game for kid that I've made with Gideros in 2014. Everything seems to work fine except for 2 or 3 things.
I cannot figure one of them. In my game, I have several images that the kid can click on it to change the image or move the image (in this case, the image doesn't change).
Everything works fine with the player but when I launch the game on my iPhone I have a problem. Moving the image works fine but the simple click on these images doesn't work at all... except if I move the image at the bottom of the screen... so strange... what could be the problem? Do I need to add a plugin or a library in Xcode? :s ...

Thank you for your help!

I have 3 events for each of the images:
The Event.MOUSE_DOWN
The Event.MOUSE_MOVE
The Event.MOUSE_UP

In the mouse_up, I've added dialog to display what's the value of target.hasMoved... and on the iPhone, it's always true even if I just do a simple click.

Here is the code

MOUSE_DOWN-> set target.hasMoved to false
self.ball:addEventListener(Event.MOUSE_DOWN, function(event)
				local target = event:getTarget()
 
				if target:hitTestPoint(event.x, event.y) then	
				      target.hasMoved = false
					self.ball.isMoving = true
					self.ball.x0 = event.x
					self.ball.y0 = event.y
					event:stopPropagation()
                                   end
			end
		)
MOUSE_MOVE-> move the object and change its scale depending on the position
self.ball:addEventListener(Event.MOUSE_MOVE, function(event)
			local target = event:getTarget()
 
					if  target.isMoving == true then  
						target.hasMoved = true
						dx = event.x -target.x0
						dy = event.y - target.y0
						target.x0 = event.x
						target.y0 = event.y
 
						local newX = dx + target:getX()
						local newY = dy + target:getY()
 
						if newY + target:getHeight()/2 > application:getContentHeight()  then 
							newY =application:getContentHeight()-target:getHeight()/2 
						end 
 
						if newX +target:getWidth()/2> application:getContentWidth()  then newX =application:getContentWidth()-target:getWidth()/2 end 
 
						if newY < -1*target:getHeight()/2   then newY =-1*target:getHeight()/2 end 
						if newX < -1*target:getWidth()/2	then newX=-1*target:getWidth()/2 end 
 
						target:setX(newX)
						target:setY(newY)
 
						--850 is the 1
 
 
						local sc = 1*target:getY()/1156
 
						if sc < 0.3 then sc = 0.3 end
 
						if sc > 2 then sc = 2 end
						target:setScale(sc)
 
 
 
						event:stopPropagation()	
				end	
 
			end)
MOUSE_UP -> test the target.hasMoved, if false, remove the image and add the new one. But the problem is that the target.hasMoved is almost always true...
self.ball:addEventListener(Event.MOUSE_UP, function(event)
			local target = event:getTarget()
 
				if (target.isMoving == true) then 
					target.isMoving = false
						randomObject.ballX = target:getX()
						randomObject.ballY = target:getY()
 
						if target.hasMoved == false then
 
							self.ball:removeFromParent()
							self.ball = nil
							local i = randomObject.ball +1
						        randomObject.ball = i
							self:addBall(randomObject.ballX,randomObject.ballY)
						end
						target.hasMoved = false
 
 
						event:stopPropagation()	
 
				end
 
 
 
			end)

Comments

Sign In or Register to comment.