I am creating a farm game and I am trying to drag an object (red spot) over the ground. When the object rolls over a soil square it highlights a different color. I am trying to drop the object onto the colored soil and have it plant some corn. My cornCrop movieClip is supposed to appear in the middle of the highlighted soil. I posted some code and a screenshot. In the code snippet i have some hard-coded x,y coordinates for the corn stalk to appear. How do I get the corn stalk to dynamically appear in the center of the highlighted soil movieClip? Plus, I can see that I should probably use some sort of array for the corn because I don't know how many times a user will want to plant them. I am not sure how to do that either.
farm.png
Code:
if (bucketCorn.hitTestObject(Grid.Cell_3_1))
{
var gridID = Grid.Cell_3_1;
//addCrop();
//myColorTransform.color = 0x00FF33;
//Grid.Cell_3_1.transform.colorTransform = myColorTransform;
trace("Yogi Bear!");
var cropCorn1 = new CropCorn();
cropCorn1.x = 50;
cropCorn1.y = 400;
addChild(cropCorn1);
}
if (bucketCorn.hitTestObject(Grid.Cell_3_2))
{
//addCrop();
//myColorTransform.color = 0x00FF33;
//Grid.Cell_3_2.transform.colorTransform = myColorTransform;
var cropCorn3 = new CropCorn();
Grid.Cell_3_2.addChild(cropCorn3);
}
Thanks,
Alex