A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Ball Vs Ball game

Hybrid View

  1. #1
    THE YELLOW FLASH!
    Join Date
    Feb 2008
    Posts
    57

    Unhappy Ball Vs Ball game

    Hi,

    I was searching for an algorithm for circle collision and i found this pretty much simple and understandable in the net.

    Code:
    http://www.emanueleferonato.com/2007/12/06/flash-ball-vs-ball-game-concept/
    But in this game,if we dont move the blue circle,the red will come and overlap the blue.How can i stop the red at the boundary of the blue if vx and vy (velocities of blue) is equal to zero?Or keep the red bouncing on blue even if the blue is still?

    Please help
    The CodeBreaker!

  2. #2
    THE YELLOW FLASH!
    Join Date
    Feb 2008
    Posts
    57
    I found the solution myself...and I did K.I.S.S!

    just add this code to "ball" MC's enterFrame()
    Code:
    if(this.hitTest(ball2))
    	{
    		if(ball._x>ball2._x)
    		  {this._x=this._x+1;}
    		if(ball._y<ball2._y)
    		  {this._y=this._y-1;}
    		if(ball._x<ball2._x)
    		  {this._x=this._x-1;}
    		if(ball._y>ball2._y)
    		  {this._y=this._y+1;}  
    	}
    Regards!
    The CodeBreaker!

Tags for this Thread

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