How do we capture left move and right move and top move event using cocos2d?
I am taking one sprite(car) and if I move left it should move to the left on screen and to the right if you move to the right.
How do we capture left move and right move and top move event using cocos2d?
I am taking one sprite(car) and if I move left it should move to the left on screen and to the right if you move to the right.
There are a few ways to implement movement in an iPhone app.
Hope this gives you some ideas.
Cocos2d uses custom callbacks called ccTouchesBegan, ccTouchesEnded, etc... basically the same callbacks you'd use in a regular UIView to detect touches, or accelerometer changes, but with Cocos2d the letters 'cc' are appended - this allows for event propagation to occur.
You must return kEventHandled or kEventIgnored - these events are only passed onto Cocos2d Layers. If multiple Layers are in the scene, each layer will receive the event (in the opposite order they were added to the scene, not their z-order). If you return kEventHandled, the event is then dropped and not passed further down the chain, otherwise the event is passed further down the chain to the next Layer until kEventHandled is returned, or all layers have been given a chance to handle the event.