A bit of help?? (With touch bug)

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 :slight_smile:

@Creator27 - please post some code then we can see where your problem is.

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

function touched(touch)
    -- You can use the touch object here

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 :stuck_out_tongue:

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