0

I am trying to detect when the player comes in contact with a platform, any idea why this is not working?

http://taffatech.com/Platformer.html

function checkCol()
{
for (var i=0;i<Platforms.length;i++)
{ 

if(Player.x > i.x && Player.x  < (i.x + i.width))
  {
    if(Player.y > i.y && Player.y < (i.y + i.height))
    {
    alert("hit");
    }
  }



}
}

1 Answer 1

2

i is just a number. It doesn't have width and height. It looks like you meant to use Platforms[i] instead.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, this is what sleep deprivation does! I'll accept your answer when it lets me :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.