Yar

Sign in to follow this  
  • entries
    208
  • comments
    383
  • views
    65546

Events and more

Sign in to follow this  
H_o_p_s

84 views

Well, I just completed the event system. I think that I have mentioned it before, but it is very neat :) Say that you have an Actor, and on activation of that event you want to decrease the HP of the Actor who activated it:


class HurtEvent extends jEvent {
public void activate() {
if (!status.CursorActivation) {
Actor act = status.getActor( status.getCurrentActorKey() );
act.setHP( act.getHP() - rand(5,10) );
}
}
}




Now, this event is attacted to the actor by doing:

HurtEvent he = new HurtEvent();
Actor_01.addEvent("default", he);

So now under the event array in Actor_01 if "default" is called, it runs the HurtEvent. In all jEvents the activate() method is the one called upon the activation of the event. So in the above example when the default event is ran it launches HurtEvent which makes sure that the Cursor did not activate it, gets the Actor that did, and decreased its HP by a random int between 5 and 10.

Anyway... there is an insight on my event system :)
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now