Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Touch Function.

edited June 2014 in General Posts: 178

I am having trouble using the touch function from classes other than the main one. For example, if I try calling the function inside the main class it doesn't work, and I can't call the function inside the class where it is needed, or otherwise is presents me with an error. Can anyone help me out on a possible solution as I never really got the hang of this, and have been putting this off for some time. Thanks!



  • edited June 2014 Posts: 82

    @DarrellBro I'm sorry, I just can't stand the sight of this. It's you're, not your.

    @YoloSwag I'm not sure what you've already done, so I'm just giving the basics here.

    If you have defined MyClass = class() and a function MyClass:touched(touch), you can call the touch function like this:

    function setup()
        obj = MyClass()
    function touched(touch)

    Make sure you pass the touch userdata to the function every time you call it.

  • edited June 2014 Posts: 425

    Something like this

    function setup()
    function touched(touch)
    Car = class()
    function Car:touched(touch)

    Edit: i just posted a second after @Kjell

  • Posts: 178

    Thank you both. This helps a lot!

Sign In or Register to comment.