I asked for some tweening capabilities to GS2 recently. I am not sure if it will be added, but here is a simple version of what I would like. This is functioning with one tween at a time and doesn't support multiple tweens.
Join the class to your object, then call
this.tween(value, time, startval, endval);
Class:
PHP Code:
//#CLIENTSIDE
function tween(value, time, oldval, newval) {
temp.dist = newval - oldval;
temp.step = temp.dist / time * 0.05;
this.( @ value) = oldval;
this.trigger("TweenValue", value, temp.step, newval);
}
function onTweenValue(value, step, newval) {
cancelEvents("TweenValue");
if (this.(@ value) == newval) return this.trigger("TweenFinished", value);
this.( @ value) += step;
scheduleEvent(0.05, "TweenValue", value, step, newval);
}
Example of its use in a level npc:
PHP Code:
//#CLIENTSIDE
function onCreated() {
join("plugin_tween");
this.image = "block.png";
this.mode = 1;
tweenobject();
}
function tweenobject() {
this.tween("alpha", 2, 0, 1);
waitfor(this, "TweenFinished");
player.chat = "Finished";
}
The above script will transition the block's alpha from 0 to 1 over 2 seconds. When the tween is finished it will invoke onTweenFinished(value).
This can also be used serverside, but you will have to change the 0.05 to 0.1 in the class (note there are two instances of 0.05).
See my post here for more information:
http://forums.graalonline.com/forums...hp?t=134260208
Please note to Stefan: I would still like this to be added into GScript2.