-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* messing around with pixel perfect check * beauty changes * debug drawing * disable origin * delete TestState * remove whoopsies * remove offset/origin stuff * remove debug info
- Loading branch information
Showing
6 changed files
with
300 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import flixel.FlxG; | ||
import flixel.FlxSprite; | ||
import flixel.tweens.FlxEase; | ||
import flixel.tweens.FlxTween; | ||
|
||
class Alien extends DemoSprite | ||
{ | ||
var collides:Bool = false; | ||
|
||
public function new() | ||
{ | ||
super(); | ||
|
||
// set dance dance interstellar animations | ||
loadGraphic("assets/alien.png", true); | ||
/* | ||
* WebGL has trouble displaying large number of sprites with dynamic coloring, | ||
* so we switch bewteen two similar animations with different colors. | ||
*/ | ||
var fps = FlxG.random.int(6, 10); | ||
animation.add("dance_off", [0, 1, 0, 2], fps); | ||
animation.add("dance_on", [3, 4, 3, 5], fps); | ||
animation.play("dance_off"); // dance! | ||
} | ||
|
||
/** | ||
* Randomize position, scrollFactor, velocity and alpha. | ||
*/ | ||
public function randomize() | ||
{ | ||
var ran = FlxG.random; | ||
x = ran.int(0, Std.int(FlxG.width - width)) + FlxG.camera.scroll.x; | ||
y = ran.int(0, Std.int(FlxG.height - height)) + FlxG.camera.scroll.y; | ||
alpha = ran.float(0.1, 1.0); | ||
scrollFactor.x = alpha; | ||
// negate the x-offset caused from scrollFactor | ||
x += FlxG.camera.scroll.x * (scrollFactor.x - 1); | ||
velocity.set(-ran.float(5, 25), 0); | ||
|
||
// Neat tweening effect for new aliens appearing | ||
var toY = y; | ||
y = (y < FlxG.height / 2) ? -20 : FlxG.height + 20; | ||
FlxTween.tween(this, {y: toY}, 1.0, { ease: FlxEase.expoOut, startDelay: ran.float() * 0.5 }); | ||
} | ||
|
||
/** | ||
* Switches the between the red/white color to show whether an overlap is occurring. | ||
* @param value | ||
*/ | ||
override function setCollides(value:Bool) | ||
{ | ||
if (value != collides) | ||
{ | ||
collides = value; | ||
var frame = animation.curAnim.curFrame; | ||
animation.play("dance_" + (collides ? "on" : "off"), false, false, frame); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import flixel.FlxG; | ||
import flixel.FlxObject; | ||
import flixel.FlxSprite; | ||
import flixel.math.FlxRect; | ||
|
||
class DemoSprite extends FlxSprite | ||
{ | ||
public function new (x = 0.0, y = 0.0) | ||
{ | ||
super(x, y); | ||
} | ||
|
||
/** | ||
* Switches the between the red/white color to show whether an overlap is occurring. | ||
*/ | ||
public function setCollides(value:Bool) | ||
{ | ||
color = value ? 0xFFac3232 : 0xFF6abe30; | ||
} | ||
|
||
public function resetAngle() | ||
{ | ||
angle = 0; | ||
angularVelocity = 0; | ||
} | ||
|
||
public function resetScale() | ||
{ | ||
scale.set(1, 1); | ||
} | ||
|
||
public function randomAngle() | ||
{ | ||
angle = FlxG.random.float() * 360; | ||
angularVelocity = FlxG.random.float(50, 100); | ||
} | ||
|
||
public function randomScale() | ||
{ | ||
scale.x = FlxG.random.float(0.5, 2.0); | ||
scale.y = scale.x; | ||
} | ||
|
||
#if debug | ||
override function draw() | ||
{ | ||
// For debugging | ||
// drawDebugScreenBounds(); | ||
|
||
super.draw(); | ||
} | ||
|
||
function drawDebugScreenBounds() | ||
{ | ||
for (camera in cameras) | ||
{ | ||
var rect = getScreenBounds(camera); | ||
var gfx = beginDrawDebug(camera); | ||
// fill static graphics object with square shape | ||
gfx.lineStyle(1, 0x0000ff, 0.5); | ||
gfx.drawRect(rect.x, rect.y, rect.width, rect.height); | ||
endDrawDebug(camera); | ||
} | ||
} | ||
#end | ||
} |
Oops, something went wrong.