A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Collision Detection

  1. #1
    Junior Member
    Join Date
    Oct 2008
    Posts
    13

    Collision Detection

    Hi everyone!

    I am wanting a simple script that will take 3 squares on the stage. They will be positioned to form an L type shape. Each square can scale in size both width and height.

    Now if the squares touch each other as they increase in size, the square that is being touched (not the one scaling up) decreases in size which ever way the touching square is going.

    So if square a is increasing in width from the left to the right and square b is on the right of square a, square b decreases in size going from left to right.

    Hope that makes sense. Any help would be great.

  2. #2
    Senior Member
    Join Date
    Jan 2008
    Posts
    150
    Something like

    Code:
    for (var i:int = 0; i < some_array.size; i  = i + 1)
    	{
    		some_array(i).scale_me(up_input);
    		for (var j:int = 0; j < some_array.size; j  = j + 1)
    		{
    			if (i =/ j)
    			{
    				if (some_array(i).hitTestObject(some_array[j]);)
    				{
    					some_array(j).scale_me(down_input)
    				}
    			}
    		}
    	}
    Been awhile since I did this so that might be fairly brain dead.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center