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

freelancepolice

  • 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:
play("charge");
maxVelocity.x = 150;
max_state_duration = 0;
break;

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.

Gama11

  • 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 FlxG.watch 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.