So I didn't get quite the reaction I expected from my last tweening script, so I've recreated it, in an easy to use/include class library.
It's currently a clientside script but it WILL work serverside, but it looks very bad due to the 0.1 timeout/sleep restriction
A little bit about this script:
I had objectives before writing this class, which are listed at the top of the class in a comment, and I think I've achieved them all
How to use in parallel and blocking:
PHP Code:
//#CLIENTSIDE
function onCreated() {
join("tweening");
this.tweens = NULL; // Make sure there are no tweens in the queue
// Set some NPC Prefs
this.x=10;
this.y=10;
this.image = "block.png";
addTween({
"this.x", // property
this.x+20, // to-value
"easeOutQuad", // easing
100, // steps
"Parallel" // Parallel / Sequence
});
addTween({
"this.y",
this.y+20,
"easeOutBounce",
100,
"Parallel"
});
runTween(0.05); // In blocking mode you need to set the interval
}
How to use in parallel and non-blocking:
PHP Code:
//#CLIENTSIDE
function onCreated() {
join("tweening");
this.tweens = NULL; // Make sure there are no tweens in the queue
// Set some NPC Prefs
this.x=10;
this.y=10;
this.image = "block.png";
addTween({
"this.x", // property
this.x+20, // to-value
"easeOutQuad", // easing
100, // steps
"Parallel" // Parallel / Sequence
});
addTween({
"this.y",
this.y+20,
"easeOutBounce",
100,
"Parallel"
});
setTimer(0.05);
}
function onTimeout() {
// Your script does it's other functions here
setTimer(0.05);
runTween(); // runTween must go after the setTimer to catch the timeout var
}
How to use in sequence and blocking:
PHP Code:
//#CLIENTSIDE
function onCreated() {
join("tweening");
this.tweens = NULL; // Make sure there are no tweens in the queue
// Set some NPC Prefs
this.x=10;
this.y=10;
this.image = "block.png";
addTween({
"this.x", // property
this.x+20, // to-value
"easeOutQuad", // easing
100, // steps
"Sequence" // Parallel / Sequence
});
addTween({
"this.y",
this.y+20,
"easeOutBounce",
100,
"Sequence"
});
runTween(0.05);
}
How to use in sequence and non-blocking:
PHP Code:
//#CLIENTSIDE
function onCreated() {
join("tweening");
this.tweens = NULL; // Make sure there are no tweens in the queue
// Set some NPC Prefs
this.x=10;
this.y=10;
this.image = "block.png";
addTween({
"this.x", // property
this.x+20, // to-value
"easeOutQuad", // easing
100, // steps
"Sequence" // Parallel / Sequence
});
addTween({
"this.y",
this.y+20,
"easeOutBounce",
100,
"Sequence"
});
setTimer(0.05);
}
function onTimeout() {
// Your script does it's other functions here
setTimer(0.05);
runTween(); // runTween must go after the setTimer to catch the timeout var
}
The examples in the video below (also find a link to a higher-def version on the youtube page) are Parallel and Blocking but as you can see it's very easy to make changes and use different variables.
Enjoy