Jump to content

How to "shake" a GUI element


Recommended Posts

Posted

Hello guys,

Today I started to create some stuffs here, and I had an idea: create a GUI element (an image created using dxDrawImage()) and shake it when the player move his mouse over the image.

I need help with the shake effect. How could I do this? Someone has something that could help me? Thought about maybe use setElementRotation(), but maybe I would need to use some timers too. I need a simple tutorial about how to create this shake effect. A little explanation.

Software Engineer & Entrepreneur Running Lustrel and VilarikA • Highly engaged on open source community

  • MTA Team
Posted

Hey Stanley,

as far as I know, setElementRotation doesn't work on GUI elements. Do you want to wiggle it like

or make it rotate all around?

EDIT: Confirmed you can't use setElementRotation on GUI elements

EDIT2: you can use interpolateBetween and getEasingFunction. its a bit complicated but you can easily get used to it with practice :)

Posted

Hey Concerned,

Yes, it is exactly what I want to do (this effect in the video). But the effect would be like this:

4kYYX.png

I'll try use these functions, but I'll still accepting new suggestions. If someone has a function already created and would like to share, I will love him forever. :P

Software Engineer & Entrepreneur Running Lustrel and VilarikA • Highly engaged on open source community

Posted

I don't think you could achieve this without using dxDrawImage. Which already has 'native' support for rotation.

EDIT2: you can use interpolateBetween and getEasingFunction. its a bit complicated but you can easily get used to it with practice :)

Correct me if I'm wrong, but I believe you can only actually re-size your UI Elements with interpolateBetween, and not actually rotate it via this function...?

If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.

  • MTA Team
Posted

Dealman, you can do anything with interpolateBetween :) From animating a line across the screen to making an object bounce in the 3D world!

Since you cannot rotate GUI elements I suggest that you use the easing functions to make an effect which is similar to this. It could consist of it shaking side to side so you might have to chain up animations. I don't have much experience with the easing functions and I've only ever played with them in the 1.1 nightly when they were introduced by Kayl. Other than that, images are the way to go if you want to stick to rotating.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...