Author Topic: Changing one variable to a member of a flxgroup and all members are affected  (Read 739 times)


  • New Member
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
So I've got a flxgroup of different enemy types. However one type changes their maxvelocity under certain conditions. However when it changes, all other enemies are affected by the change despite never calling that code themselves. It's controlled by a state which the other enemies never enter.

Is there something obvious I'm missing? The enemies are extended flxsprites.

Code: [Select]
case charge:
maxVelocity.x = 150;
max_state_duration = 0;

That's part of the set State switch statement. Only one enemy ever runs that code. However when it runs, all members of the group get their maxVelocity set to 150. I've tested it by replacing with velocity.y -= 500; and in this example only the single enemy jumps in the air. So strange.


  • Contributor
  • ****
  • Posts: 390
  • Karma: +0/-0
    • View Profile
Are you *absolutely sure* that piece of code only gets called for that specifc sprite? Try using  FlxG.log or for debugging if you haven't already, extremely useful.

It's a bit hard to tell what's really the issue here without getting to see more code.