How do I Make a button wiggle once?

0 favourites
  • 15 posts
From the Asset Store
Change the size and position of everything without calculating anything!
  • I want to have the buttons in my game wiggle when you press them like in many mobile games. I tried using tweens and sine behaviors but I think there may be a more elegant and function way. Does anyone have insight on such wiggly subjects as this?

    Thank you.

    Tagged:

  • The norm would be to create an animation I guess if it moves in a unique way. But nothing wrong with using scale or something else to mimic button pressed states.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks for the reply Plinkie,

    I was thinking something more procedural. So any button of a button family will wiggle using scale, rotation etc.

    I am looking for an elegant way of doing a little bounce on touch.

  • Subscribe to Construct videos now
  • Thanks for the reply newt I will try this as soon as possible. Thank you.

  • Thanks again newt for the example! it works great on a single object now I must figure out how to get it to work on a single instance of a family. I have it individual family instances wiggling but they wiggle themselves out of place and don't seem to be setting their x and y correctly at start.

  • This is what the code currently reads like

  • You don't need a Boolean if its while you are touching

    On touched family, family set startx to self.x, set starty to self.y

    Is touching family, family set x to startx, y to starty

    ->set x to self.x+random(-2,2), set y to self.y+random(-2,2)

    On touch end, family set x to startx, set y to starty

  • That's more of a shake than a wiggle. Why not just use a few tweens? You would get much smoother motion and control over the timing.

    Put the tween behavior on the FAMILY. Then "On tap object" on the FAMILY, do two tween actions (one tween for rotation and the other for position).

  • yeah I think you want some easing in your "wiggle" rather than a "jerky shake".

    I say use Sine or Tween for the movement. you can easily apply that to Newt's code.

  • how are we defining wiggle here?

    this sounds like something you could do very easy with sine behavior.

  • Hey Fib jobel I did have a version using Tweens and it didn't how I would like. The tweens cannot reset and pressed again. It does however have a smooth transition of course. :) NetOne I couldn't figure a way to reset the sine when done.

    newtThanks so much for making an example! This is a cool method. Is this how screen shake works too?

    Thanks everyone for helping out.

    :)

  • Welcome.

    Yeah, you can do that, just promise not to use a ScrollTo behavior. lol

  • Hey Fib jobel I did have a version using Tweens and it didn't how I would like. The tweens cannot reset and pressed again. It does however have a smooth transition of course. :)

    I'm not sure why it wouldn't replay when you click again. Are you trying to use the Stop action on the tween and trying to use the Resume action? Because that definitely wouldn't work.

    Are the start and end tween values becoming the same? If the start value and end value are the same then obviously it won't tween, it will end immediately.

    It's hard to debug it without seeing any code.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)