i am using cocos2d to develop a game, now have a sprite loaded from image, and i would like to draw something on it like square? how can i do that?
+1
A:
This is what I would do:
- Create a new CocosNode class. Call it CustomDrawNode
- in the draw method of that class I would use drawline to draw what I need.
- In the GameScene where you init your sprite, also init an instance of your CustomDrawNode.
- Add it to the scene with: [self addChild:myCustomDrawNode z:1000 tag:999]. Use a higher z than the sprite.
- Move your instance of CustomDrawNode to the same position as the sprite.
Mattias Akerman
2010-02-03 12:58:56
You may want to add it as a child of the sprite.
hudsonb
2010-02-03 21:41:02