Author Topic: Rotate A Platform  (Read 1102 times)

shaolin

  • Member
  • **
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Rotate A Platform
« on: Mon, Sep 13, 2010 »
I'm a newbie to Flixel so this may seem like a stupid question. I'm making a platformer game and I'm wanting to rotate certain platforms so that they are on an angle (roughly by 30 degrees). I currently have two platforms side by side, and I want the player to walk from a horizontal platform to an angled platform.
Both of these platforms are rectangular of the same length and are 'Sprites'.

How can I rotate the second platform to a specific angle, and have that rotated sprite collide with the player?

Thanks for any help in advance :D.
« Last Edit: Tue, Sep 14, 2010 by shaolin »

hamedn

  • Member
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
Re: Rotate A Platform
« Reply #1 on: Tue, Sep 14, 2010 »
Flixel doesn't support that level of physics.

initials

  • Contributor
  • ****
  • Posts: 378
  • Karma: +0/-0
  • Initials
    • View Profile
    • Initials Blog. Code and other things.
Re: Rotate A Platform
« Reply #2 on: Tue, Sep 14, 2010 »
My understanding is that quad-tree, which is doing the collision detection works using bounding boxes.
So using rotated boxes will just cause the bounding box to still be box at that isn't rotated.

The Mode demo has "B" set to show bounding boxes. Maybe try showing bounding boxes in your game, and you'll see what happens when you rotate something.
Initials: Super Lemonade Factory, Super Lemonade Factory Part Two, Above The Clouds, Revvolvver, Four Chambers of the Human Heart

Garmichael

  • Member
  • **
  • Posts: 89
  • Karma: +0/-0
    • View Profile
Re: Rotate A Platform
« Reply #3 on: Wed, Sep 15, 2010 »
Maybe you can do it like this:

1) Make the platform a sprite.
2) Use the tutorials to set up the collision so when the character is standing on it, the character 'snaps' to the surface of the platform. Use the Pixel Perfect Collision package found somewhere in this forum to handle the overlap. You'll want to use overlapPP
3) Create a variable called AlignedAngle in your character's class that is a reference to the angle of the platform it's standing on.
4) Factor in this variable when adjusting the movement in Key.LEFT and Key.RIGHT scripts and use trig. Normally AlignedAngle is equal to zero, but when the character is touching a rotated platform, AlignedAngle is equal to that platforms angle.
5) Set the character's angle to match the AlignedAngle