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 TrexKikBut

Everytime I switch my weapons, it ends up glitching on EntityGrenade. Why is it doing this?

I'm following the book of HTML5 Game Development

if( ig.input.pressed('switch') ) {
            	this.weapon ++;
            	if(this.weapon >= this.totalWeapons)
            		this.weapon = 0;
                switch(this.weapon){
                	case(0):
                		this.activeWeapon = "EntityBullet";
					case(1):
						this.activeWeapon = "EntityBullet2";
					case(2):
					    this.activeWeapon = "EntityGrenade";
						break;
                	break;
                }
                this.setupAnimation(this.weapon);

1 decade ago by UteEffacht

I think you forgot the break at the end of each case. ;-)

Without the break, the following code will also be executed - in your case ending with setting the active weapon to the EntityGrenade.

1 decade ago by TrexKikBut

Yeah thank you! That worked!
Page 1 of 1
« first « previous next › last »