1 Replies - 12351 Views - Last Post: 07 January 2013 - 06:35 AM

#1 Jono20201   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 179
  • Joined: 07-July 09

ActionScript Collision Detection not quite working

Posted 03 January 2013 - 05:33 AM

Hi guys,

Its not normal that I need help with a college assignment but this one has me truly stuck. The issue I have been having is that I want to have border around my 'room' in my game and when you go up to that wall it would stop you going any further. The issue I am having is that when I am in the middle of the boxes (inside the games walls) I can move up to the walls and go through them, however when I turn around and go back towards the inside of the box I cannot go back through. So it seems it only working one-way which is annoying. Unfortunately we have split up for Christmas break so I cannot ask my tutor for assistance.

I have tried multiple ways (multiple HitTestObject, and points etc) and tried looping through all the objects which are walls and testing each frame, however with no luck. If you could just give me a hint of where to go I would be very grateful.

Here is my detection code:

player.x = newX;
player.y = newY;
/*if(wallMovieclip.hitTestPoint(player.x, player.y, true)){
	//tried this, and it didn't work.
for (var i:int=0; i<wallMovieclip.numChildren; i++){
		player.x = oldX;
		player.y = oldY;

Here is also a zip of the whole thing if anyone want to have a closer look.

Thank you DIC!

Is This A Good Question/Topic? 0
  • +

Replies To: ActionScript Collision Detection not quite working

#2 stayscrisp   User is offline

  • フカユ
  • member icon

Reputation: 1040
  • View blog
  • Posts: 4,325
  • Joined: 14-February 08

Re: ActionScript Collision Detection not quite working

Posted 07 January 2013 - 06:35 AM

Hit test is nasty. It's not reliable at all.

You could use a bounding box collision detection, it would be a lot easier and more reliable. Also you should split up detecting x and y or you will get the issue you are having.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1