Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by LaserBeam

Hi,

I am trying to switch between two entities that 1 player can control. However, everytime I do it the browser freezes.

swap: true, is defined in main. In EntityA in the update function is the following code:

##if(ig.game.swap){
if(ig.input.pressed('swap')){
ig.game.swap=false;
this.kill();
ig.game.spawnEntity(EntityB, this.pos.x, this.pos.y, {flip:this.flip});
}

}

In EntityB the following code is defined in the update function:

##if(ig.game.swap==false){
""if(ig.input.pressed('swap')){
""ig.game.swap=true;
this.kill();
ig.game.spawnEntity(EntityA, this.pos.x, this.pos.y, {flip:this.flip});""
}
""
}

Any idea why the browser 'freezes'?

1 decade ago by LaserBeam

Something got messed up, up there! Another try:

I am trying to switch between two entities that 1 player can control. However, everytime I do it the browser freezes.

swap: true, is defined in main. In EntityA in the update function is the following code:

if(ig.game.swap){
if(ig.input.pressed('swap')){
ig.game.swap=false;
this.kill();
ig.game.spawnEntity(EntityB, this.pos.x, this.pos.y, {flip:this.flip});
}
}

In EntityB the following code is defined in the update function:

if(ig.game.swap==false){
if(ig.input.pressed('swap')){
ig.game.swap=true;
this.kill();
ig.game.spawnEntity(EntityA, this.pos.x, this.pos.y, {flip:this.flip});
}
}

Any idea why the browser 'freezes'?

1 decade ago by SlouchCouch

do you have any errors to the console? do you have any accidental infinite loops?

1 decade ago by LaserBeam

For those who have a similar issue. I don't use a Boolean now but use instead an additinal key for the swap.

P.S.: @SlouchCouch no accidental infinite loops but thanks anyway.
Page 1 of 1
« first « previous next › last »