-
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.
FlxSkewedSprite: bigger hd grass graphics (#312)
* bigger hd grass graphics * fix flash
- Loading branch information
Showing
5 changed files
with
48 additions
and
42 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 |
---|---|---|
@@ -1,45 +1,41 @@ | ||
package; | ||
|
||
import flixel.addons.effects.FlxSkewedSprite; | ||
import flixel.FlxG; | ||
import flixel.addons.effects.FlxSkewedSprite; | ||
|
||
/** | ||
* @author Zaphod | ||
*/ | ||
class Grass extends FlxSkewedSprite | ||
{ | ||
public var maxSkew:Float = 30; | ||
public var minSkew:Float = -30; | ||
public var skewSpeed:Float = 15; | ||
|
||
var _skewDirection:Int = 1; | ||
|
||
public function new(X:Float = 0, Y:Float = 0, Frame:Int = 0, StartSkew:Float = 0) | ||
static public inline var SKEW_MAX = 10; | ||
static public inline var SKEW_MIN = -30; | ||
static public inline var SKEW_FREQ = 1.3; | ||
var time:Float; | ||
public function new(x = 0.0, y = 0.0, frame = 0, timeOffset = 0.0) | ||
{ | ||
super(X, Y); | ||
|
||
loadGraphic("assets/grass.png", true, 300, 28); | ||
animation.frameIndex = Frame; | ||
|
||
this.time = timeOffset * SKEW_FREQ; | ||
super(x, y); | ||
|
||
if (frame < 0) | ||
loadGraphic("assets/grass.png"); | ||
else | ||
{ | ||
loadGraphic("assets/grass.png", true, 600, 56); | ||
animation.frameIndex = frame; | ||
} | ||
|
||
origin.set(0, height); | ||
antialiasing = true; | ||
skew.x = StartSkew; | ||
} | ||
|
||
override public function update(elapsed:Float):Void | ||
{ | ||
super.update(elapsed); | ||
|
||
skew.x += _skewDirection * skewSpeed * elapsed; | ||
|
||
if (skew.x > maxSkew) | ||
{ | ||
skew.x = maxSkew; | ||
_skewDirection = -1; | ||
} | ||
else if (skew.x < minSkew) | ||
{ | ||
skew.x = minSkew; | ||
_skewDirection = 1; | ||
} | ||
time += elapsed; | ||
|
||
skew.x = SKEW_MIN + (Math.cos(time / SKEW_FREQ * Math.PI) + 1) / 2 * (SKEW_MAX - SKEW_MIN); | ||
} | ||
} |
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
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