Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add analog directional input to FlxVirtualPad #3340

Open
wants to merge 27 commits into
base: release6
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion flixel/FlxCamera.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ class FlxCamera extends FlxBasic
if (deadzone == null)
{
target.getMidpoint(_point);
_point.addPoint(targetOffset);
_point.add(targetOffset);
_scrollTarget.set(_point.x - width * 0.5, _point.y - height * 0.5);
}
else
Expand Down
18 changes: 9 additions & 9 deletions flixel/FlxSprite.hx
Original file line number Diff line number Diff line change
Expand Up @@ -833,11 +833,11 @@ class FlxSprite extends FlxObject
@:noCompletion
function drawSimple(camera:FlxCamera):Void
{
getScreenPosition(_point, camera).subtractPoint(offset);
getScreenPosition(_point, camera).subtract(offset);
if (isPixelPerfectRender(camera))
_point.floor();

_point.copyToFlash(_flashPoint);
_point.copyTo(_flashPoint);
camera.copyPixels(_frame, framePixels, _flashRect, _flashPoint, colorTransform, blend, antialiasing);
}

Expand All @@ -856,7 +856,7 @@ class FlxSprite extends FlxObject
_matrix.rotateWithTrig(_cosAngle, _sinAngle);
}

getScreenPosition(_point, camera).subtractPoint(offset);
getScreenPosition(_point, camera).subtract(offset);
_point.add(origin.x, origin.y);
_matrix.translate(_point.x, _point.y);

Expand Down Expand Up @@ -1122,11 +1122,11 @@ class FlxSprite extends FlxObject

result.subtract(worldPoint.x, worldPoint.y);
result.negate();
result.addPoint(offset);
result.subtractPoint(origin);
result.add(offset);
result.subtract(origin);
result.scale(1 / scale.x, 1 / scale.y);
result.degrees -= angle;
result.addPoint(origin);
result.add(origin);

worldPoint.putWeak();

Expand All @@ -1148,11 +1148,11 @@ class FlxSprite extends FlxObject

result.subtract(screenPoint.x, screenPoint.y);
result.negate();
result.addPoint(offset);
result.subtractPoint(origin);
result.add(offset);
result.subtract(origin);
result.scale(1 / scale.x, 1 / scale.y);
result.degrees -= angle;
result.addPoint(origin);
result.add(origin);

screenPoint.putWeak();

Expand Down
2 changes: 1 addition & 1 deletion flixel/graphics/frames/FlxAtlasFrames.hx
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ class FlxAtlasFrames extends FlxFramesCollection

