I'm developing a (first) game in Flash AS3 as my exam for school. I'm still learning the language...
[The concept of the game]
Well I'm trying to make the game "falling blocks" where blocks fall of the sky and you as a player have to climb as high as possible to get as much points.
[What I've got]
I've managed to let blocks fall of the sky on a random x coordination. I've managed to keep the blocks inbound of my stageWidth and the player also stays inbound of the stage width.
I've putted the blocks in an Array. I'm working ObjectOriented ofcourse.
[The problem]
I'm trying to use a HitTestObject for my Arrays of blocks. But this isn't going very well. That's why I'm here...
Before I'm going further with my explaination I'll display the code I'm talking about:
The code in my class Main
blockTimer = new Timer(1000);
blockTimer.addEventListener(TimerEvent.TIMER,FallBlocks);
blockTimer.start();
function FallBlocks(evt:TimerEvent):void
{
var blokje:Block = new Block(stage,allBlocks);
//Blokje blijft tussen de randen van de stage
blokje.x = randomNumbers(stage.stageWidth - stage.stageWidth,stage.stageWidth);
addChild(blokje);
allBlocks.push(blokje);
}
The code in my class Block
addEventListener(Event.ENTER_FRAME,update);
function update(evt:Event):void
{
for (var i = 1; i < allBlocks.length; i++)
{
if (hitTestObject(allBlocks[i]))
{
trace("check " + i);
}
The output
check 1 check 1 check 1 Jumping // Happens when I jump with my player so don't mind this check 1 check 1 check 1 check 1 check 1 check 1 check 1 check 1 check 1 check 1 check 1 check 1 check 1 check 1 check 1 check 1 check 1 check 1 check 2 check 1 check 2 check 1 check 2 check 1 check 2 check 1 check 2 check 1 check 2 check 1 check 2 check 1 check 2 check 1 check 2 check 1 check 2 check 2 check 2 check 2 check 2 check 2 check 2 check 2 check 2 check 2 check 2 check 2 check 2 check 2 check 2 check 2 check 3 check 2 check 3 check 2 check 3 check 2 check 3 check 2 check 3 check 2 check 3 check 3 check 3 check 3 check 3 check 3 check 3 check 3 check 3 check 3 check 3 check 3 check 3 check 3 check 3 check 3 check 3 check 3 check 3 check 3 check 4 check 3 check 4 check 3 check 4 check 3 check 4 check 3 check 4 check 3 check 4 check 4 check 4 check 4 check 4 check 4 check 4 check 4 check 4 check 4 check 4 check 4 check 4 check 4 check 4 check 4 check 4 check 4 check 4 check 4 check 5 check 4 check 5 check 4 check 5 check 4 check 5 check 4 check 5 check 4 check 5 check 5 check 5 check 5 check 5 check 5 check 5 check 5 Jumping check 5 check 5 check 5 check 5 check 5 check 5 check 5 check 5 check 5 check 5 check 5 check 5 check 6 check 5 check 6 check 5 check 6 check 5 check 6 check 5 check 6 check 1 check 5 check 6 check 6 check 6 check 6 check 6 check 6 check 6 check 6 check 6 check 6 Jumping check 6 check 6 check 6 check 6 check 6 check 6 check 6 check 6 check 6 check 6 check 7 check 6 check 7 check 6 check 7 check 6 check 7 check 6 check 7 check 6 check 7 check 7 check 7 check 7 check 7 check 7 check 7 check 7 check 7 check 7 check 7 check 7 check 7 check 7 check 7 check 7 check 7 check 7 check 7 check 7 check 8 check 7 check 8 check 7 check 8 check 7 check 8 check 7 check 8 check 1 check 7 check 8 check 8 check 8 check 8 check 8 check 8 check 8 check 8 check 8 check 8 check 8 check 8 check 8 And so on...
The problem is that it doesn't actually hit... I've tried to do it without a for loop because it is in an ENTER_FRAME. But then I thought the for loop is for my timer actually. I also asked my teacher, and he also didn't came up with an solution or any tips. That's why I'm tracing the result but I'm not getting any further actually...
Someone can help me in the right direction? Or tell me what I'm doing wrong?

New Topic/Question
Reply



MultiQuote




|