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:
pdeo*[rt9rt7
pdeo*[ru9ru7
pdeo*t9op]npT7
pdeo*u9op]npU7
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
created:
1. Import the >arahBehpan and >epi]lBehpanMq]hepu classes:
eilknpbh]od*behpano*>arahBehpan7
eilknpbh]od*behpano*>epi]lBehpanMq]hepu7
2. Declare the bevel object:
lner]par]n[^arah6>arahBehpan7
3. Create the bevel object and assign its properties:
[^arah9jas>arahBehpan$%7
[^arah*`eop]j_a9/7
[^arah*]jcha9-.,7
[^arah*mq]hepu9>epi]lBehpanMq]hepu*HKS7
4. Add the bevel object to the behpano array:
pdeo*behpano9W[^arahY7
These steps are identical to adding a dynamic drop shadow filter.
 
Search Nedrilad ::




Custom Search