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
  • 1070 posts

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
  • 1070 posts

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
  • 3117 posts

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users