Jump to content
  • Advertisement


Sign in to follow this  
  • entries
  • comments
  • views

Events and more

Sign in to follow this  


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  


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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!