00:00
00:00
Newgrounds Background Image Theme

444rgh just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Class communication AS3

336 Views | 0 Replies
New Topic Respond to this Topic

Class communication AS3 2014-09-13 02:44:02


Forgive my string of posts.

I am currently working on a boss that is made up of two separate enemies. Both of these enemies share the same subclass. I made it that way because I wanted to be able to play the two enemies off one another. Like, if one enemy is in a current state, the other will react to it.

As usual, I'm trying to make classes as self-contained as possible. By that, i mean that I don't want to rely on anything more than a simple outer update to control the objects of the class if I can help it.

What I'm really hoping is possible, from within the subclass, I can reference both instances of the class. I can already reference a class by itself. I can say "if(this is Boss1)" and only control that class, but I can't figure a way to reference one instance of the class as the other class.

So none of this crap: "if(this is Boss1){ this.x = Boss2};"

I think what i could do is just create another child class of the All-knowing Enemy.as class that will be able to specifically control state changes of the two boss enemies. At which point I may as well separate the two bosses. That would probably be the best way for me if I can't get this same-class thing to work.

I just want to get this composite-enemy thing functioning right. I'm going to need it again.