It only stops the single current ongoing event as breakEvent() is called, if another event is dispatched afterwards it will work normally. In short, with breakEvent() a component can stop other components from hearing an event. Of course, it only works for components with specified a lower priority value, as the ones with a higher priority value have already executed. Calling it prevents any other components that were listening for this event from ever getting their turn. The only gotcha here is that our attachEvent() function has been appended to return an Event instance, soley used for the purpose of identification so that we can detach it later if we want to.īreakEvent() is a fairly simple function with a lot of power, and you can invoke it at any time inside your components as they are reacting to a dispatchEvent. RemoveComponent() and detachEvent() should be fairly self-explanatory. Public function detachEvent(e:Event):Bool Public function removeComponent(type:Class):Bool Public function attachEvent(keyword:String, callback:Function, priority:Int = 0):Event Public function dispatchEvent(keyword:String, data:Object = null):Object Public function getComponent(type:Class):Component Public function attachComponent(component:Component):Bool Let’s add some more functionality to our Entity class: Just ask if you are unsure of how something would be implemented. For this post, I will be posting more plain English description of the components rather than actual component code. Now that we have a basic idea about what components are and how they work together with events, let’s talk about some examples and more advanced techniques.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |