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;
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
add a comment |
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
>Anyone help me
– virtual
Mar 25 at 8:53
add a comment |
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
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
actionscript-3
asked Mar 24 at 14:21
virtualvirtual
33
33
>Anyone help me
– virtual
Mar 25 at 8:53
add a comment |
>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
add a comment |
1 Answer
1
active
oldest
votes
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--;
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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--;
add a comment |
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--;
add a comment |
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--;
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--;
answered Mar 25 at 11:54
obscureobscure
3,1171623
3,1171623
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
>Anyone help me
– virtual
Mar 25 at 8:53