Jump to content


Photo

Animating with code (skew/warp)


  • Please log in to reply
7 replies to this topic

#1 Tommo020788

Tommo020788

    GMC Member

  • New Member
  • 67 posts

Posted 12 June 2012 - 12:23 PM

Hi there,
I would like to start learning to make simple animation using code, rather than animating everything manually all the time,
particularly because this technique would save allot on the file size...

I am trying to animate a title, to wobble side to side using skew on the top two corners to tilt it side to side, giving it a waving appearance.

I know I know.... you probably have no idea what I'm trying to describe above, so I have made a quick little frame by frame example: Sample Sprite (right click and download)

Take a look at that sprite, and you will know what I am trying to achieve.
I want to achieve this using 1 image, and a code to skew/warp it to create the same animated effect.


Has anyone seen this done before?
And would someone be able to offer some kind of sample code please?


For those who don't have the capability to open a gmspr file, here is a strip animation:
Posted Image

Edited by Tommo020788, 12 June 2012 - 12:55 PM.

  • 0

#2 Misu

Misu

    Awesometasticness!

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

Posted 12 June 2012 - 12:50 PM

Yes, I have. To animate text, you need to program variables that increase/decrease, to form a scheme. For your case, you can use draw_text_ext() for animate your text but you need to use variables to create an animation(switching from one number to the other to create animation). You can use step event or alarm event to detect whther to change the value of the variable for creating a new scale or skew.
  • 0

#3 dannyjenn

dannyjenn

    GMC Member

  • GMC Member
  • 2067 posts
  • Version:Mac

Posted 12 June 2012 - 12:51 PM

Can you post it as a gif (or strip)? I don't know how to open gmspr files (I use GM7 if that makes any difference)
You may be in luck because by coincedence I just wrote some code yesterday that does exactly what I think you're describing. I'll post it once I see that it is in fact what you are looking for.
  • 0

#4 Tommo020788

Tommo020788

    GMC Member

  • New Member
  • 67 posts

Posted 12 June 2012 - 12:54 PM

Can you post it as a gif (or strip)? I don't know how to open gmspr files (I use GM7 if that makes any difference)
You may be in luck because by coincedence I just wrote some code yesterday that does exactly what I think you're describing. I'll post it once I see that it is in fact what you are looking for.


Hi,
Here is the strip you asked for:
Posted Image
  • 0

#5 dannyjenn

dannyjenn

    GMC Member

  • GMC Member
  • 2067 posts
  • Version:Mac

Posted 12 June 2012 - 01:00 PM


Can you post it as a gif (or strip)? I don't know how to open gmspr files (I use GM7 if that makes any difference)
You may be in luck because by coincedence I just wrote some code yesterday that does exactly what I think you're describing. I'll post it once I see that it is in fact what you are looking for.


Hi,
Here is the strip you asked for:
Posted Image

Okay, that's not exactly what my code does but I can try editing my code.
One question though... what version of Game Maker are you using? I just realized that my code does not work for Lite on PC, so unless I can figure out another way of doing it then you're out of luck. Sorry.
  • 0

#6 Tommo020788

Tommo020788

    GMC Member

  • New Member
  • 67 posts

Posted 12 June 2012 - 01:48 PM



Can you post it as a gif (or strip)? I don't know how to open gmspr files (I use GM7 if that makes any difference)
You may be in luck because by coincedence I just wrote some code yesterday that does exactly what I think you're describing. I'll post it once I see that it is in fact what you are looking for.


Hi,
Here is the strip you asked for:
Posted Image

Okay, that's not exactly what my code does but I can try editing my code.
One question though... what version of Game Maker are you using? I just realized that my code does not work for Lite on PC, so unless I can figure out another way of doing it then you're out of luck. Sorry.


Hi,
I am using GM8 pro.
So no problems there :)

I look forward to seeing your code! :D
  • 0

#7 Tommo020788

Tommo020788

    GMC Member

  • New Member
  • 67 posts

Posted 13 June 2012 - 12:48 AM

Well It looked like I was going to get an answer then for a minute... but I guess not.
Anyone else have a solution? :mellow:
  • 0

#8 dannyjenn

dannyjenn

    GMC Member

  • GMC Member
  • 2067 posts
  • Version:Mac

Posted 13 June 2012 - 02:45 AM

Sorry, I was having problems making the file. It turned out to be a lot more complicated than I thought... my old code that I was editing only involved changing the x coordinates and everything was parallel so it was easier but I had to add a ton of stuff to the new code.
Anyway, I've made an example... not sure if it works since I don't have GM8.1 Pro but it worked on my Mac.
http://kulukuku.webs.com/warp6.gm81
I did not make any comments and it is probably confusing / hard to read... but at least you now know it is possible and maybe you can see how I did it. Maybe I'll go back later and fix it up.
The downside is that most of it is hard-coded... you will only be able to warp a single sprite with this code unless you edit it. That is until I fix the code up some, if I decide to.
But the way it works is that the code in the room creation will take the sprite called spr_test and it will create a new sprite called global.spr_ftemp which can be used like any other sprite (in the draw event or set sprite_index to it). Also it adds a little to the loading time... if the code is used after the game has already started then it'll freeze the game for about a second :(

Edit - just noticed, my warp effect looks horrible on sprites that don't have the same ratio as that original shape. And since it's hard-coded it's difficult to edit. I'll need to improve that if I fix it up (which I rpobably will, although I'm not sure when I'll do that...)

Edited by dannyjenn, 13 June 2012 - 03:09 AM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users