Double hit test detectionCustom (simple) AS3 Class code not executing entirelyAccessing Labels in AS3?Moving objects with TimerURLStream throws Error#2029 in my flex AIR appRemoving array-objects from DisplayListmultipart/x-mixed-replace ActionScript3 and Google Chrome (and others as well)The supplied DisplayObject must be a child of the callerAccumulate score in AS3How to push instantiated MC into Array dynamically?Generating Random Instances from library Actionscript 3

Is it possible to trip with natural weapon?

Do manufacturers try make their components as close to ideal ones as possible?

Incremental Ranges!

Who operates delivery flights for commercial airlines?

Short story written from alien perspective with this line: "It's too bright to look at, so they don't"

Is the decompression of compressed and encrypted data without decryption also theoretically impossible?

Through what methods and mechanisms can a multi-material FDM printer operate?

What's the correct term for a waitress in the Middle Ages?

How to decline physical affection from a child whose parents are pressuring them?

Working in the USA for living expenses only; allowed on VWP?

Is it legal in the UK for politicians to lie to the public for political gain?

What is the traditional way of earning a doctorate in Germany?

What risks are there when you clear your cookies instead of logging off?

How can I instantiate a lambda closure type in C++11/14?

What is in `tex.print` or `tex.sprint`?

Calling GPL'ed socket server inside Docker?

Pronoun introduced before its antecedent

Adding two lambda-functions in C++

Finding row wise sum of transpose of hv-convex binary matrix

Bent spoke design wheels — feasible?

Funtion to extract float from different price patterns

Implement Homestuck's Catenative Doomsday Dice Cascader

What can plausibly explain many of my very long and low-tech bridges?

How can drunken, homicidal elves successfully conduct a wild hunt?



Double hit test detection


Custom (simple) AS3 Class code not executing entirelyAccessing Labels in AS3?Moving objects with TimerURLStream throws Error#2029 in my flex AIR appRemoving array-objects from DisplayListmultipart/x-mixed-replace ActionScript3 and Google Chrome (and others as well)The supplied DisplayObject must be a child of the callerAccumulate score in AS3How to push instantiated MC into Array dynamically?Generating Random Instances from library Actionscript 3






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-1















I want to create brick breaker game.The brick(movieClip) object have been kept in array.So I want to destroy the brick after two time collision.Already i have been destroy brick after one time collision.But I want to destroy the brick after two time collision. When first time collision detected then change the brick color and second time destroy the brick.How can I solve this problem.Please help me.
Here the brick create function.



private function createLabell():void

for(var i:Number=0;i<totalBricks;i++)

if(i==2)

newBrick=new Power();
else

newBrick=new Brick();

bg_mc.addChild(newBrick);
newBrick.x=50*row+10;
newBrick.y=30 *col+40;
label1.push(newBrick)

row++;
if(row>8)

row=0;
col++;
//trace(col);

//trace(label1[i]);




Here the collision part(one time collision).



private function collisionDetectionn():void

for(var i:Number=0;i<label1.length;i++)

var bk:MovieClip = label1[i] as MovieClip;
if(bg_mc.ball.hitTestObject(bk))

ballYSpeed *=-1;
brickCount++;
scores+=5;
bk.parent.removeChild(bk);
label1.splice(i,1);
i--;






But I want to destroy the brick after two time collision.Thanks in advanced.










share|improve this question






















  • >Anyone help me

    – virtual
    Mar 25 at 8:53

















-1















I want to create brick breaker game.The brick(movieClip) object have been kept in array.So I want to destroy the brick after two time collision.Already i have been destroy brick after one time collision.But I want to destroy the brick after two time collision. When first time collision detected then change the brick color and second time destroy the brick.How can I solve this problem.Please help me.
Here the brick create function.



private function createLabell():void

for(var i:Number=0;i<totalBricks;i++)

if(i==2)

newBrick=new Power();
else

newBrick=new Brick();

bg_mc.addChild(newBrick);
newBrick.x=50*row+10;
newBrick.y=30 *col+40;
label1.push(newBrick)

