Game Development Reference
In-Depth Information
What just happened?
In the interface, we declare the class to be a subclass of the public
Sprite
class.
Then we add three synthesized properties. In Cocos2d-x, these are macros to create getters
and setters. You declare the type, the protected variable name, and the words that will be
appended to the
get
and
set
methods. So in the first
CC_SYNTHESIZE
method, the
getNextPosition
and
setNextPosition
method will be created to deal with the
Point
value inside the
_nextPosition
protected variable.
We also add the constructor and destructor for our class, and the ubiquitous static method
for instantiation. This receives as a parameter, the image filename used by the sprite. We
finish off by overriding
setPosition
from
Sprite
and adding the declaration for our
helper method radius.
The next step then is to implement our new class.