Jump to content

[SOLVED] How to modify GUI button click animation?


BuzyGear
 Share

Recommended Posts

Hi @BuzyGear

Please see docs for buttons; 
https://doc.babylonjs.com/how_to/gui#button

Quote

Visual animations

By default a button will change its opacity on pointerover and will change it's scale when clicked. You can define your own animations with the following callbacks:

  • pointerEnterAnimation
  • pointerOutAnimation
  • pointerDownAnimation
  • pointerUpAnimation

 

and; http://doc.babylonjs.com/api/classes/babylon.gui.button#pointerdownanimation

TL:DR;

_this.pointerEnterAnimation = function () {
  _this.alpha -= 0.1;
};
_this.pointerOutAnimation = function () {
  _this.alpha += 0.1;
};
_this.pointerDownAnimation = function () {
  _this.scaleX -= 0.05;
  _this.scaleY -= 0.05;
};
_this.pointerUpAnimation = function () {
  _this.scaleX += 0.05;
  _this.scaleY += 0.05;
};

 

You can simply overwrite those functions, '_this' being your button name/variable ofcourse :) 
Have a nice saturday!

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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