title: What's a more efficient way to do collisions?
body: <p>Here's my dilemma</p>
  
  <p>I have 4 walls around the stage of my game, when a player hits these walls I do not want to make an if statement for each and every one of the walls checking if the player is hitting it, so I have created an array to hold the walls, then check if the player is hitting that.  Now, because I am doing this I will not know what the player is actually hitting if he hits something, and I cannot do a check in my array if he's hitting like <code>[0], [1], [2]</code> etc because then I'm back to doing the checks if he's hitting specific walls.  The reason I don't want to do that is for the future, when I add more barriers, buildings, and so on.</p>
  
  <p>So my question is, how can I do collision checks, without hard coding checks on specific objects, and giving some sort of value that can be used for the player to respond to, for example if your hitting the top wall and you can figure that out somehow without doing the above, then make it so you can't walk through or something, </p>
  
  <pre><code>if (main.playerPosKeeper_mc.hitTestObject(this[main.StageCollisions]))
  {
      trace("hit");
  }
  </code></pre>
  
  <p>StageCollisions is an array which contains all of my barriers in it.</p>
  
  <p>When the player hits anything in StageCollisions, I cannot just simply subtract from his y value, or x value, because I do not know which object he hit, <em>but I also do not want to hard code it so that I check if I'm hitting lets say the top barrier, because then why do an array in the first place if I'm just going back to making static if else statements.</em></p>
  
  <p><strong><em>^^ Refrencing this topic</em></strong></p>
  
  <p><a href="https://stackoverflow.com/questions/42148445/as3-how-to-cycle-states-of-character-animations-moving-stopped">AS3 - How to Cycle States of Character Animations (moving &amp; stopped)</a></p>
  
  <p>This has been stumping me for a little while, so help would be greatly appreciated.   It is a hard question to form so I can clarify points if necessary.</p>