søndag 30. januar 2011

Creating a full game - the menu

A menu is often used at the beginning of a app. To start the game, to change the settings and other stuuf. But a menu can also be used as a controller for your character. It can be arrows to make your character move or a joystick. Here i will teach you how to make a menu with images. The code will be a little different if you make the menu with labels, which is just letters on the screen.
To make a menu, write this in your if statement in your init block:

//This first line adds a Image to the menu (mine is item1) itemFromNormalImage is what you want the picture to look like before you click it, and selected image is what you want the picture/button to look like when you click it (you can make these the same if you want to)

CCMenuItemImage *item1 = [CCMenuItemImage itemFromNormalImage:@"buttonplay.png" selectedImage:@"buttonplay2.png"

//target:self means look in the return self; class. selector:@selector is where the method is located, and doThis is just the name of the mathod that is going to be called whenever you click the button

target:self selector:@selector(doThis:)];


//CCMenu menu = menuwithitems: item1, nil means:
//The menu is named: menu, and these are the items i want in it. nil signifies the end of the //items

CCMenu *menu = [CCMenu menuWithItems:item1, nil];




 //self addChild means: add this menu to the scene, easily enough
[self addChild:menu];


CCMenuItemImage *item1 = [CCMenuItemImage itemFromNormalImage:@"buttonplay.png" selectedImage:@"buttonplay2.png" 
target:self selector:@selector(doThis:)];
CCMenu *menu = [CCMenu menuWithItems:item1, nil];
[self addChild:menu];

If you get any errors, please tell me. First time a made a menu i got a lot of errors.
Ex: i forgot to write @ before the filname.
Ex: i forgot ;

example of a menu          --->  ---> ---> ---> ---> ---> ---> ---> ---> --->   

mandag 24. januar 2011

Errors

I will now tell you and explain some errors that i have wondered about, and after a while figured out:

If you get errors saying: expected ';' before'[' token or something like that, the easiest way to understand theese errors is to take away the two '' because they are just markers to tell you that this are a sign. So if you  translate that error it will be: expected ; before [ token. Often when i write a line of code, the error says at the start of a perfect code: expected ';' before '[' or something like that. And i often think that that new perfect line of code is wrong. But i have checked it 10 billion times and the code is right. So i check the line above. And what do i see? I see  ] without ; at the end. And then everything solves out and i understand. I have been pretty close to punching my mac in the screen when my code doesn`t work, but when i figured this easy error out i got really happy. But that time is over, moving on.

torsdag 20. januar 2011

Bonus features for the copy of papi jump.




How to make continuing background,
high score, and falling platforms.

how to make a copy of papi jump part 10

how to make a copy of papi jump part 9

how to make a copy of papi jump part 8

how to make a copy of papi jump part 7

how to make a copy of papi jump part 6

how to make a copy of papi jump part 5

how to make a copy of papi jump part 4

How to make a copy of papi jump part 3

How to make a copy of papi jump part 2

how to make a copy of papi jump

part 1

mandag 17. januar 2011

lørdag 15. januar 2011

Install templates

Now i would recommend you to install templates for cocos2d. First, go in your terminal (all macs have got a terminal, if you cant find it search in your finder). The terminal says when you the last time you logged in was. Write behind this: cd (drag the cocos2d map in to get the filename) press enter and write ./install-templates.sh-u (enter) then if you wrote everything right  your mac should start installing templates, when it is done it should say "done" or finished or something else. You are ready to move on!


[terminal icon]

fredag 14. januar 2011

Download xcode

Next step in his process is to go to: http://developer.apple.com/programs/start/register/create.php,
to make a profile as a developer.
When that`s don you can find the xcode download on the apple page when you are logged in. All this is completely FREE. It will take about 3 hours to download xcode. After  this download you should download cocos2d, a small program used with xcode. I recommend you to download this, if you don`t my other guides will just be waste for you. Here is the link for downloading cocos2d: http://www.cocos2d-iphone.org This wont take more than 15 min to download. :)