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

- Added timeScale #110

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
40 changes: 39 additions & 1 deletion src/motion/Actuate.hx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,45 @@ class Actuate {
}

#end


public static var timeScale(get, set):Float;
private static var _timeScale:Float = 1.0;

private static function get_timeScale():Float
{
return _timeScale;
}

private static function set_timeScale(value:Float):Float
{
_timeScale = value;

#if neko

for (library in methodLibraries) {

for (actuator in library) {

actuator.timeScale = value;

}

}

#end

for (library in targetLibraries) {

for (actuator in library) {

actuator.timeScale = value;

}

}

return value;
}

private static function getLibrary<T> (target:T, allowCreation:Bool = true):Array<IGenericActuator> {

Expand Down
23 changes: 18 additions & 5 deletions src/motion/actuators/GenericActuator.hx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import motion.Actuate;


class GenericActuator<T> implements IGenericActuator {



public var timeScale(get, set):Float;
private var _timeScale:Float = 1.0;

private var duration:Float;
private var id:String;
private var properties:Dynamic;
Expand All @@ -36,7 +38,8 @@ class GenericActuator<T> implements IGenericActuator {


public function new (target:T, duration:Float, properties:Dynamic) {


_timeScale = Actuate.timeScale;
_autoVisible = true;
_delay = 0;
_reflect = false;
Expand Down Expand Up @@ -452,6 +455,16 @@ class GenericActuator<T> implements IGenericActuator {


}



private function get_timeScale():Float
{
return _timeScale;
}

private function set_timeScale(value:Float):Float
{
_timeScale = value;

return value;
}
}
4 changes: 2 additions & 2 deletions src/motion/actuators/IGenericActuator.hx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,6 @@ interface IGenericActuator {
private function pause ():Void;
private function resume ():Void;
private function stop (properties:Dynamic, complete:Bool, sendEvent:Bool):Void;


var timeScale(get, set):Float;
}
2 changes: 1 addition & 1 deletion src/motion/actuators/SimpleActuator.hx
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ class SimpleActuator<T, U> extends GenericActuator<T> {
var easing:Float;
var i:Int;

var tweenPosition:Float = (currentTime - timeOffset) / duration;
var tweenPosition:Float = (currentTime - timeOffset) * _timeScale / duration;

if (tweenPosition > 1) {

Expand Down