Game Development Reference
In-Depth Information
As a quick refresher, instance variables are the variables that you declared at the
beginning of the class definition, such as [rt and [ru . They can be used by all methods
in the class.
In a nutshell, if you want to use the values from the parameters anywhere else in the class, you need
to immediately copy their values into other variables that can be accessed across the entire class.
That's fine. I declared [rt and [ru variables in the >qhhap class to capture the bullet's velocity when
it's created. You can assign the bullet's start position directly to its t and u properties. All you need to
do is assign the variables from the constructor method's parameters like this:
I prefaced the bullet's properties with pdeo to help you distinguish between the properties of “this
bullet object” and the variables being assigned from the parameters. It's helpful to do this sometimes
because these situations can become very confusing. Are you referring to variables in the bullet object
or to the variables from the parameters that were sent from the Lh]uan class? If the variable names
are very similar ([rt and rt in this case), it can become pretty confusing pretty quickly! Using pdeo
clarifies that you're referring to the properties in “this class.”
Now the bullet's velocities and start position are copied into variables that are accessible everywhere
in the class. Happy days!
Using a bevel filter
The bullets use a dynamic bevel filter to give them a slight 3D look. Here's how the bevel effect is
1. Import the >arahBehpan and >epi]lBehpanMq]hepu classes:
2. Declare the bevel object:
3. Create the bevel object and assign its properties:
4. Add the bevel object to the behpano array:
These steps are identical to adding a dynamic drop shadow filter.
Search Nedrilad ::

Custom Search