|Hosting by PhotoTangler Collage Maker|
Question submitted by (18 November 1999)
|Return to The Archives|
|It's pretty standard to see "flying" platforms in side scrollers that upon landing/stepping on, the sprite moves along with it. This is a feature I've never got to work quite right. First, you have to determine when the player is actually on the platform, and then somehow attaching him to it. I'm not using a tile map, but rather sprites for one. Any idea how this works?|
First you will need to check for the collision of the floating (moving)
platform, and for this you can usually use a bounding box which is a
rectangle made of the furthest edges of the platform. Then you do a simple
test to see if the character is touching the rectangle or not. When he is
you will want to lock the character to the rectangle by giving him a flag
that says "hes on moving platform X", where X can be the number of the
moving platform in the level. Then you can assign the character an offset
to the far upper-left corner of the bounding box and move the characters
position in relation to the bounding box, instead of the tile-map (or
however you normally track character movement).
Response provided by Geoff Howland
This article was originally an entry in flipCode's Fountain of Knowledge, an open Question and Answer column that no longer exists.