1

CCSprite class reference

I need an object in which I can draw and it also has fixed rect size with position. It seems CCSprite has everything I need but it can be initialized with picture only.

CCLayer can be initialized without picture but it hasn't rect. I have found content size only.

So what to do if I need an object similar to CCSprite, but I don't wan't to use pictures?

EDITED

I mean I need a Rect to detect touches. And CCSprite can be defined with a static method spriteWithTexture:rect:, where I can manually set its rect. But what to do if I don't want to set texture, but rect only?

Gargo
  • 1,135
  • 1
  • 10
  • 21

1 Answers1

4

You can create a sub class of CCNode and override its draw method.

You can look here for more detail

giorashc
  • 13,691
  • 3
  • 35
  • 71
  • I have edited the question. Your answer is too partially answers this question. – Gargo Jan 14 '14 at 18:58
  • 1
    Did you try setting the node's contentSize and position members ? This should be the rect you are looking for – giorashc Jan 14 '14 at 22:08
  • Yes, I found these properties yesterday, but anyways it is size and position are accessed separately, so I need a category with a rect setter/getter. But finally if I will use these properties then is `CCNode` the most appropriate object? Or has it no difference? – user2083364 Jan 15 '14 at 09:22
  • 1
    This should work fine for you. CCNode is the basic drawing element. Any GUI object like CCSprite inherit from a CCNode for its specific functionality (i.e. loading texture etc..) – giorashc Jan 15 '14 at 09:28