header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
CyberPunk
Points:10
Posts:0

4/30/2010 2:39:13 PM

Title: BOWLING PIN COLLISION:


BOWLING PIN COLLISION:

I wanted to try bowling pin collision, when the bowling ball touches, pins gets moved.

But...The pins themselves won't knock each other around, hmmm.[pin animation is placed in timeline]

I can't seem to figure out how to make them cause collision between themselves...HELP!

I have tried several ideas, none of them seems to work.

what i tried is working only with one single pin vs ball:

>hitTestObject
>hitTestPoint [in some cases it is working otherwisw no response]


P = is a MovieClip Contain PINS.
A = is Pin name [A to J || 1 to 10]
hit = is pin hit area [for ball collision when ball hits it will be removed]
phit = is pin to pin hit area i created .

if (_ball.HitArea.hitTestObject(P.A.hit))
{
	_isPinADown = true;
	if(_isPinADown)
	{
		//INCREASES SCORE
	}
	
	//LEFT
	if(_ball.x > 174.0 && _ball.x < 215.0){

		//trace("LEFT");
		P.A.gotoAndStop("Left");//PLAY THE ANIMATION
		P.A.play();
		P.A.removeChildAt(3); //REMOVES HIT AREA OF PIN [PLACES IN TIMELINE]

		//PIN TO PIN COLLISIONS
		
		//------------------- A - B --------------------

		/*if(P.A.phit.hitTestObject(P.B.phit))
		{
			trace("A - B");
			//DO REACTION ANIMATION	
			//P.B.removeChildAt(2);
		}*/

	}
	//RIGHT
	if(_ball.x > 258.0 && _ball.x < 281){

		//trace("RIGHT");
		P.A.gotoAndStop("Right");
		P.A.play();
		P.A.removeChildAt(3);

		//------------------- A - E --------------------

		/*if(P.A.phit.hitTestObject(P.E.phit))
		{
			trace("A - E");
			//DO REACTION ANIMATION	
			//P.E.removeChildAt(2);
		}*/

	}

	//FRONT
	if(_ball.x > 200 && _ball.x < 258){

		//trace("FRONT");
		P.A.gotoAndStop("Front");
		P.A.play();
		P.A.removeChildAt(2);

		//------------------- A - C --------------------

		/*if(P.A.phit.hitTestObject(P.c.phit))
		{
			trace("A - C");
			//DO REACTION ANIMATION	
			//P.C.removeChildAt(2);
		}*/

	}
	
	
	
}//A
Please help me out of this i have no time and it is getting worth... am stuck in this and still have problems with split detector coz of this. Asim Thanx in Advance



1
Dave
Points: 970
Posts:1
4/30/2010 9:56:38 PM



you are able to detect ball vs pin collisions and not able to detect pin vs pin collision right? Why have you put the pin collision code in hittest code of ball and pin , it will never execute

if (_ball.HitArea.hitTestObject(P.A.hit))

I can help you out but i need the project. If you can share on some file sharing website like http://2shared.com/.

2
CyberPunk
Points: 10
Posts:0
5/1/2010 11:53:51 PM



Hi Dave!

Thanx for the response. yes i am able to detect ball vs pin collision but i can't do pin vs pin collision.

I put pin vs pin collision code inside the ball vs pin collision code because when ball hit the pin A then animation and result it pin A moved from its location to left right or backward so then it can hit the backward pins or left right pins therefore i put that code right in the ball vs pin collisoin code. but it won't do any thing.. i also checked shape to shape collision but i think i am missing something important in this type of collision...

i am very thankfull to you if you help me out from this and i can give only the swf because of my company's privacy rules.. i cannot give you the whole project...

thanx again..
Asim.

3
Dave
Points: 970
Posts:1
5/2/2010 12:19:13 AM



As you told the flow. To my opinion the the PIN to PIN collision code cannot be inside the ball vs pin collision condition. See if you put the pin vs pin code inside the ball vs pin code it means that . Pin vs pin code will work only if the ball is also hitting pin and pin is also hitting pin, so it actually becomes an AND condition. You need to have a separate code for pin vs pin collision out side the condition.
if (_ball.HitArea.hitTestObject(P.A.hit))



4
Flash_Guy
Points: 830
Posts:0
5/2/2010 12:27:47 AM



when pin is colliding with pin , i don't see any relationship between ball then. So after ball collision then animation the pin collision code will never execute. you can simply put the pin collision code to root as you did with ball.

If u are still not able to get me. Create a simple example just this functionality and share the fla file , if you cant share proj. I would love to solve this :)

5
CyberPunk
Points: 10
Posts:0
5/4/2010 1:15:10 PM




@DAVE :> Hi Dave And Flash_Guy !!

sorry am late coz of some work.. any ways friends i did put the pin vs pin collision code out of the ball vs pin code block and it works but there are still problems like when ball hit pin A then pin A have conditions to check that from which direction [ i mean front left and right directions ] then if pin A move to right then it will hit the pin B
and then pin B hit other on side but it is not looking as expected after collision for ex: ball just hits pin A then Pin A hits B and and so on,all the pins will down one bye one and this seems to be a strike on every throw .
dont mind my bad english. :P

and thank you so much friends...

here are the example flash files, i have compressed them in two formats:
CS4
CS5

just download and change the extension to .rar from .text or .txt.

links:

CS4
https://acrobat.com/#d=DJUVm3ps64pBRgWLU2ugmg

CS5
https://acrobat.com/#d=pOWVfa-*vOeiTTgp6N7oBw

6
Dave
Points: 970
Posts:1
5/5/2010 5:20:31 AM



Hi CyberPunk i am not able to open the CS4 version in my Flash CS4 , I think you zipped the wrong version

7
CyberPunk
Points: 10
Posts:0
5/5/2010 12:54:27 PM



HI DAVE I UPLOADED THE CS4 FILE TO THIS LINK

PREVIOUS FILE WAS CS5 VERSION I MISTAKEN...

http://www.4shared.com/file/yaGIYmSi/CS4_VERSION_OK.html

REGARDS ASIM


Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 3+5 



Members Login

Email  
Password
Forgot Password





This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions