What is the best way I center the screen to follow the character? Should I use CCCamera
or just move the background around?
I am new to cocos2d so please show me exact code.
BTW: I am also using box2d in this project.
Thanks
What is the best way I center the screen to follow the character? Should I use CCCamera
or just move the background around?
I am new to cocos2d so please show me exact code.
BTW: I am also using box2d in this project.
Thanks
Hey there, You have always to choose between the best way and the best way in your situation. A problem has multiple ways how you can solve it. So I can just tell you how I did it.
A few weeks ago I released my first game. (If you are interested check it out: Birdy!) I also used Cocos2d and had the same problem like you. The player should always be in the center of the screen. I've choosen the way to move the background. I added 2 things to the GameScene: The background and the bird. And I set the background as the bird's delegate. So as soon as the bird performs a jump for example, the background is moved in the opposite direction.
I think for my situation it was the best method. But I can't talk about CCCamera
because I never did anything with that class...
I hope I could help you a little bit. But it's always a bit difficult to find the right way. So you should also think about things you will optionally add in the future. So perhaps my way does not fit your requirements...
I hope also my english is understandable...
Sandro Meier
Try this...
It will follow your character (your hero).