Skip to main content
gamedev.net
🔒 Locked

[web] Actionscript: interaction between classes

Started by Funkymunky Sep 29, 2006 at 1:39 AM 0 replies 300+ views
Original Post
Funkymunky
Funkymunky
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?
Funkymunky
Funkymunky
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?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.