Jump to content


Photo

Gm Tween


  • Please log in to reply
41 replies to this topic

#1 SuperSlacker

SuperSlacker

    GMC Member

  • New Member
  • 10 posts

Posted 11 September 2007 - 10:15 PM

Has anyone ever used Adobe Flash, and thought, "I sure wish I could use tweening in Game Maker." Once, I did. From that thought came this extension - GM Tween.

Download it here:
GM Tween

What it does:
  • Allows you to, with one line of code, have any number or color begin a transition from one value to another value over some length of time. If you need to have a menu slide in, a wall slide aside, a shield flash, this will let you do that very easily.

Features:
  • Tweens colors and numbers
  • Supports native easing functions (change the animation speed along its duration) - for example, you might have a menu slide out really quick at first but slow as it gets closer to being all-the-way-in
  • Supports looping tweens for easy animations
  • Pause/resume for, well, pausing and resuming animations.
  • Tweening variables of individual instances, or global variables.
  • Calling a script after the tween is completed.
Let me know what you think!

Edit:
Here's a link to a good explanation of tweening: http://en.wikipedia.org/wiki/Tweening

Edited by SuperSlacker, 01 August 2008 - 04:29 AM.

  • 0

#2 the_doominator

the_doominator

    Eight Star

  • New Member
  • 925 posts

Posted 11 September 2007 - 11:38 PM

What is "tweening"?
  • 0

#3 lukesterspy

lukesterspy

    Robofish

  • GMC Member
  • 762 posts
  • Version:Unknown

Posted 12 September 2007 - 12:31 AM

Yeah, whats "tweening"? Lol, might be an odd question, but I seriously don't know what it means...
  • 0

#4 the_doominator

the_doominator

    Eight Star

  • New Member
  • 925 posts

Posted 12 September 2007 - 12:56 AM

Me neither.....
  • 0

#5 thp

thp

    GMC Member

  • GMC Member
  • 64 posts

Posted 12 September 2007 - 01:01 AM

tweening is taking a shape and having it animated using two key frames instead of having to draw the shape again and move it in every frame.
  • 0

#6 Matt13

Matt13

    GMC Member

  • New Member
  • 580 posts

Posted 12 September 2007 - 01:03 AM

Basically with tweening, you create two key frames and the computer will fill in the missing frames in between.
  • 0

#7 SuperSlacker

SuperSlacker

    GMC Member

  • New Member
  • 10 posts

Posted 12 September 2007 - 03:43 AM

Yep, that's right. Tweening is having the computer fill in the frames to animate a change in a number, or a color, over some number of frames.

For example, say you have an object that you want to move from (30,10) to (70,10) during 30 frames. You could write code to have the object move until it's x position is greater than 70, or with this, you can write:

tween("(object).x", 30, 70, 30);

With this engine, you can also have it change a color (say, the image_blend) from one color to another smoothly. One use of this is having an enemy flash red when it's low on life, or do whatever else you want it to do.
  • 0

#8 Lukearentz

Lukearentz

    My Two Cents

  • New Member
  • 2587 posts

Posted 12 September 2007 - 03:50 AM

For further clarification, Search Motion Tweening in Google.
Anyway i didn't think this would be possible. Did it take a long time to make?
  • 0

#9 SuperSlacker

SuperSlacker

    GMC Member

  • New Member
  • 10 posts

Posted 12 September 2007 - 04:04 AM

It didn't take too long to make, and really isn't that complex.

You can't have pointer variables in GM, but you can execute strings, so all it does is make a new object (OBJECT_TWEEN or something...) and gives it the actions to use the execute_string() function to set the variable passed in to some percentage between start and stop.

Admittedly, it doesn't run super fast when you have 60+ tweens and other stuff going on because of the execute_string() being used so many times, but in some tests I did, they weren't much slower than precompiled code.

For more info, or details, I think the .gml file is in there. It's not commented very well, but it's not super complex. Maybe that's something to add...
  • 0

#10 Kyle_Solo

Kyle_Solo

    GMC Member

  • GMC Member
  • 1071 posts
  • Version:Unknown

Posted 12 September 2007 - 06:52 PM

See this topic.

From what I understand, you could use variable_local_set("variable",value) instead.
  • 0

#11 SuperSlacker

SuperSlacker

    GMC Member

  • New Member
  • 10 posts

Posted 12 September 2007 - 07:16 PM

Does that present the same problems that execute does?

If not, then I'll rewrite the extension.
  • 0

#12 Kyle_Solo

Kyle_Solo

    GMC Member

  • GMC Member
  • 1071 posts
  • Version:Unknown

Posted 12 September 2007 - 08:07 PM

It has no problem that I'm aware of. You can't use it to execute custom code, so it should be safe (as far as safe goes). It is also much faster.
  • 0

#13 SuperSlacker

SuperSlacker

    GMC Member

  • New Member
  • 10 posts

Posted 13 September 2007 - 12:13 AM

OK, it no longer includes any execute_string() functions, and has been re-uploaded. Thanks Kyle_Solo.

And for the time being, the tween_to() and tween_color_to() functions have been removed, because I can't figure out what is going wrong with them. But you can just pass in the current value of a variable easily enough.

Anyway, this should speed things up a bit too.
  • 0

#14 cybot99

cybot99

    GMC Member

  • New Member
  • 190 posts

Posted 23 September 2007 - 12:44 AM

Great extention, but would you be able to release the sorce? I would like to learn from it.

Anyway, keep up the good work
  • 0

#15 SuperSlacker

SuperSlacker

    GMC Member

  • New Member
  • 10 posts

Posted 26 September 2007 - 09:34 PM

The source code is in there as a .gml file. It isn't commented very well, but the code is all there.
  • 0

#16 cybot99

cybot99

    GMC Member

  • New Member
  • 190 posts

Posted 27 September 2007 - 01:19 AM

Thanks greatly.
Credit will given.

Like I said, Keep up the good work.

EDIT: I don't mean to be pain in the bum (so to speak), but could you mirror the download, 'cause I cant seem to download anything from the site.

Edited by cybot99, 27 September 2007 - 01:46 AM.

  • 0

#17 kubaszewczyk11

kubaszewczyk11

    GMC Member

  • New Member
  • 100 posts

Posted 02 February 2008 - 06:55 PM

Yeah, whats "tweening"? Lol, might be an odd question, but I seriously don't know what it means...

<{POST_SNAPBACK}>

When trying to tween 3 and 5 with 3 frames, tween loks like this:
3-4-5
  • 0

#18 grandhighgamer

grandhighgamer

    Village Idiot

  • GMC Member
  • 3708 posts
  • Version:GM:Studio

Posted 02 February 2008 - 07:15 PM

Basically it takes two very different frames and uses interpolation to create an inbetween frame.
  • 0

#19 leif902

leif902

    GreenMan Games

  • New Member
  • 748 posts

Posted 03 February 2008 - 05:50 PM

Good idea
  • 0

#20 Fede-lasse

Fede-lasse

    AI Programmer

  • GMC Member
  • 2009 posts
  • Version:Unknown

Posted 11 July 2008 - 04:08 PM

This is the by far best extension I've seen, yet. Thank you for making this. But some stuff is missing... Here's what you've got to do:
  • Add functionality to pause, resume or stop a tween completely. This could be done using the instance ID, and tell it to do that and that, you know?
  • There seems to be an odd problem when using the tween ease, COS_UP. For some reason, it "inverts" the whole tween, meaning that it starts from the end, and begins tweening towards the start. For now, I've been forced to do complicated stuff, in order to avoid this.

Edited by Fede-lasse, 11 July 2008 - 04:09 PM.

  • 0

#21 SuperSlacker

SuperSlacker

    GMC Member

  • New Member
  • 10 posts

Posted 31 July 2008 - 06:44 AM

OK, it's been a long time since I've been back here, but I updated the tween engine, and, as Fede-lasse advised, added pause/resume/stop tween manipulators. In addition, I added the ability to set the progress of a tween, to set the duration of a tween, and considerably cleaned up the built in easing functions. Now, the names are much less cryptic, and should all work much more reliably. I also added the ability to specify your own functions, but I didn't really test that feature yet, and it's getting late, so I might take a look at that sometime soon.

