Sign in to follow this  
BuzyGear

[SOLVED] How to modify GUI button click animation?

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!

 

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.