row++;
if(row>8)

row=0;
col++;
//trace(col);

//trace(label1[i]);




Here the collision part(one time collision).



private function collisionDetectionn():void

for(var i:Number=0;i<label1.length;i++)

var bk:MovieClip = label1[i] as MovieClip;
if(bg_mc.ball.hitTestObject(bk))

ballYSpeed *=-1;
brickCount++;
scores+=5;
bk.parent.removeChild(bk);
label1.splice(i,1);
i--;






But I want to destroy the brick after two time collision.Thanks in advanced.










share|improve this question






















  • >Anyone help me

    – virtual
    Mar 25 at 8:53













-1












-1








-1








I want to create brick breaker game.The brick(movieClip) object have been kept in array.So I want to destroy the brick after two time collision.Already i have been destroy brick after one time collision.But I want to destroy the brick after two time collision. When first time collision detected then change the brick color and second time destroy the brick.How can I solve this problem.Please help me.
Here the brick create function.



private function createLabell():void

for(var i:Number=0;i<totalBricks;i++)

if(i==2)

newBrick=new Power();
else

newBrick=new Brick();

bg_mc.addChild(newBrick);
newBrick.x=50*row+10;
newBrick.y=30 *col+40;
label1.push(newBrick)

row++;
if(row>8)

row=0;
col++;
//trace(col);

//trace(label1[i]);




Here the collision part(one time collision).



private function collisionDetectionn():void

for(var i:Number=0;i<label1.length;i++)

var bk:MovieClip = label1[i] as MovieClip;
if(bg_mc.ball.hitTestObject(bk))

ballYSpeed *=-1;
brickCount++;
scores+=5;
bk.parent.removeChild(bk);
label1.splice(i,1);
i--;






But I want to destroy the brick after two time collision.Thanks in advanced.










share|improve this question














I want to create brick breaker game.The brick(movieClip) object have been kept in array.So I want to destroy the brick after two time collision.Already i have been destroy brick after one time collision.But I want to destroy the brick after two time collision. When first time collision detected then change the brick color and second time destroy the brick.How can I solve this problem.Please help me.
Here the brick create function.



private function createLabell():void

for(var i:Number=0;i<totalBricks;i++)

if(i==2)

newBrick=new Power();
else

newBrick=new Brick();

bg_mc.addChild(newBrick);
newBrick.x=50*row+10;
newBrick.y=30 *col+40;
label1.push(newBrick)

row++;
if(row>8)

row=0;
col++;
//trace(col);

//trace(label1[i]);




Here the collision part(one time collision).



private function collisionDetectionn():void

for(var i:Number=0;i<label1.length;i++)

var bk:MovieClip = label1[i] as MovieClip;
if(bg_mc.ball.hitTestObject(bk))

ballYSpeed *=-1;
brickCount++;
scores+=5;
bk.parent.removeChild(bk);
label1.splice(i,1);
i--;






But I want to destroy the brick after two time collision.Thanks in advanced.







actionscript-3






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 24 at 14:21









virtualvirtual

33




33












  • >Anyone help me

    – virtual
    Mar 25 at 8:53

















  • >Anyone help me

    – virtual
    Mar 25 at 8:53
















>Anyone help me

– virtual
Mar 25 at 8:53





>Anyone help me

– virtual
Mar 25 at 8:53












1 Answer
1






active

oldest

votes


















0














From what I can see, Brick is the base class for your bricks? What is Power?



Anyway, enhance Brick by a public variable collisions



public var collisions:int = 0;


It's a bit tricky now since you don't distinguish between Power and Brick in your collision detection. So we need to make sure it's a Brick first. Afterwards instead of simply removing a brick upon collision, increment it's collisions counter by 1 and finally remove the brick if it's 2.



var bk:MovieClip = label1[i] as MovieClip;
if(bg_mc.ball.hitTestObject(bk))

ballYSpeed *=-1;
brickCount++;
scores+=5;
if(bk is Brick)

