-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
smaller commit this time. just general fixes for now
- Loading branch information
1 parent
e00215d
commit 78657ba
Showing
14 changed files
with
206 additions
and
170 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
Binary file not shown.
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
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,83 @@ | ||
package kec.objects; | ||
|
||
/** | ||
* A Multipurpose Button Useful For Many Menus. | ||
Author : TheRealJake_12 | ||
*/ | ||
class MenuButton extends FlxSprite | ||
{ | ||
public var onClick:() -> Void; | ||
public var onRelease:() -> Void; | ||
public var onHover:() -> Void; | ||
public var onExit:() -> Void; | ||
public var blockInput:Bool = false; | ||
public var targSize:Float = 1.0; | ||
|
||
private var _hoverCheck:Bool = false; | ||
|
||
/** | ||
* An All Purpose Button Used For Main Menu. | ||
* @param x The Starting X Position. | ||
* @param y The Starting Y Position. | ||
* @param image The Image To Load. Has To Be In The `shared/images` Folder. Can Load Any Subfolders From There. | ||
* @param atlas If It Should Look For A SparrowAtlas Instead | ||
*/ | ||
public function new(x:Float, y:Float, image:String = "", ?atlas:Bool = false) | ||
{ | ||
super(x, y); | ||
|
||
onClick = function() | ||
{ | ||
}; | ||
onRelease = function() | ||
{ | ||
}; | ||
onHover = function() | ||
{ | ||
}; | ||
onExit = function() | ||
{ | ||
}; | ||
loadImage(image, atlas); | ||
} | ||
|
||
public function loadImage(path:String, atlas:Bool) | ||
{ | ||
switch (atlas) | ||
{ | ||
case true: | ||
frames = Paths.getSparrowAtlas(path); | ||
case false: | ||
loadGraphic(Paths.image(path)); | ||
} | ||
} | ||
|
||
override function update(elapsed:Float) | ||
{ | ||
super.update(elapsed); | ||
if (blockInput) | ||
return; | ||
|
||
final lerp = CoolUtil.smoothLerp(scale.x, targSize, elapsed, 0.2); | ||
scale.set(lerp, lerp); | ||
|
||
if (FlxG.mouse.overlaps(this) && !_hoverCheck) | ||
{ | ||
_hoverCheck = true; | ||
onHover(); | ||
} | ||
else if (!FlxG.mouse.overlaps(this) && _hoverCheck) | ||
{ | ||
_hoverCheck = false; | ||
onExit(); | ||
} | ||
if (FlxG.mouse.overlaps(this)) | ||
{ | ||
if (FlxG.mouse.justPressed) | ||
onClick(); | ||
else if (FlxG.mouse.justReleased) | ||
onRelease(); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.