Jump to content

How to limit velocity


aykut
 Share

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?

Link to comment
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){
 stopBall()
}

 

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...