Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Simplistic Tween (https://forums.graalonline.com/forums/showthread.php?t=134260288)

Tigairius 08-22-2010 11:36 PM

Simplistic Tween
 
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(valuetimeoldvalnewval) {
  
temp.dist newval oldval;
  
temp.step temp.dist time 0.05;
  
this.( @ value) = oldval;
  
this.trigger("TweenValue"valuetemp.stepnewval);
}

function 
onTweenValue(valuestepnewval) {
  
cancelEvents("TweenValue");
  if (
this.(@ value) == newval) return this.trigger("TweenFinished"value);
  
this.( @ value) += step;
  
scheduleEvent(0.05"TweenValue"valuestepnewval);


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"201);
  
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.

adam 08-23-2010 01:03 AM

Nice. Today I've been working on a more advanced version, but it was only meant to be used on the object I am making though. In principle I could change it to work like that eventually. Once I overcome the problem I'm having grrr....

It supports multiple queued and simultanous actions, when done.

It's a object to show text with/without a background and outline on the screen, planning support for Fading, Moving, Zooming, changing colors of everything, and the text, to be queue'able. Rotating is too hard for text at this point.

adam 08-30-2010 02:57 PM

Still working on a more advanced version. Very similar to my animated text animation, only applicable to every object.


All times are GMT +2. The time now is 03:44 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.