I'm working on an app, and I want a sound to play when two objects collide. However, I realized that this will just cause the sound to play a lot, so I want to modify it by making it only play when one of the objects is going some speed. This is my code:
public void beginContact(Contact contact) {
if(contact.getFixtureA().getBody().getUserData() == Box.class &&
contact.getFixtureA().getBody().getLinearVelocity().len() >= new Vector2(1,1).len())
res.boxCollision.play();
The Box class is just one of my classes that I want to cause the sound to play. However, this does not work, and I'm not sure how you would make it work. Any ideas? And this is not the entire function, it is much long so I cut most of it out.
Aucun commentaire:
Enregistrer un commentaire