Hopefully, this is still helpful to someone out there, and if not, well, at least it's still fun to write :P
  • 0

#22 Fede-lasse

Fede-lasse

    AI Programmer

  • GMC Member
  • 2009 posts
  • Version:Unknown

Posted 31 July 2008 - 08:01 AM

There's still something wrong:
- You forgot to state (In the manual) that the tweening functions returned the tween_id
- I didn't find the stars thing a good way to give people an example. It already follows within the ZIP. No need for one in the manual, too :D
- If you are able to set the duration, resume the tween and stuff in runtime, then probably we'll be able to set the tween ease, too? :P

Other than that, it's PERFECT. I wonder why no one actually looks at this.
  • 0

#23 SuperSlacker

SuperSlacker

    GMC Member

  • New Member
  • 10 posts

Posted 01 August 2008 - 04:27 AM

There's still something wrong:
- You forgot to state (In the manual) that the tweening functions returned the tween_id
- I didn't find the stars thing a good way to give people an example. It already follows within the ZIP. No need for one in the manual, too tongue.gif
- If you are able to set the duration, resume the tween and stuff in runtime, then probably we'll be able to set the tween ease, too? biggrin.gif


OK, well, I think this SHOULD fix those problems. The manual has been updated, functions have been added to dynamically change repeat, easing, and (a new feature!), an ending function. Basically, it lets you call a script when the animation is done to perform some other action. It adds a lot of flexibility, and makes this much more like Adobe Flash's tweens. Also, functions are added to get the values of a tweens properties.

And for those of you who actually want to learn how it's used, I added a more comprehensive example. (I guess I shouldn't have counted on my last one, made around 12 at night, to be very helpful. Thanks again for the feedback, and (again), I hope this is somewhat helpful!
  • 1

#24 johnie102

johnie102

    GMC Member

  • New Member
  • 1608 posts

Posted 05 August 2008 - 08:16 PM

I don't have a use for it right now, but I can see how this can be really handy and save a lot of work.
  • 0

#25 Mnementh

Mnementh

    15151

  • GMC Elder
  • 6328 posts
  • Version:GM:Studio

Posted 30 August 2008 - 01:17 AM

I love nothing more in an extension than the ability to know that, if I can think of it, the extension can do it. And I'm happy to say, this extension is all that I could want it to be. Very complete, and I can create and use my own functions for anything that I can think of that isn't included. I especially love the ability to set an ending function, because with it I can easily chain animations.

The only thing that annoys me is the passing of the variable by name. And of course, there's nothing you can do about that.
  • 0

#26 wat_a_noob

wat_a_noob

    GMC Member

  • New Member
  • 129 posts

Posted 27 September 2008 - 02:00 AM

sorry to bug but when i click the dowload link on the page it does nothing how do i download it?
  • 0

#27 wat_a_noob

wat_a_noob

    GMC Member

  • New Member
  • 129 posts

Posted 27 September 2008 - 02:02 AM

sorry bout double post bad internet

Edited by wat_a_noob, 27 September 2008 - 02:13 AM.

  • 0

#28 death-droid

death-droid

    GMC Member

  • GMC Member
  • 2600 posts

Posted 27 September 2008 - 12:18 PM

The link is working perfectly for me.
  • 0

#29 2d_games

2d_games

    GMC Member

  • GMC Member
  • 1498 posts
  • Version:GM8

Posted 29 September 2008 - 10:03 PM

So tweening is similer to Euphoria which you can use to animate things on the fly?

I may have a use for this...
  • 0

#30 Brandan

Brandan

    GMC Member

  • New Member
  • 82 posts

Posted 16 December 2008 - 03:10 PM

Basically with tweening, you create two key frames and the computer will fill in the missing frames in between.


sounds sweet.. Can the same be done but instead of color, image alpha?

EDIT: sry for double post it was an accident ignore this look below for the post i acctully wanted

Edited by Brandan, 16 December 2008 - 03:27 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users