breve Documentation: version 1.9 | ||
---|---|---|
<< previous | Chapter 4. Interactions Between Agents | next >> |
If you need to determine whether an object is of a certain type, you can use the method is from Object.tz. The method takes a single keyword, "a", such that the method call can be written:
item is a "Dog". |
The call returns a int value 1 if the item is of the specified type, or 0 otherwise. This would most likely be part of an if statement:
if (item is a "Dog"): item roll-over. |
This method is useful in collision callbacks or when examining neighbors in order to determine the appropriate action.
<< previous | breve Documentation table of contents | next >> |
Testing Whether an Object Responds to a Method Call | up | Physical Simulation |