Be a Supporter!

AS problem (hit test)

  • 275 Views
  • 5 Replies
New Topic Respond to this Topic
Bluehare
Bluehare
  • Member since: Jun. 13, 2009
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
AS problem (hit test) 2010-06-02 17:09:03 Reply

Every time i move my character against the top left and bottom left corners he somehow slides through, everywhere else is perfectly sealed off, just those corners

The script itself is here:

onClipEvent(enterFrame){
	if(Key.isDown(Key.UP)){
		this._y -= 4;
	}else if(Key.isDown(Key.DOWN)){
		this._y += 4;
	}
	if(Key.isDown(Key.LEFT)){
		this._x -= 4;
	}else if(Key.isDown(Key.RIGHT)){
		this._x += 4;
	}
	if(_root.maze.hitTest(_x+(_width/0.73),_y,true)){
		this._x -= 4;
	}
	if(_root.maze.hitTest(_x-(_width/-2),_y,true)){
		this._x += 4;
	}
	if(_root.maze.hitTest(_x,_y+(_height/1.5),true)){
		this._y -= 4;
	}
	if(_root.maze.hitTest(_x,_y-(_height/5),true)){
		this._y += 4;
	}
}

The walls are 6 pixels wide and theres a 12 pixel gap between each wall (not that that makes a difference right?)

<deleted>
Response to AS problem (hit test) 2010-06-02 17:53:17 Reply

Try using while statements to move the character until he is not colliding anymore.

Bluehare
Bluehare
  • Member since: Jun. 13, 2009
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to AS problem (hit test) 2010-06-02 18:00:26 Reply

At 6/2/10 05:53 PM, SmartNoob wrote: Try using while statements to move the character until he is not colliding anymore.

I'm not familiar with "while" statements, how would i go about placing these in the code?

Treerung
Treerung
  • Member since: Apr. 18, 2008
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to AS problem (hit test) 2010-06-02 18:02:52 Reply

Can you post a .fla so I can see the problem? You gave a terrible description..


:'(

BBS Signature
Bluehare
Bluehare
  • Member since: Jun. 13, 2009
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to AS problem (hit test) 2010-06-02 18:10:56 Reply

At 6/2/10 06:02 PM, Treerung wrote: Can you post a .fla so I can see the problem? You gave a terrible description..

Mmk, bear in mind i started it about two hours ago so the design isn't great but here you go

Link

<deleted>
Response to AS problem (hit test) 2010-06-02 18:11:53 Reply

At 6/2/10 06:00 PM, Bluehare wrote:
At 6/2/10 05:53 PM, SmartNoob wrote: Try using while statements to move the character until he is not colliding anymore.
I'm not familiar with "while" statements, how would i go about placing these in the code?

If you don't even know what a while statement is, then I would highly suggest learning the basics of ActionScript.

Also here is an example of while statements.