Harder Monsters and More Levels: How To Make A Simple iPhone Game with Cocos2D 2.X Part 3

Discussion of the official tutorials published on raywenderlich.com. Please only discuss the official tutorials here - for general questions, use the General Discussion forum instead.

Harder Monsters and More Levels: How To Make A Simple iPhone Game with Cocos2D 2.X Part 3

Postby rwenderlich » Thu Nov 22, 2012 1:00 pm

This is the official thread to discuss the following blog post: Harder Monsters and More Levels: How To Make A Simple iPhone Game with Cocos2D 2.X Part 3
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ray Wenderlich
Blog: http://www.raywenderlich.com
Twitter: http://twitter.com/rwenderlich
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
User avatar
rwenderlich
Team Member
Site Admin
 
Posts: 2216
Joined: Thu Dec 23, 2010 4:14 pm
Has thanked: 28 times
Been thanked: 359 times

Re: Harder Monsters and More Levels: How To Make A Simple iP

Postby daithi » Wed Nov 28, 2012 4:21 pm

This line of code
Code: Select all
_levels = [@[level1, level2] retain];
from the init method keeps giving an error, unexpected '@' in program, is it a typo? I am on xcode 4.2
daithi
Baby Hacker
 
Posts: 7
Joined: Tue Aug 21, 2012 1:53 pm
Has thanked: 1 time
Been thanked: 1 time

Re: Harder Monsters and More Levels: How To Make A Simple iP

Postby rcasey » Wed Nov 28, 2012 5:24 pm

That line uses the new syntax to define an array, so you would need to be on XCode 4.5 to take advantage of it.

As a workaround, you could use
Code: Select all
_levels = [ [NSArray arraywithObjects:level1, level2, nil] retain];

but I would go ahead and upgrade to 4.5.

Have fun!
rcasey
Team Member
Forum Subject Matter Expert
 
Posts: 1223
Joined: Fri Jul 01, 2011 6:50 pm
Has thanked: 2 times
Been thanked: 264 times

Re: Harder Monsters and More Levels: How To Make A Simple iP

Postby daithi » Thu Nov 29, 2012 9:11 am

That line uses the new syntax to define an array, so you would need to be on XCode 4.5 to take advantage of it.

As a workaround, you could use
CODE: SELECT ALL
Code: Select all
_levels = [ [NSArray arraywithObjects:level1, level2, nil] retain];


but I would go ahead and upgrade to 4.5.

Have fun!


Hey thanks rcasey

I was thinking that it was some new 4.5 feature but wasn't 100% sure as I hadn't seen it before. Upgrading is on my todo list.

Thanks again.
daithi
Baby Hacker
 
Posts: 7
Joined: Tue Aug 21, 2012 1:53 pm
Has thanked: 1 time
Been thanked: 1 time

Re: Harder Monsters and More Levels: How To Make A Simple iP

Postby daithi » Thu Nov 29, 2012 10:21 am

Use initWithObjects for 4.2 instead of arrayWithObjects if you are still using 4.2 like me :) rcasey was 99% Thanks again
Code: Select all
_levels = [[[NSArray alloc] initWithObjects:level1, level2, nil] retain];//4.2
daithi
Baby Hacker
 
Posts: 7
Joined: Tue Aug 21, 2012 1:53 pm
Has thanked: 1 time
Been thanked: 1 time

Re: Harder Monsters and More Levels: How To Make A Simple iP

Postby Infinity-James » Thu Nov 29, 2012 7:46 pm

Bloody amazing tutorial!

I'm so happy with the timing as well, I was about to do the old tutorial just as it was updated. Yay for me, haha.

Thank you so much, I love this website.
Infinity-James
Uber Haxx0r
 
Posts: 56
Joined: Thu Oct 18, 2012 4:46 pm
Has thanked: 4 times
Been thanked: 3 times

Re: Harder Monsters and More Levels: How To Make A Simple iP

Postby Vicbit » Mon Dec 10, 2012 8:01 pm

I´m still in Xcode 4.3.2 and I have an issue with this line in LevelManager.m

return _levels [_curLevelIdx];

What´s wrong with that?

Thanks!
Vicbit
Baby Hacker
 
Posts: 6
Joined: Mon Dec 10, 2012 7:56 pm
Has thanked: 1 time
Been thanked: 0 time

Re: Harder Monsters and More Levels: How To Make A Simple iP

Postby Vicbit » Mon Dec 10, 2012 8:45 pm

I solved this replacing this line of code

return _levels[_curLevelIdx];

for

return [_levels objectAtIndex: _curLevelIdx];

:D :D
Vicbit
Baby Hacker
 
Posts: 6
Joined: Mon Dec 10, 2012 7:56 pm
Has thanked: 1 time
Been thanked: 0 time

Re: Harder Monsters and More Levels: How To Make A Simple iP

Postby rcasey » Mon Dec 10, 2012 8:49 pm

Vicbit wrote:I´m still in Xcode 4.3.2 and I have an issue with this line in LevelManager.m

return _levels [_curLevelIdx];

What´s wrong with that?

Thanks!


That uses the new array syntax.

As a workaround, you can use

Code: Select all
return [_levels objectAtIndex:_curLevelIdx];


Or you can upgrade to Xcode 4.5 :)
rcasey
Team Member
Forum Subject Matter Expert
 
Posts: 1223
Joined: Fri Jul 01, 2011 6:50 pm
Has thanked: 2 times
Been thanked: 264 times

Re: Harder Monsters and More Levels: How To Make A Simple iP

Postby Yaman » Sun Dec 23, 2012 1:14 am

Hi,

Thanks for this amazing tutorial, so good job !

Somewhere at the beginning, you talked about component based architecture for games development.
Is there any of your cocos2d tutorials based on this kind of architecture at this moment ? I would love to know how it works.

Thanks again !
Yaman
Hacker
 
Posts: 10
Joined: Sun Dec 23, 2012 1:09 am
Has thanked: 0 time
Been thanked: 1 time

Next

Return to Official Tutorials

Who is online

Users browsing this forum: Bing [Bot] and 1 guest