Objects in the World (and their properties) can be referenced in a variety of ways within a behavior. This creates a great deal of flexibility, but may lead to some unexpected results.
The following are intended as guidelines to help you produce robust and predictable behaviors.
This Object Reference
The use of
"this object""this" should be used whenever you are operating on the object where the behavior has been defined. Resist using the object name explicitly. By using
this object, you are guaranteed to operate on the right object.
The reference is listed in the object
browser,browser and
willcan alwaysbe showaccessed under the
name"this" oftab, which also shows the
underlyingproperties objectfor inthe active parentheses.object. For example, when the current object contacts something else, change its orientation.
Mouse Input Event References
WhenWhenever you
have a mouse eventare filter,creating a
new reference -behavior, mouseit's event object - will be
created whichlisted referencesunder the
object"other" thattab receivedin the
mouse event,Values regardlesssection of
where the
respective behavior is defined.For example, if you define theBehavior belowBuilder. behaviorClicking on the airplane, the actionevent will result in the rectangle's fill color being changed since that was the object thatshow wasyou beingcertain definedproperties inof the filter.Created Object When creating behaviorsevent, thatsome interactof withwhich dynamicallycan createdthen objects,be aclicked uniqueon referenceas willwell beto createdsee forwhat the
object that isvalue created.references. ThereThis areimage twoshows usethe caseslocation forof the
created object referenceEvent :object.
TheAnd Createclicking Action:on Whenthe creatingEvent object using the Createwill action,show you must use the new reference toproperties. manipulateIn this object. By default, thecase, namewe willare belooking newat <objecta name>collision whereevent, <objectwhich name>shows iscertain theproperties namethat ofdescribe the underlying object beingcollision created.occurrence:
It'sIf referencewe willwanted appearto inchange the object browser list. You can rename this reference as long as it doesn'torientation overlapof the name ofobject anthat existing"this" object incollided thewith, World.we Forwould example,click inon the below behavior, we've created a circle and a rectangle. The circle has its fill color"actor2" changed,reference andin the rectangleProperty has itlist, fillwhich colorwill andshow lineus colorthe changed.Anproperties Objectfor Createdthat Filter:actor Behaviorswhich can be executed when an object is created. If the filter describes this event, the new object willdragged referenceinto the created object that causedaction, thegiving behaviorus tothis execute.result:For example, when a rectangle is created created object will reference that individual rectangle that was just created.
Looping References
When you loop across multiple instances of an object - even if you are doing it from within an object's behavior - you can define your own name
for the iteratorsto reference.Byuse default,inside the
name will be "the <object name>" where <objectfor-each name>action. isIn theany namelocation ofthat thea underlyingnew object
you are looping across. It's reference
will appear in the object browseris list.defined, Youyou can
rename this reference asclick longon asthat itreference doesn'tto overlapsee the
name ofproperties anassociated existingwith objectthat inobject. theIn World.this Forcase, example,we whenare looping across all rectangles,rectangles changeand theirchanging colortheir tofill red:color. The Specificfill objectcolor referenceReferencesis toaccessed specificby objectsclicking inon the
World can be done as well.first Theseoccurrence referencesof will"rectangle appearinstance," inwhere theit objectis browser.defined.These are only recommended when you know that there is just a single instance of that object. If there are multiple copies of the object with the same name, the outcome of references in non-deterministic. It could affect any one of the objects.
Furthermore, you should always use this object whenever it is possible. That will maximize the portability of the behaviorApplication orand function.Worl If
The thisApplication object is used to modify properties of the parent object, you can re-use the actions on any object without making changes to the behavior. This is especially relevant when you are sharing your work with the community.WorldTheand World objectobjects isare always available in the behavior editor.
ItThey isare listed along with other objects within the object
browser. And although World and this object are interchangeable when editing the World's behaviors, it is recommended that you always use this object whenever it is possible.First Collision BodySecond Collision BodyThe Collision Body references available anytime the Collide or Contact filters are used. The references will appear object browser along with all of the objects in the World.The First Collision Body reference always refers to the first object reference of the filter. The typical use case is to use this object for the first object, but this is configurable. The Second Collision Body reference always refers to the second object referencebrowser, ofunder the
filter. For example,"actors" intab theand belowcan filter,be itclicked referson to
the actual circle that the this object collided with.access Thetheir referenceproperties isjust forlike the specific circle that was involved inother thenamed collision.references: