Jump to content
Search Community

Ball example

Alexygen test
Moderator Tag

Recommended Posts

Hello.

I find example  

How to make the ball flatten when it hits the wall? 

If I add code: 

.to(
ball,
{
duration: 3,
scaleY: 0.5,
scaleX: 1.3,
ease: "myBounce-squash",
transformOrigin: "bottom",
}
)

 

and code

 

import { CustomBounce } from "./plug/CustomBounce.js"
import { CustomEase } from "./plug/CustomEase.js"
 
gsap.registerPlugin(Draggable, InertiaPlugin, CustomBounce, CustomEase)
 
CustomBounce.create("myBounce", { strength: 0.7, squash: 3 })

 

this not work

See the Pen 7c4eae8dd686a125d631da761b164f2d by osublake (@osublake) on CodePen

Link to comment
Share on other sites

Hey Alexygen. You'd need to modify the checkBounds function to fire a squash animation based on the wall that it's hitting. Using CustomBounce won't really help you here as the animation has to be more dynamic.

 

Here's a really rough approximation that should be enough to get you started:

See the Pen YzwVjbR by GreenSock (@GreenSock) on CodePen

  • Like 1
Link to comment
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
  • Recently Browsing   0 members

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