cocoa touch - Cancel ccTouch on State Change in Cocos2d-iPhone -


could please with issue having canceling touch event when character dies. have character controller (touch sprite , drag left/right move) based on screen x-axis. controller class subclass of ccnode , has required methods register touch touchdispatcher. cctouchbegin, cctouchmove & cctouchend works fine, while cctouchmove in action , character dies want reset controller, player position start location on screen not trigger until lift finger(thus cctouchend) triggers reset player/controller in gamelayer(cclayer) fires.

i thought adding cctouchcancel method trick not getting fired. each of touch event methods first checks controller's state (idle, active, stop) before doing actions. have update method handle dragging checks controller.state == active before allowing player drag/move character.

in gamelayer's update method when character dies, set controller.state = stop. in controller's update method stop state, call [[[ccdirector shareddirector] touchdispatcher] removedelegate: self]; same code in onexit method, touch event not canceling. touch event stopping if lift finger. state change made in gamelayer fires

please advise.

i figured out why character's controller not changing state stop when character dies. had implemented cctouchcancel method not getting triggered, touch event never cancelling until lifted finger off screen.

i had implemented update: (cctime)delta method, in checking active state , performing action. after commenting out update method, worked expected. there no need update method cctouchmove method handles continuous touched location detection long finger touching screen, no need run update method.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -