Skip to content

Instantly share code, notes, and snippets.

@djcsdy
Created July 23, 2012 19:39
Show Gist options
  • Save djcsdy/3165730 to your computer and use it in GitHub Desktop.
Save djcsdy/3165730 to your computer and use it in GitHub Desktop.
package;
import flash.MovieClip;
class Bubble {
// Set this to true when the bubble is 'created'.
// Set it to false when the bubble is popped.
public var active:Bool;
var movieClip:MovieClip;
public function new(parentMovieClip:MovieClip) {
active = false;
var depth = parentMovieClip.getNextHighestDepth();
movieClip = parentMovieClip.createEmptyMovieClip("Bubble" + depth, depth);
}
public function update() {
// Call this once per frame to update the Bubble (only if it is active).
}
public function render() {
// Call this once per frame to render the Bubble (only if it is active).
// Draw to movieClip here.
}
}
package;
import flash.MovieClip;
class Main {
static inline var MAX_BUBBLES = 512;
var bubbles:Array<Bubble>;
public function new(display:MovieClip) {
bubbles = [];
for (i in 0...MAX_BUBBLES) {
bubbles.push(Bubble.create(display));
}
}
public function run() {
// Set up a game loop and gameplay logic here
}
static function main() {
new Main(flash.Lib._root).run();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment