1 decade ago by JackImpact
Hi All ImpactJS Stars,
I am developing a puzzle game in which players can splat pickles on the screen. The idea is that enemies will slow down when they hit the pickles on the screen and when they go through the pickle, their speed will resume. I managed to slow down the speed using check function but having a hair-pulling time with the speed resume. Cannt figure out why the check function is not working for me. Here is the code:
The code above can slow down the enemies but cann't reset the speed of enemies.
Your help is much appreciated and thanks heaps!
Cheers!
Jack
I am developing a puzzle game in which players can splat pickles on the screen. The idea is that enemies will slow down when they hit the pickles on the screen and when they go through the pickle, their speed will resume. I managed to slow down the speed using check function but having a hair-pulling time with the speed resume. Cannt figure out why the check function is not working for me. Here is the code:
check:function(other){ if(other instanceof EntityEnemy){ if(this.touches(other)){ other.vel.x=other.vel.x*0.99; other.vel.y=other.vel.y*0.99; }else{ other.vel.x=90; other.vel.y=10; } } },
The code above can slow down the enemies but cann't reset the speed of enemies.
Your help is much appreciated and thanks heaps!
Cheers!
Jack