LoginSignup
0
1

More than 3 years have passed since last update.

【Godot】Spriteをキー入力で左右反転させる

Last updated at Posted at 2021-01-24

プロジェクト>プロジェクト設定>インプットマップから
「move_right」「move_left」のアクションを追加し、キーを割り当てる。
keyshortcut.png

スプライトを作成し、以下のスクリプトをアタッチ。
$Spriteはスプライト名を入れる。

Player.gd
func _process(delta):
    if Input.is_action_pressed("move_right"):
        $Sprite.set_flip_h( false )
    elif Input.is_action_pressed("move_left"):
        $Sprite.set_flip_h( true )

これでSpriteを左右反転できる。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1