Game Development Reference
In-Depth Information
This is the first (easy) part of determining collisions, in this first checkCollision()
method, called from inside of the .update() method, by the pulse event manager. This
iterates through the List<Actor> CURRENT_CAST and calls the col-
lide(object); method, for each Actor object, to see if the InvinciBagel character
has collided with it. As you can see in Figure 16-31 , this Java code is error-free, and
the next Java method body that we will code is the public boolean collide()
method, which we declared for use previously inside of our abstract Hero class, in
Chapter 8 .
Figure 16-31 . Add a for loop, counting from 0 to number of objects in the CURRENT_CAST using .getCur-
rentCast().size()
Before we code the .collide() method, which is one of the more difficult method
bodies that we'll be coding during this entire book, we'll need to look at some of the
more complex topics relating to the javafx.scene package's Node class, and its
Bounds property, and .getBoundsInLocal() and .getBoundsInparent() method call.
We will also be looking at the javafx.scene.shape package's Shape class, and its .in-
tersect(Shape shape1, Shape shape2) method call. We will be using all of these inside
of our public boolean collide(Actor object) {...} method, so we
will need to have this advanced knowledge in place first, before we write this complex
and dense (but exciting) Java structure.
 
 
Search WWH ::




Custom Search