mirror of
https://github.com/Heretek-AI/GDevelop.git
synced 2026-07-21 17:45:25 -04:00
deb802cfec
* For now, this is limited to instances inside custom objects. This will be made available in the future for all instances in scenes if this works well.
76 lines
1.6 KiB
TypeScript
76 lines
1.6 KiB
TypeScript
/*
|
|
* GDevelop JS Platform
|
|
* Copyright 2013-2023 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
|
|
* This project is released under the MIT License.
|
|
*/
|
|
namespace gdjs {
|
|
/** @category Behaviors > Default behaviors */
|
|
export interface Flippable {
|
|
flipX(enable: boolean): void;
|
|
|
|
flipY(enable: boolean): void;
|
|
|
|
isFlippedX(): boolean;
|
|
|
|
isFlippedY(): boolean;
|
|
}
|
|
|
|
/**
|
|
* A behavior that forwards the Flippable interface to its object.
|
|
* @category Behaviors > Default behaviors
|
|
*/
|
|
export class FlippableBehavior
|
|
extends gdjs.RuntimeBehavior
|
|
implements Flippable
|
|
{
|
|
private object: gdjs.RuntimeObject & Flippable;
|
|
|
|
constructor(
|
|
instanceContainer: gdjs.RuntimeInstanceContainer,
|
|
behaviorData,
|
|
owner: gdjs.RuntimeObject & Flippable
|
|
) {
|
|
super(instanceContainer, behaviorData, owner);
|
|
this.object = owner;
|
|
}
|
|
|
|
usesLifecycleFunction(): boolean {
|
|
return false;
|
|
}
|
|
|
|
override applyBehaviorOverriding(behaviorData): boolean {
|
|
// Nothing to update.
|
|
return true;
|
|
}
|
|
|
|
onDeActivate() {}
|
|
|
|
onDestroy() {}
|
|
|
|
doStepPreEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {}
|
|
|
|
doStepPostEvents(instanceContainer: gdjs.RuntimeInstanceContainer) {}
|
|
|
|
flipX(enable: boolean): void {
|
|
this.object.flipX(enable);
|
|
}
|
|
|
|
flipY(enable: boolean): void {
|
|
this.object.flipY(enable);
|
|
}
|
|
|
|
isFlippedX(): boolean {
|
|
return this.object.isFlippedX();
|
|
}
|
|
|
|
isFlippedY(): boolean {
|
|
return this.object.isFlippedY();
|
|
}
|
|
}
|
|
|
|
gdjs.registerBehavior(
|
|
'FlippableCapability::FlippableBehavior',
|
|
gdjs.FlippableBehavior
|
|
);
|
|
}
|