고도엔진에서 전처리문으로 모바일과 에디터환경 나누기

extends Node2D  # 또는 Node2D (2D 게임의 경우)

@export var label: Label

func _input(event: InputEvent) -> void:

# 모바일 환경에서만 실행

if OS.has_feature("mobile"):

if event is InputEventScreenTouch:

if event.is_pressed():

Jump()

elif event.is_released():

pass

# 에디터 환경에서만 실행

elif OS.has_feature("editor"):

if Input.is_action_pressed("my_input"):

Jump()

func Jump():

print("점프")


터치이벤트를 에디터와 모바일환경을 따로 나누고 싶을 때 OS.has_feature("mobile") or OS.has_feature("editor") 







댓글

이 블로그의 인기 게시물

[코틀린] 고도용 안드로이드 플러그인 CameraX 기능파악을 위한 앱 실습 codelabs

일시정지에서 특정 노드만 사용되게 하고 싶다면 get_tree().paused=false

cpp 작업을 위한 비쥬얼스튜디오에서 고도프로젝트 열기