override public function addBorder(border:FlxPoint):FlxAtlasFrames
{
var resultBorder = FlxPoint.weak().addPoint(this.border).addPoint(border);
var resultBorder = FlxPoint.weak().add(this.border).add(border);
var atlasFrames = FlxAtlasFrames.findFrame(parent, resultBorder);
if (atlasFrames != null)
return atlasFrames;
Expand Down
4 changes: 2 additions & 2 deletions flixel/graphics/frames/FlxBitmapFont.hx
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ class FlxBitmapFont extends FlxFramesCollection
final h:Float = charFrame.sourceSize.y + (offset != null && offset.y > 0 ? offset.y : 0);
charFrame.sourceSize.set(w, h);
if (offset != null)
charFrame.offset.addPoint(offset);//calls putWeak
charFrame.offset.add(offset);//calls putWeak
charFrame.name = charName;
pushFrame(charFrame, true);
charMap.set(charCode, charFrame);
Expand Down Expand Up @@ -536,7 +536,7 @@ class FlxBitmapFont extends FlxFramesCollection

override public function addBorder(border:FlxPoint):FlxBitmapFont
{
var resultBorder:FlxPoint = FlxPoint.weak().addPoint(this.border).addPoint(border);
var resultBorder:FlxPoint = FlxPoint.weak().add(this.border).add(border);

var font:FlxBitmapFont = FlxBitmapFont.findFont(frame, resultBorder);
if (font != null)
Expand Down
6 changes: 3 additions & 3 deletions flixel/graphics/frames/FlxFrame.hx
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ class FlxFrame implements IFlxDestroyable

if (angle == FlxFrameAngle.ANGLE_0)
{
offset.copyToFlash(_point);
offset.copyTo(_point);
if (point != null)
_point.offset(point.x, point.y);

Expand Down Expand Up @@ -521,7 +521,7 @@ class FlxFrame implements IFlxDestroyable
else
{
frameToFill.type = FlxFrameType.REGULAR;
frameToFill.offset.set(frameRect.x, frameRect.y).subtract(rect.x, rect.y).addPoint(offset);
frameToFill.offset.set(frameRect.x, frameRect.y).subtract(rect.x, rect.y).add(offset);

final p1 = FlxPoint.weak(frameRect.x, frameRect.y);
final p2 = FlxPoint.weak(frameRect.right, frameRect.bottom);
Expand Down Expand Up @@ -623,7 +623,7 @@ class FlxFrame implements IFlxDestroyable
else
{
clippedFrame.type = FlxFrameType.REGULAR;
clippedFrame.offset.set(frameRect.x, frameRect.y).addPoint(offset);
clippedFrame.offset.set(frameRect.x, frameRect.y).add(offset);

var p1 = FlxPoint.weak(frameRect.x, frameRect.y);
var p2 = FlxPoint.weak(frameRect.right, frameRect.bottom);
Expand Down
2 changes: 1 addition & 1 deletion flixel/graphics/frames/FlxImageFrame.hx
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class FlxImageFrame extends FlxFramesCollection

override public function addBorder(border:FlxPoint):FlxImageFrame
{
var resultBorder:FlxPoint = FlxPoint.weak().addPoint(this.border).addPoint(border);
var resultBorder:FlxPoint = FlxPoint.weak().add(this.border).add(border);

var imageFrame:FlxImageFrame = FlxImageFrame.findFrame(parent, frame.frame, resultBorder);
if (imageFrame != null)
Expand Down
2 changes: 1 addition & 1 deletion flixel/graphics/frames/FlxTileFrames.hx
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ class FlxTileFrames extends FlxFramesCollection

override public function addBorder(border:FlxPoint):FlxTileFrames
{
var resultBorder:FlxPoint = FlxPoint.get().addPoint(this.border).addPoint(border);
var resultBorder:FlxPoint = FlxPoint.get().add(this.border).add(border);
var resultSize:FlxPoint = FlxPoint.get().copyFrom(tileSize).subtract(2 * border.x, 2 * border.y);
var tileFrames:FlxTileFrames = FlxTileFrames.findFrame(parent, resultSize, region, atlasFrame, tileSpacing, resultBorder);
if (tileFrames != null)
Expand Down
9 changes: 9 additions & 0 deletions flixel/input/actions/FlxActionInputAnalog.hx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ enum abstract FlxAnalogState(Int) from Int
var STOPPED = cast FlxInputState.RELEASED; // is 0
var MOVED = cast FlxInputState.PRESSED; // is !0
var JUST_MOVED = cast FlxInputState.JUST_PRESSED; // became !0 on this frame

public var moved(get, never):Bool;
inline function get_moved() return this == MOVED || justMoved;
public var justMoved(get, never):Bool;
inline function get_justMoved() return this == JUST_MOVED;
public var justStopped(get, never):Bool;
inline function get_justStopped() return this == JUST_STOPPED;
public var stopped(get, never):Bool;
inline function get_stopped() return this == STOPPED || justStopped;
}

/**
Expand Down
12 changes: 12 additions & 0 deletions flixel/math/FlxMath.hx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,18 @@ class FlxMath
{
return a + ratio * (b - a);
}

/**
* Adjusts the given lerp to account for the time that has passed
*
* @param lerp The ratio to lerp in 1/60th of a second
* @param elapsed The amount of time that has actually passed
* @since 6.0.0
*/
public static function getElapsedLerp(lerp:Float, elapsed:Float):Float
{
return 1.0 - Math.pow(1.0 - lerp, elapsed * 60);
}

/**
* Checks if number is in defined range. A null bound means that side is unbounded.
Expand Down
Loading
Loading