this.touching property help

I recently learned that you can check to see if an object is colliding against a specific side of a collider. However, I run this code to test if it works:

var bool = str(platform.touching.left);
text(bool, 100, 100);

And it returns the error Cannot read property 'left' of undefined. Why is this not working? Help would be greatly appreciated :)



  • Answer ✓

    Cannot read property 'left' of undefined

    It means property touching is undefined. 8-X

  • edited December 2017

    Oof. I assume the property was never implemented; it's there in the library though, so I'll double check my code again/look for examples that use this property, if any.

    EDIT: I know what I did wrong, and it was so silly. The platform is an object I created, and I was defining a property that never existed within the class. I'll modify the code so it doesn't do that and report if it's a success.

  • edited December 2017

    Ok, now my code won't return errors, but it always returns false for any side I try to check. I read in the docs that it was used in conjunction with collide() and overlap(), but those already return boolean values themselves. I've also tried:

    if(player.collide(platform) && player.touching.left)

    But that doesn't work. I tried to look it up, but I didn't find anything. Can somebody help please? :)

    EDIT: I figured it out, just took some testing and time :)

Sign In or Register to comment.