Game Development Reference
In-Depth Information
Creating subobjects
The simplest way to improve collision detection using depPaopK^fa_p is to create subobjects inside
the main object and use them to check for a collision.
Let's stick with the problem of the long-eared cat and the apple for a moment. You could greatly
improve the collision detection between them if you created a smaller rectangular object inside the _]p
object that defined the collision area. You could give this subobject the instance name _khheoekj=na].
You could then access it with dot notation like this:
_]p*_khheoekj=na]
If you used it with depPaopK^fa_p in an eb statement, it might look something like this:
eb$_]p*_khheoekj=na]*depPaopK^fa_p$]llha%%
w
?khheoekj`ena_perao***
y
Of course, you have to set the alpha of the _khheoekj=na] subobject to , so it is completely transpar-
ent. (To make an object completely transparent, select it, and then give it an alpha value of , in the
Color Effect pane of the Properties panel. Alpha is one of the options in the Style menu.)
Figure 7-24 shows how using a subobject can greatly improve the collision detection between the cat
and the apple. In the figure, a. shows what this would look like if the _khheoekj=na] subobject were
visible, and b. shows how it would probably be used, completely transparently, in a real project.
Figure 7-24. Use subobjects to improve collision
detection.
 
Search Nedrilad ::




Custom Search