ForumsProgramming ForumAS3 Memory and Classes

12 5875
manny6574
offline
manny6574
922 posts
Nomad

Hello, some of you may remember me as I used to come here quite often.

I remember this forum had a lot of good developers, and I am back into AS3 after a year of having quit.

Anyway, long story cut short: I'm making a game that is the top of my ability, which seems to have improved on its own. I have an Enemy class and 16 types of enemies, and another massive load is being thought up and drawn by my friend. The enemies have different behaviours. I have two options:

1. Use a switch statement in the Enemy class to test for the type of enemy, and execute the corresponding function. That would mean the Enemy class has about 80 functions in the end - 40 pseudo-constructors and 40 handler for different ENTER_FRAME events

2. Make separate classes for each of the types, that extend the Enemy class. Contain all code in here.

WHICH OPTION IS BEST IN TERMS OF MEMORY EFFICIENCY?

  • 12 Replies
Showing 16-15 of 12