Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 05-09-2008, 02:50 AM
Robin Robin is offline
The secret of NIMH
Robin's Avatar
Join Date: Apr 2005
Location: Wales, UK
Posts: 515
Robin will become famous soon enough
Send a message via AIM to Robin
Tweening 2.0

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

Attached Files
File Type: txt Tween2.txt (6.2 KB, 396 views)
__________________

Reply With Quote
 


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 01:45 AM.


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