Howdy, Stranger!

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

A bit of help?? (With touch bug)

edited August 7 in Bugs Posts: 104

So I’m trying to fix this bug in my game. The bug is around the touch function. I’ve done some code that senses when you touch the screen and if you do, a spacecraft model will go straight into the distance. It would be fine and dandy for my game, BUT if I don’t touch the screen within a few seconds nothing happens if I then try to touch the screen. Can someone please help me fix this bug? Thanks :)

Comments

  • Posts: 2,364
    @Creator27 - please post some code then we can see where your problem is.
  • Posts: 104

    It’s all good, I think I found out what the problem was, and I used it to my advantage! Thank you though! :)

  • AnatolyAnatoly Mod
    Posts: 893
    function touched(touch)
        -- You can use the touch object here
    end
    

    Like this you declare a function that will be called when the screen is touched. You can read all about the Touch function here; https://codea.io/reference/Touch.html

    The important thing for you however is the state (touch.state) attribute, it can be BEGAN or ENDED (and some more)

    What you can do to recognize if the screen is touched, to set the state of the touch to a variable, then wether or not the screen is touched do whatever you want.

    The problem here however will be multiple touches at once :p

    @Bri_G you should get a “Mod” role already :p

Sign In or Register to comment.