A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Tring to make things collide in arrays

  1. #1
    Junior Member
    Join Date
    Aug 2012
    Posts
    1

    Tring to make things collide in arrays

    i tried to make sure that when my circle hits the fblue platforms(which are in the floors array) that it would stop its gravity
    but the character stops his gravity in mid air reguardless like if i was testing the whole level.

    Code:
    for (var i:Number = 0; i < Main.floors.length; i++)
    			{
    				if (Main.floors[i].hitTestObject(this))
    				{
    					grav = 0;
    					jumped = false
    				}
    				else
    				{
    					grav++;
    				}
    			}
    but im not..im testing the blue platforms in the testlevel which the blue platforms are linked to the "ground_blue" class which THAT is linked to the static array called floors(the blue platforms are the only objects in the array)

    Whats wrong with my code? Or am i supposed to make a hitTest against the ground_blue class instead of a array.


    Here are my files if you need them:New WinRAR ZIP archive.zip
    or this link:http://www.mediafire.com/?g7916hzac0xyzit

    I know i didnt display(addChild(flor)) the "flor" object which is basically the blue platform
    because its already in the "j" movieclip which is linked to the "j" class,just like the circle
    and the circle works extacly how its supposed to.

  2. #2
    Member
    Join Date
    Jul 2012
    Posts
    39
    I think that a break statement should do the trick... So:
    Code:
    for (var i:Number = 0; i < Main.floors.length; i++)
    {
    	if (Main.floors[i].hitTestObject(this))
    	{
    		grav = 0;
    		jumped = false;
                    break;   //////////THIS LINE
    	}
    	else
    	{
    		grav++;
    	}
    }
    Hope that works...

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