Multiple ground isntances using Arrays [Help please]

Hello everyone!

I’ve been browsing this forum for a long time, and I wanted to make an account so I could actually communicate with it’s members. :slight_smile:

Currently I’m working on a game engine with a friend of mine, we plan to make it open source so other people can use it too for their own games…

We basically have everything done, but I really want to add multiple ground instance support.

To get more in-depth…

I would like to use an Array, to call upon all ground layers on the stage, and put it into one call name for my gravity function. So I wouldn’t have to have various strings for each ground instance.

I know I’m probably no where close… but this is my attempt.

var groundArray:Array = [ground, ground2, ground3];
var groundtile:MovieClip = groundArray[1];
addChild(groundtile);

This is my gravity…

function heroGravity(e:Event) {				
	if (jumping) { 							
		Suoh.y -=  yspeed; 					
		if (Suoh.hitTestObject(groundtile)) {
			jumping = false; 				
			inAir = false;					
			Suoh.gotoAndStop("Stand")		
		}
	}											
	Suoh.y -=  yspeed;							
	if (!Suoh.y < groundtile.y && jumping == true) {
		yspeed -=  gravity;
	}
	if (Suoh.hitTestObject(groundtile)) {
		Suoh.y = groundtile.y;
	}
}
	if (!Suoh.hitTestObject(groundtile)) {   
		yspeed -=  yacceleration;                     
	}
	if (!Suoh.y < groundtile.y) {
		yspeed -=  yacceleration;
}

What I have so far works perfect without arrays…
When I add my above array, I don’t get any errors… but I fall through the ground. :frowning:

Would anyone mind helping me?
I’ve been trying at this for quite some time now and I can’t seem to nail it…