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

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현