Topic was automatically imported from the old Question2Answer platform.
Asked By
System_Error
Hi all.
Figured I’d attempt to get one of my working games prepped for mobile, but I’m a little confused as to how I should get this done.
I want to use InputEventScreenTouch. There are three main divisions for my screen (two for rotating the turret, one for shooting), and I’ve been attempting to figure out how to make these areas without adding extra nodes.
Below is what I’m trying to implement into my get_input() function.
if InputEventScreenTouch.is_pressed() == true:
var TouchPoint = InputEventScreenTouch.get_position()
if TouchPoint is in LeftTurnArea:
rotation_Direction -= 1.25
if TouchPoint is in RightTurnArea:
rotation_Direction += 1.25
if TouchPoint is in ShootArea:
fire()
In its current state, the error detector’s complaining about improper use of in. What’s a better way of doing this?
And the areas;
onready var LeftTurnArea #Upper left quarter of the screen.
onready var RightTurnArea #Lower left quarter of the screen.
onready var ShootArea #Right half of the screen
Yeah, I figured I wasn’t using is and in the right way, but I wasn’t sure how to do it right. Sometimes I forget that English and GDScript are two completely different languages.
Thank you very much.
System_Error | 2020-02-14 20:08
Huh… getting an error.
Non-static function "is_pressed" can only be called from an instance.
System_Error | 2020-02-16 17:46
That’s part of the code you provided in your question, so assumed it’d would work already. See here for a solution.