How to limit velocity

Recommended Posts

Hello, I am building my first game as a trainee ( web developer ). My employer wants me to build a hammer hit game, similar to this: http://html.orgino.com.tr/mobilegitimtiri/25/index.html 

I started building it in Phaser 3 but stuck at moving the ball.

How the game works:

There are 4 levels,

Each time the player pulls the hammer, the hammer hits the machine and ball moves up. For each level, the ball moves to a certain point. While the ball moving I need to change the background.


I have tried velocity, but I can't limit how high it can go

I have tried to create a game object from graphics so the ball can hit and bounce back, I've failed

Currently, I am trying tween but it is problematic too. ( ball goes back and forth)

My question is can I create an invisible line and use as a ceiling? If not how can I solve this problem?

Share this post

Link to post
Share on other sites


game does not work for me, but you could probably use a collider callback to deal with that. Add an invisible physics body, and call some function that stops the ball on collision:

https://labs.phaser.io/edit.html?src=src\physics\arcade\remove collider.js

What about the straightforward way ? :

if(ball.y < 300){


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

  • Recently Browsing   0 members

    No registered users viewing this page.