Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-22-2010, 11:36 PM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
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.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”

Last edited by Tigairius; 08-22-2010 at 11:52 PM..
Reply With Quote
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:58 PM.


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