Jump to content

Yar

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

Events and more

Sign in to follow this  
H_o_p_s

105 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
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!