Cocos2d – Touch Events
http://www.levelhelper.org/app/documentation/docs/COCOS2D_touch.htm
LHSprite* mySprite = [lh spriteWithUniqueName:@"MySpriteName"]; [mySprite registerTouchBeginObserver:self selector:@selector(touchBegin:)]; [mySprite registerTouchMovedObserver:self selector:@selector(touchMoved:)]; [mySprite registerTouchEndedObserver:self selector:@selector(touchEnded:)];
-(void)touchBegin:(LHTouchInfo*)info{ if(info.sprite) NSLog(@"Touch BEGIN on sprite %@", [info.sprite uniqueName]); if(info.bezier) NSLog(@"Touch BEGIN on bezier %@", [info.bezier uniqueName]); } -(void)touchMoved:(LHTouchInfo*)info{ if(info.sprite) NSLog(@"Touch MOVED on sprite %@", [info.sprite uniqueName]); if(info.bezier) NSLog(@"Touch MOVED on bezier %@", [info.bezier uniqueName]); } -(void)touchEnded:(LHTouchInfo*)info{ if(info.sprite) NSLog(@"Touch ENDED on sprite %@", [info.sprite uniqueName]); if(info.bezier) NSLog(@"Touch ENDED on bezier %@", [info.bezier uniqueName]); }
‘registerTouchBeginObserver:selector’ is deprecated.
↓
registerTouchBeganObserver
SpriteHelperでPhysicsのIs Sensorをチェックしないとダメ。
関係ないみたい。
http://www.raywenderlich.com/4622/how-to-use-spritehelper-and-levelhelper-tutorial
Cocos2d – LevelHelper – LHSprite – Touch Detect