Can some one help with a game?

Subscribe to Can some one help with a game? 12 posts

avatar for bimbofred bimbofred 45 posts
Flag Post

I have a problem with the hitTest when it tries to change an array variable it changes them all and it only works for one of the attached MCs.

Please, Please help?

 
avatar for IndieFlashArcade IndieFlashAr... 433 posts
Flag Post

Um… can you please be a little more ambiguous?

 
avatar for bimbofred bimbofred 45 posts
Flag Post

i can send you the fla

 
avatar for IndieFlashArcade IndieFlashAr... 433 posts
Flag Post

No, I wasn’t offering to debug your file… I am trying to suggest that you provide the forum with a little more information about your problem. How do you expect anyone to be able to help you when your question is so ambiguous (if you don’t know what that means, it’s in the dictionary).

 
avatar for bimbofred bimbofred 45 posts
Flag Post

It’s exactly as I said insted of changing one part of an array it changes the whole array.
If it helps to know the code is in a movieclip and there is a loop to control the several attached movieclips.
Plus your use of ambiguous is very ambiguous. The phrase “less vague” would be better.

 
avatar for boluc boluc 19 posts
Flag Post

please post the code we cant really help you like this.

 
avatar for bimbofred bimbofred 45 posts
Flag Post
Heres the code:
onClipEvent (load) {
	chavA = new Array();
	chavb = new Array();
	cnum = new Number();
}
onClipEvent (enterFrame) {
	num--;
	if (num<-9>-1; i--) {
		chavA[i].Name._y -= chavA[i].bob;
		if (chavb[i] == true) {
			chavA[i].bob--;
			chavA[i].Name._x += 5*chavA[i].scale;
			chavA[i].Name.gotoAndStop(8);
		}
		if (chavA[i].bob == -10) {
			chavA[i].bob = 0;
			chavb[i] = false;
			chavA[i].Name.gotoAndStop(1);
		}
		if (chavb[i] == false) {
			if (this.wack.hitTest(chavA[i].Name)) {
				chavA[i].scale = _root.scale;
				chavA[i].bob = 9;
				chavb[i] = true;
				chavA[i].hp--;
			}
		}
		if (chavb[i] == false) {
			if (chavA[i].hp == 0) {
				removeMovieClip(chavA[i].Name);
				chavA.splice(i, 1);
			}
			xdis = _root.blob._x-chavA[i].Name._x;
			if (xdis>0) {
				if (xdis>3) {
					xspeed = 3;
					chavA[i].Name._xscale = 100;
				} else {
					xspeed = xdis;
				}
			} else {
				if (xdis<-3>0) {
				if (ydis>3) {
					yspeed = 3;
				} else {
					yspeed = ydis;
				}
			} else {
				if (ydis<-3><40>-40) {
				chavA[i].Name.play();
			}
		}
	}
	if (this.hitTest(_root.chav.hit)) {
		_root.hart.health._x--;
	}
	if (Key.isDown(Key.SPACE)) {
		this.play();
	}
	if (Key.isDown(Key.LEFT)) {
		this._x -= 10;
		_root.scale = -1;
		this._xscale = 100*_root.scale;
		this.legs.play();
	}
	if (Key.isDown(Key.UP)) {
		this._y -= 10;
		this.legs.play();
	}
	if (Key.isDown(Key.DOWN)) {
		this._y += 10;
		this.legs.play();
	}
	if (Key.isDown(Key.RIGHT)) {
		this._x += 10;
		this.legs.play();
		_root.scale = 1;
		this._xscale = 100*_root.scale;
	}
}
I think the mistake is in the loop. Sorry about the varible names I name them after random people I know.
 
avatar for arcaneCoder arcaneCoder 2354 posts
Flag Post

Please read the sticky regarding how to post code in the forums. If you post it like that, no one is likely to read it. I fixed it for you this time.

 
avatar for bimbofred bimbofred 45 posts
Flag Post

I think the mastake is:



chavA[i].Name.y = chavA[i].bob;
if (chavb[i] == true) {
chavA[i].bob
-;
chavA[i].Name.
x += 5*chavA[i].scale;
chavA[i].Name.gotoAndStop(8);
}
if (chavA[i].bob == 10) {
chavA[i].bob = 0;
chavb[i] = false;
chavA[i].Name.gotoAndStop(1);
}
if (chavb[i] == false) {
if (this.wack.hitTest(chavA[i].Name)) {
chavA[i].scale = _root.scale;
chavA[i].bob = 9;
chavb[i] = true;
chavA[i].hp
-;
}
}


It allways seems to through them into the air so to speak and that it only works if you hit the first one attached.


For example if 2 are created and I defeat the first then and only then can i go after the second.

 
avatar for truendymion truendymion 201 posts
Flag Post

It is greek to me…

 
avatar for IndieFlashArcade IndieFlashAr... 433 posts
Flag Post

Ok, one problem is that you’re using cryptic variable names. Obviously, that’s not a good practice, because it will confuse anyone who tries to read your code. You should always give your variables appropriate names for what the variable actually represents, honestly I won’t even look at your code until that happens, because it’s just a really, really confusing thing to do. I mean, it’s no wonder you’re having problems when I see variables named “bob”… it’s just silly.

 
avatar for arcaneCoder arcaneCoder 2354 posts
Flag Post

Its also bad to repeat chavA[i] over and over. You should save that to a local variable and use the variable instead.