Citrus Engine: Box2d Revolving Platform

This class was officially added to the Citrus Engine on November 26, 2012.

After seeing Lee Brimelow's tutorial on the Citrus Engine, I was intrigued and decided to play around with it. The engine's platformer package is already great and has some very useful objects for game developers. I took a look at the code for the box2d Platform and MovingPlatform classes and extended the functionality to create a RevolvingPlatform class. Anyone that's interested can check out the sample project and download the class below. Here's an example of the class in action.

Arrow keys move - Space bar jumps

RevolvingPlatform class
Example Source (FlashDevelop Project)

Sample Usage

var rot:RevolvingPlatform = new RevolvingPlatform("rev", { x:450, y:200, width:80, height:20, xOffset:60, yOffset:60 } );

The x and y properties determine the center point which the platform will rotate around. The width and height set the size of the platform itself. The xOffset value is the distance the platform will move from the center point along the x axis and yOffset does the same for the y axis. This allows platforms to follow paths other than perfect circles.

Additional properties to set include speed and startAngle. There is a bug with speed which can cause positioning issues if you have multiple platforms rotating around the same point and set the speed to something other than the default (1).

Bookmark and Share

Leave a Reply

Subscribe to RSS feed FGS5 Badge