Hello I just started working with Flash last week, I would need some help figuring out why my game fails. I’m trying to create a small game, pretty much a Bejeweled clone. I got everything working, but when I try to move the whole “playing field” to the right, my collision suddenly stops working. The way I have setup the game is like this: I got a class called “Main” which extends a MovieClip. I use Main as my Document Class, the in main I got a MovieClip called BlockHolder that holds all of my blocks. I add BlockHolder as a child to Main and the add each block to the BlockHandler.
My blocks are instances of my “CBlock” class, which holds alot of variables like, isSleeping, hasLanded and so on. It also holds a instance of a MovieClip that is a picture of the block, I got six different types of MovieClips (redBlock, blueBlock, greenBlock and so on…).
I handle collision in each of the instances of CBlock by checking up/down/left/right with the getObjectsUnderPoint() function, if I find any blocks underneath I put the block to sleep, I use a similar method to find out which blocks that needs to be removed when there are three or more in a row or column.
Everthing works fine untill I move the Main instance, then the collsion stops working and I get the strange results as shown below. I post the collision code snippet in case it will be needed to find out what the problem is.
Correct:
http://www.filedropper.com/correct
Failed:
http://www.filedropper.com/noncorrect
public function CheckForBlockAt( testPoint:Point ):CBlock
{
//get an array of objects from the m_BlockHolder of the MainClass from under the testpoint
var tmpArray:Array = parent.parent.getObjectsUnderPoint( testPoint );
if( tmpArray.length > 0 )
{
if( tmpArray[0] is CBlock )
{
if( tmpArray[0] != this )
{
return tmpArray[0];
}
}
else
{
if( tmpArray[0].parent.parent != this )
{
return tmpArray[0].parent.parent;
}
}
}
return null;
}
Sorry for the big pictures, couldn’t resize them…
Thank you.