Brick(bk).collisions++;
if(Brick(bk).collisions==2)

bk.parent.removeChild(bk);
label1.splice(i,1);
i--;


else

bk.parent.removeChild(bk);
label1.splice(i,1);
i--;







share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55324765%2fdouble-hit-test-detection%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    From what I can see, Brick is the base class for your bricks? What is Power?



    Anyway, enhance Brick by a public variable collisions



    public var collisions:int = 0;


    It's a bit tricky now since you don't distinguish between Power and Brick in your collision detection. So we need to make sure it's a Brick first. Afterwards instead of simply removing a brick upon collision, increment it's collisions counter by 1 and finally remove the brick if it's 2.



    var bk:MovieClip = label1[i] as MovieClip;
    if(bg_mc.ball.hitTestObject(bk))

    ballYSpeed *=-1;
    brickCount++;
    scores+=5;
    if(bk is Brick)

    Brick(bk).collisions++;
    if(Brick(bk).collisions==2)

    bk.parent.removeChild(bk);
    label1.splice(i,1);
    i--;


    else

    bk.parent.removeChild(bk);
    label1.splice(i,1);
    i--;







    share|improve this answer



























      0














      From what I can see, Brick is the base class for your bricks? What is Power?



      Anyway, enhance Brick by a public variable collisions



      public var collisions:int = 0;


      It's a bit tricky now since you don't distinguish between Power and Brick in your collision detection. So we need to make sure it's a Brick first. Afterwards instead of simply removing a brick upon collision, increment it's collisions counter by 1 and finally remove the brick if it's 2.



      var bk:MovieClip = label1[i] as MovieClip;
      if(bg_mc.ball.hitTestObject(bk))

      ballYSpeed *=-1;
      brickCount++;
      scores+=5;
      if(bk is Brick)

      Brick(bk).collisions++;
      if(Brick(bk).collisions==2)

      bk.parent.removeChild(bk);
      label1.splice(i,1);
      i--;


      else

      bk.parent.removeChild(bk);
      label1.splice(i,1);
      i--;







      share|improve this answer

























        0












        0








        0







        From what I can see, Brick is the base class for your bricks? What is Power?



        Anyway, enhance Brick by a public variable collisions



        public var collisions:int = 0;


        It's a bit tricky now since you don't distinguish between Power and Brick in your collision detection. So we need to make sure it's a Brick first. Afterwards instead of simply removing a brick upon collision, increment it's collisions counter by 1 and finally remove the brick if it's 2.



        var bk:MovieClip = label1[i] as MovieClip;
        if(bg_mc.ball.hitTestObject(bk))

        ballYSpeed *=-1;
        brickCount++;
        scores+=5;
        if(bk is Brick)

        Brick(bk).collisions++;
        if(Brick(bk).collisions==2)

        bk.parent.removeChild(bk);
        label1.splice(i,1);
        i--;


        else

        bk.parent.removeChild(bk);
        label1.splice(i,1);
        i--;







        share|improve this answer













        From what I can see, Brick is the base class for your bricks? What is Power?



        Anyway, enhance Brick by a public variable collisions



        public var collisions:int = 0;


        It's a bit tricky now since you don't distinguish between Power and Brick in your collision detection. So we need to make sure it's a Brick first. Afterwards instead of simply removing a brick upon collision, increment it's collisions counter by 1 and finally remove the brick if it's 2.



        var bk:MovieClip = label1[i] as MovieClip;
        if(bg_mc.ball.hitTestObject(bk))

        ballYSpeed *=-1;
        brickCount++;
        scores+=5;
        if(bk is Brick)

        Brick(bk).collisions++;
        if(Brick(bk).collisions==2)

        bk.parent.removeChild(bk);
        label1.splice(i,1);
        i--;


        else

        bk.parent.removeChild(bk);
        label1.splice(i,1);
        i--;








        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 25 at 11:54









        obscureobscure

        3,1171623




        3,1171623





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55324765%2fdouble-hit-test-detection%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript