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

Supporting properties for motion path actuactors. Also adding the sta… #15

Merged
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
36 changes: 25 additions & 11 deletions src/motion/actuators/MotionPathActuator.hx
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,38 @@ class MotionPathActuator<T> extends SimpleActuator<T, T> {
}

private override function initialize() {
super.initialize();

// "x" and "y" are handled by `super.initialize()`, but there's custom behavior for those properties below,
// so we need to remove the details and rebuild them.
propertyDetails = [
for (detail in propertyDetails) {
if (detail.propertyName == "x" || detail.propertyName == "y") continue;
detail;
}
];
detailsLength = propertyDetails.length;

var details:PropertyPathDetails<T>;
var path:IComponentPath;

for (propertyName in Reflect.fields(properties)) {
path = cast(Reflect.field(properties, propertyName), IComponentPath);
if (propertyName == "x" || propertyName == "y") {
path = cast(Reflect.field(properties, propertyName), IComponentPath);

if (path != null) {
var isField = true;
if (path != null) {
var isField = true;

if (Reflect.hasField(target, propertyName)) {
path.start = Reflect.field(target, propertyName);
} else {
isField = false;
path.start = Reflect.getProperty(target, propertyName);
}
if (Reflect.hasField(target, propertyName)) {
path.start = Reflect.field(target, propertyName);
} else {
isField = false;
path.start = Reflect.getProperty(target, propertyName);
}

details = new PropertyPathDetails(target, propertyName, path, isField);
propertyDetails.push(details);
details = new PropertyPathDetails(target, propertyName, path, isField);
propertyDetails.push(details);
}
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/motion/actuators/SimpleActuator.hx
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,11 @@ class SimpleActuator<T, U> extends GenericActuator<T> {

tweenPosition = (currentTime - timeOffset) / duration;

var startAt = getField(properties, "startAt");
if (startAt != null) {
tweenPosition += startAt;
}

if (tweenPosition > 1) {
tweenPosition = 1;
}
Expand Down
Loading