Abduction of children through hitTestObject

Before asking what I'm sure will be a very stupid question, let me say that I am a total newbie to the Action Script. I try my best to make a simple game of University, and I tried, but he cannot know.

Anyway, the game is essentially Breakout, where you control a paddle and try to hit a ball to the blocks.

I can't understand how to remove blocks when the ball strikes.

I got this far.

If (ball.hitTestObject (b3)) {}
yDirection * = - 1;
stage.removeChild (b3)

Where b3 is block number 3. (I have 6 blocks, b1 - b6, respectively).

It works for the first time the ball hits the block. the block disappears and the ball bounces. However, when the ball moves on this domain yet, it crashes and I get an error.

That is right.  but the hittest code you'll probably want to put in a function, then you can call it when you want to:

var brickA:Array = [];

var tl:MovieClip =;

for (var i: int = 0; i<>

TL ["b" +(i+1)] = new brick();

brickA.push (tl ["b" +(i+1)]);

addChild (tl ["b" +(i+1)])

TL ["b" +(i+1)] .x = 5 + i * (TL ["b" +(i+1)]. Width + 10);

TL ["b" +(i+1)] there = 100;

}

function hitTestF (): void {}

for (var i: int = brickA.length - 1; i > = 0; i--) {}

{if (ball.hitTestObject (brickA [i])}

brickA [i].parent.removeChild (brickA [i]);

var temp = brickA [i];

brickA.splice (i, 1);

Temp = null;

}

}

}

Tags: Adobe Animate

Similar Questions

Maybe you are looking for

  • Why does the cursor not change from an arrow to a hand and allow me to click on words that are 'clickable '.

    In any Web site and a Web page I can't click links/words up to 3 cm of the page. All below I can click on without any problem. Why is this happening? How should I do? I am not computer, so any help you can give me please answer clear and detailed ste

  • Tecra M9 - upgrade to Windows 7

    Hi all I'm new here so please forgive if I made a mistake. I was given a Toshiba Tecra M9 PMT90E laptop from a friend. I want to upgrade to Windows 7 ultimate 32 bit of Windows Vista Business 32-bit. I downloaded the drivers for the laptop for Window

  • Cannot run recovery disk on Tecra A10

    I'm trying to do a system restore on my Tecra laptop a10 and follow the instruction to hold down the zero key and then pressing the start button.The hard drive recovery mode message appears at the bottom of the screen but then the laptop computer wil

  • TOUCH DOWN in case

    When to use BUTTON down in the event, this event has raised for each press key (keyboard), the question I need event raised for only 1 button; for example, press F2 triggered and event not triggered for the other key of the keyboard. Thank you

  • How to get constants into Labview which will have an impact on the graph?

    How should I enter constants in Labview where x and are dependent on them? Ex. Say I create a graph of voltage vs time and I want to have of the constants as trigger (for example, wanting my chart to start the recording of the data when it reaches 20