-1

Eventually I will implement the following using touch technology. For the time being however I am only after the mouse solution. If a player clicks and holds the mouse on a particular part of the screen, or on a particular sprite/ menuitem (an image of a left arrow for e.g.) then the main game sprite (say a car for e.g.)continues moving to the left until the player releases the mouse button. If a player clicks and holds another part of the screen/sprite/menu item (an image of a right arrow) then the car continues moving to the right until the player releases the mouse button. Note that the mouse does not have to move while the button is being held down.

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
Bruno
  • 17
  • 4
  • Not enough context and too broad. What is the gist of your question, how to receive mouse click events? How to move the objects towards the mouse? PS: I take it you want to develop a web app with cocos2d-html5? Therefore I removed the cocos2d-iphone and cocos2d-android tags because they are different engines, incompatible to cocos2d-x. – CodeSmile Apr 28 '14 at 14:30

1 Answers1

0

solved via a combination of mousedown, mouseup and scheduleupdate. So i have two arrows on my screen. A left and right arrow. If the player clicks and holds on the left arrow then the car sprite keeps moving to the left across the screen and vice versa for the right arrow moving the car right. The car only stops moving when the player releases the mouse (mouseup) from the respective arrow.

Bruno
  • 17
  • 4