Jump to content
  • Advertisement
Sign in to follow this  
Funkymunky

[web] Actionscript: interaction between classes

This topic is 4374 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is it possible to have interactions between classes in actionscript? Say I have one character and I want him to punch the other character. Both are movie clips that are being controlled by independant classes. So I want the first characters class to tell the second one "i punched you, react." Furthermore I then want the first class to tell a third score-keeping class to change the health meters. How would I go about doing this type of thing?

Share this post


Link to post
Share on other sites
Advertisement
hmmm, here's what i'm thinking. Right now, I set up my updates like this:


onEnterFrame = function()
{
fighter.Update();
baddie.Update();
}


fighter and baddie are two different classes. Maybe i should change the onEnterFrame to do something like this:


onEnterFrame = function()
{
fighter.Update();
baddie.Update();

var fState:String = fighter.getState();
var bState:String = baddie.getState();

var fReaction:String = intermediary.CheckFighter(fState);
var bReaction:String = intermediary.CheckBaddie(bState);

fighter.React(fReaction);
baddie.React(bReaction);
}


in this, intermediary is a new class which will make decisions based on the state returned from the first two classes. It then issues a reaction response, which is in turn passed to each class.

This seems really convoluted and over-complicated. Is this really the best solution?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!