I am looking for a way to tween between any two values (for example an objects position, but it could be anything else, perhaps an .alpha value or otherwise) in a JS code block.
that I could initialise with a starting and end value
that I could get a function() method that executes for each ‘tick’ on its way
that I could get a callback() method when it completes
that I could have a method to .cancel/stop the tween event midway if needed.
Is there such a way ? any examples around that do this ?
I have added ‘tween’ behaviour to an object, and can use the tween commands in the event manager, but i want to force an object to initiate/stop tweens in the JS code, anyone know how to reference these tween behaviours from code ?
Just found out how. The object must have a tween behavior attached.
// get object by its name
const obj = runtimeScene.getObjects(objectName)[0];
// get attached tween behavior
let tween = obj.getBehavior("Tween");
// create a tween identifier using the object name
const tweenYName = obj.name + "PositionYTween";
// run the tween
tween.addObjectPositionYTween(tweenYName, 2000, "linear", 1000, false);
I started to play with GDevelop recently. Don’t know how much it changed since 3 years ago, but I agree that a lot of questions remained unanswered. Glad I could help.