Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #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, 395 views)
__________________

Reply With Quote
  #2  
Old 05-09-2008, 02:53 AM
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
I am very impressed, Robin. Good job.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #3  
Old 05-09-2008, 02:54 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
Quote:
Originally Posted by Tigairius View Post
I am very impressed, Robin. Good job.
People should use it!
__________________

Reply With Quote
  #4  
Old 05-09-2008, 02:58 AM
MysticalDragon MysticalDragon is offline
Global Administration
MysticalDragon's Avatar
Join Date: Oct 2002
Location: Lynn Ma
Posts: 883
MysticalDragon is a jewel in the roughMysticalDragon is a jewel in the rough
Send a message via AIM to MysticalDragon Send a message via MSN to MysticalDragon
Amazing congrats mate.
__________________
~Delteria Support
~Playerworld Support
~PWA Chief
http://support.toonslab.com
[email protected]



Reply With Quote
  #5  
Old 05-09-2008, 02:58 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Very dramatic video, not bad script either.

I will try this some time, it looks awesome.

Great job
__________________
Reply With Quote
  #6  
Old 05-09-2008, 03:05 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
The response pleases me somewhat this time round

It was the video proof wasn't it? :P
__________________

Reply With Quote
  #7  
Old 05-09-2008, 03:10 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Robin View Post
The response pleases me somewhat this time round

It was the video proof wasn't it? :P
Of course, "tween" means nothing to most of us (I knew what it meant; didn't realize that you meant to completely replicate something like Flash's tweening)
__________________
Reply With Quote
  #8  
Old 05-09-2008, 03:55 AM
Rapidwolve24 Rapidwolve24 is offline
North*
Join Date: Oct 2007
Location: Massachusetts
Posts: 178
Rapidwolve24 is on a distinguished road
Send a message via AIM to Rapidwolve24 Send a message via MSN to Rapidwolve24
I think the name "tweening" turns people off.
Reply With Quote
  #9  
Old 05-09-2008, 04:12 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
Quote:
Originally Posted by cbkbud View Post
Of course, "tween" means nothing to most of us (I knew what it meant; didn't realize that you meant to completely replicate something like Flash's tweening)
Well a tween is just a transition really.

Quote:
Originally Posted by Rapidwolve24 View Post
I think the name "tweening" turns people off.
Dirteh dirteh boy
__________________

Reply With Quote
  #10  
Old 05-09-2008, 07:41 AM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Good job, looks nice!
__________________
Do it with a DON!
Reply With Quote
  #11  
Old 05-09-2008, 10:48 AM
Dan Dan is offline
Daniel
Join Date: Oct 2007
Posts: 383
Dan is an unknown quantity at this point
Send a message via MSN to Dan
Nice
__________________
Reply With Quote
  #12  
Old 05-09-2008, 03:05 PM
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
Yarr I like it. It's free for anyone to use too, but if you use it leave a note in this thread
__________________

Reply With Quote
  #13  
Old 05-09-2008, 03:18 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Nice script Robin
__________________
Reply With Quote
  #14  
Old 05-09-2008, 06:01 PM
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
Thanks chompy

I never really thought that this was a replication of Flash's motion tweening to be honest, but I guess it really does act in a very similar manner, although it does not take into account flash's timeline and such. More over it has it's own internal timeline.

I'm going to keep working on this, and if anyone has any ideas for optimising or improving let me know!
__________________

Reply With Quote
  #15  
Old 05-10-2008, 07:06 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
I have an off-topic question: What did you use to record your screen?
__________________
Reply With Quote
Reply


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 09:47 PM.


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