How to Make a Game Like Jetpack Joyride using LevelHelper, SpriteHelper [Cocos2D 2.X edition] - Part 4

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.

How to Make a Game Like Jetpack Joyride using LevelHelper, SpriteHelper [Cocos2D 2.X edition] - Part 4

Postby rwenderlich » Fri Jan 25, 2013 2:00 pm

- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ray Wenderlich
Blog: http://www.raywenderlich.com
Twitter: http://twitter.com/rwenderlich
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
User avatar
rwenderlich
Team Member
Site Admin
 
Posts: 2056
Joined: Thu Dec 23, 2010 4:14 pm
Has thanked: 28 times
Been thanked: 291 times

Re: How to Make a Game Like Jetpack Joyride using LevelHelpe

Postby konedj » Sat Jan 26, 2013 2:19 pm

Cool!! Just a typo: In the final part of the tutorial, when you say: "In Part Two, " or In Part Three, they link you to the old parts , not to the upgraded ones :D

Also some advice to the readers, if you have enemies with animations, don't use AutoTraced Shapes, just use circle shape (if not, you're gonna get low fps), circle shapes just work great :D
konedj
Hacker
 
Posts: 46
Joined: Mon Jan 09, 2012 8:13 pm
Has thanked: 3 times
Been thanked: 1 time

Re: How to Make a Game Like Jetpack Joyride using LevelHelpe

Postby vladubogdan » Mon Jan 28, 2013 10:09 am

Yes, circle shapes are the fastest ones - but you can also optimise the shape you auto trace with the optimise slider inside SpriteHelper.
vladubogdan
Uber Haxx0r
 
Posts: 133
Joined: Wed Aug 24, 2011 6:05 am
Has thanked: 0 time
Been thanked: 12 times

Re: How to Make a Game Like Jetpack Joyride using LevelHelpe

Postby RockyB » Mon Jan 28, 2013 3:28 pm

HI Vladu, thanks for updating the tutorial.

I just obtained copies of sprite helper and level helper but I like to ask as a novice to level helper about the following gray areas:

1. How do I move objects using the accelerometer in level helper?
2. How to spawn objects randomly using level helper?
3. Is it possible to use openGl code in level helper for fluid simulation?
4. is it possible to mix cocos2d code and level helper "loader" codes in the same project?

Thanks in advance for your reply.
RockyB
Hacker
 
Posts: 15
Joined: Wed Sep 07, 2011 6:04 am
Has thanked: 2 times
Been thanked: 0 time

Re: How to Make a Game Like Jetpack Joyride using LevelHelpe

Postby vladubogdan » Tue Jan 29, 2013 7:46 am

Hey,

Yes, you can do all this things.

1. you will do it the same as you currently do it. (LHSprite is a subclass of CCSprite). The important thing to know is that the LHSprite is attached to a b2Body object (if it has physics) so in this case the transformations (position, rotation) are handled by Box2d and not cocos2d.
LHSprite code can help you move both so instead of using setPosition or setRotation (cocos2d methods) you will use
transformPosition, transformRotation, transformScale (LHSprite specific methods)
For transformations cocos2d actions (like move to point) you should enable overloaded transformations - e.g just do this

[sprite setUsesOverloadedTransformation:YES];

2. Check out Documentation tab(inside LH app) -> LevelHelper API -> cocos2d -> LevelHelperLoader class -> Create sprites dynamically.

3. Yes, just write your code in the draw method - the same as you will normally do it

4. yes.

LH code is just a bunch of classes that helps you do what you need but they dont restrict you in any way.
vladubogdan
Uber Haxx0r
 
Posts: 133
Joined: Wed Aug 24, 2011 6:05 am
Has thanked: 0 time
Been thanked: 12 times

Re: How to Make a Game Like Jetpack Joyride using LevelHelpe

Postby RockyB » Tue Jan 29, 2013 10:34 am

Thanks man for the fast answers to my queries...you are indeed a star!

For me its LevelHelper all the way ...!!
RockyB
Hacker
 
Posts: 15
Joined: Wed Sep 07, 2011 6:04 am
Has thanked: 2 times
Been thanked: 0 time

Re: How to Make a Game Like Jetpack Joyride using LevelHelpe

Postby RockyB » Fri Feb 01, 2013 11:39 am

@vladubogdan: I am here once again, I have tried implementing moving an object using accelerometer in level helper but I am at cross roads now. My problem is in your reply you talked about me using LHSprite methods transformScale etc....

vladubogdan wrote:Hey,

Yes, you can do all this things.

1. you will do it the same as you currently do it. (LHSprite is a subclass of CCSprite). The important thing to know is that the LHSprite is attached to a b2Body object (if it has physics) so in this case the transformations (position, rotation) are handled by Box2d and not cocos2d.
LHSprite code can help you move both so instead of using setPosition or setRotation (cocos2d methods) you will use
transformPosition, transformRotation, transformScale (LHSprite specific methods)
For transformations cocos2d actions (like move to point) you should enable overloaded transformations - e.g just do this

[sprite setUsesOverloadedTransformation:YES];




Now I have been searching for where these classes are so that I can understand how they are used and I have not been able to locate any docs on that. I have looked at LH API but there isn't anything on that. Secondly please can you help with just writing a LH code snippet that I can use to move an object using the accelerometer from the left to the right and vice versa of the iphone screen while keeping the object within the screen boundaries.

Thanks
RockyB
Hacker
 
Posts: 15
Joined: Wed Sep 07, 2011 6:04 am
Has thanked: 2 times
Been thanked: 0 time

Re: How to Make a Game Like Jetpack Joyride using LevelHelpe

Postby vladubogdan » Fri Feb 01, 2013 11:47 am

CCPoint pos = [sprite position];

pos.x *= accelerometer

[sprite transformPosition:pos];

Check x and y of the pos and sprite width and height in order to be inside the screen.

LHSprite.h its the place to look and "LHSprite class" chapter inside LevelHelper API from under "Documentation" tab inside LevelHelper.
vladubogdan
Uber Haxx0r
 
Posts: 133
Joined: Wed Aug 24, 2011 6:05 am
Has thanked: 0 time
Been thanked: 12 times

Re: How to Make a Game Like Jetpack Joyride using LevelHelpe

Postby Coder2012 » Thu Feb 14, 2013 3:32 pm

im having a problem with level-helper when i download the project and run it in the simulator the game is not set to retina display and everything in the game is offset..the game is unplayable ..how do i fix it?



EDIT: forget i just decided to rebuild the map again from scratch...it works great now. :D
Coder2012
n00b
 
Posts: 3
Joined: Thu Feb 14, 2013 2:26 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to Make a Game Like Jetpack Joyride using LevelHelpe

Postby Coder2012 » Sun Feb 17, 2013 7:02 am

When i try Running the game on my device everything functions great but the only things visible are the player and the bunnies?!?!?!?!?!?!WTF?!?! :shock: :evil: :x :oops:
Coder2012
n00b
 
Posts: 3
Joined: Thu Feb 14, 2013 2:26 pm
Has thanked: 0 time
Been thanked: 0 time

Next

Return to Official Tutorials

Who is online

Users browsing this forum: No registered users and 3 guests