June 2013
Beginner
352 pages
9h 5m
English
Let's keep the default navigational inputs in our PhysicsFallingBricks.java, and simply add a shoot action. Every time the user clicks, you want to shoot a cannon ball from the camera position forward.
shootCannonBall() method that creates a new physical geometry ballGeo from our ballMesh shape and stoneMat material. The setLinearVelocity() line defines the initial speed and direction of the object. In this case, we accelerate the cannon ball forward. public void shootCannonBall() { Geometry ballGeo = new Geometry("cannon ball", ballMesh); ballGeo.setMaterial(stoneMat); ballGeo.setLocalTranslation(cam.getLocation()); rootNode.attachChild(ballGeo); ballPhy = new RigidBodyControl(5f); ballPhy.setCcdSweptSphereRadius(.1f); ...Read now
Unlock full access