Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / stand on Top of Floor

Author
Message
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 10th Jan 2014 18:29
I try to check collision between 2 Player and Floor Sprite with GetPhysicsCollision () Function because The Player and Floor have Physics. but it show the result 0. I think collision no detect on the top and bottom of the floor sprite. No I need a way for detect collision on the top and bottom of the floor sprite.
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 10th Jan 2014 19:52
Maybe alpha transparency is causing a problem?, or the physics shape isn't right for the player and/or platform.

Try running in debug mode, it'll show the collision shapes and you might spot the problem just with that. Sometimes it's better to set the sprite shape yourself rather than letting Box2D autoshape it. Especially with the player sprite - you probably want different frames, so usually it's best to just use a general sized rectangle for the player.

I am the one who knocks...
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 10th Jan 2014 21:26
Think I not good Explanation mean. My Player could stand on top of the Floor Sprite. when I use GetPhysicsCollision () function for get collision value (0 or 1) it always show the 0 value. mean there is no collision.
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 10th Jan 2014 22:01
I see. Maybe it's the order that your updating things, could you post some code so we can see what you have so far?

I am the one who knocks...
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 10th Jan 2014 22:23
this is my code :

Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 10th Jan 2014 23:16 Edited at: 10th Jan 2014 23:17
Ahh!

Your checking ground for collision, but that is changed in the for next loop every time, so ground is actually just the 10th sprite. When you do this:

ground=clonesprite(spr2)

It will change the ground number each time, so it loses track of it.

So, if you were to keep track of ground, like using a preset range of sprites, you could check them in turn. One thing, is if your map is sticking to a set grid - like 10x10 blocks, then maybe using a 2D array would be a quick way, you'd set an array to store the sprite number when making the map, then work out which grid positions are around the player, and check them for collision.

I am the one who knocks...
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 12th Jan 2014 20:07 Edited at: 12th Jan 2014 20:13
Quote: "
One thing, is if your map is sticking to a set grid - like 10x10 blocks, then maybe using a 2D array would be a quick way, you'd set an array to store the sprite number when making the map, then work out which grid positions are around the player, and check them for collision.
"


no my map is no grid.there is no another way? However, for make platform games should use CloneSprite() Function and Certainly need set collision. I think should there is a easier way for solve this Problem.
Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 12th Jan 2014 20:17
You can use CloneSprite() if you wish, but what VanB is saying is that you are using the same Sprite handle over and over. What I would do is create a separate handle for each tile... Something like this;

Login to post a reply

Server time is: 2024-11-25 02:52:33
Your offset time is: 2024-11-25 02:52:33