I'm struggling to make this switch statement work. I want to have multiple conditions like in an if-else statement, but I can't seem to figure out how to add more than two conditions.
function spriteAI1() {
var posX = c2Sprite.position.x
console.log(c2Sprite.position.x);
switch(c2Sprite)
{
case c2Sprite.position.x > 30:
//&& c2Sprite.position.x <= 450:
c2Sprite.translateX( -7 );
break;
//case c2Sprite.position.x < 30:
//&& c2Sprite.position.x >= -450:
//c2Sprite.translateX( 7 );
//break;
//case c2Sprite.position.z < 30
//&& c2Sprite.position.x < 30:
//c2Sprite.remove;
//c2Sprite.clone;
//break;
//default:
//c2Sprite.translateX( -7 );
//break;
}
}
function spriteAI2() {
if (c2Sprite.position.z >= 30 && c2Sprite.position.z <= 350) {
c2Sprite.translateZ( -7 );
} else if (c2Sprite.position.z <= -30 &&c2Sprite.position.z >= -350) {
c2Sprite.translateZ( 7 );
}
//else (c2Sprite.position.z = 30 && c2Sprite.position.x = 30) {
//c2Sprite.remove;
//c2Sprite.clone;
//}
}