Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #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
  #2  
Old 08-23-2010, 01:03 AM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
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.
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
  #3  
Old 08-30-2010, 02:57 PM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
Still working on a more advanced version. Very similar to my animated text animation, only applicable to every object.
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
Reply

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 07:25 PM.


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