Reputation: 728
I want to make free running/side scrolling type game in cocos2d.i try it in tile maps but i am
stucked due to an issue.Issue is i want to jump and after jump the player sprite detects the
lower floor boundary and get the position at floor boundary whenever don't get boundary it
dies.can anyone suggest me what i do or any tutorial etc?Or help me by code example ?
Thanks
Upvotes: 2
Views: 503
Reputation: 61
I write code in my game that you want.
So i suggest that you create the player class and set gravity and velocity of player. In update method of player class set the position of the player. And add the floor in array and in update method test the collision between player and floor with CGRectIntersectsRect.
floor *flr = [allfloors objectAtIndex:i];
CGRectIntersectsRect([self boundingbox],[flr boundingbox])
{
self.position = ccp(self.position.x,flr.position.y + flr.contentSize.height/2);
velocity = 0;
}
and whenever you want to jump just apply the Velocity.
Upvotes: 0
Reputation: 929
I created a basic platformer for the Global Game Jam, using Box2D and adding a couple of classes similar to the Flash engine called "Citrus Engine". You may use this as you like and take it as an example.
http://globalgamejam.org/2012/o
Upvotes: 2