hello to all i created the Push entity but how can i chain this with other objects and launch specific event when i push the botton? FOR exemple i have botton1 and when i push it i wanna open a door2, thx a lot
The push events
I’d use the name property of entities.
Here’s how it works: you give each entity that you need to a reference to a unique name. For example, in your case I’d name the button “button01” and the door “door01”. Then when your button is pressed, have it call getInstance() and pass “door01” as the parameter which will return your door entity. From there you can execute a public method, set a variable, and etc.
I also recommend setting up a name property in Ogmo (rather than trying to set them through code) and then having the names loaded into the entities at run-time.
In addition, if you’re asking how to set up callbacks, you can give your Push entity a Function object property and call it when the button is activated.
class Push extends Entity
{
// your class goes here
public var onClick:Function;
protected function callThisMethodWhenButtonIsClicked():void
{
if (onClick != null) onClick();
}
}
Then you can set the handler like this:
var button:Push = new Push();
button.onClick = door2.open;
// if open is a function on your door entity