CoRサンプル集: タッチ操作不具合修正スクリプト

touch.rb - タッチ操作でも押下状態を取得できるようにRmakeMouse、RmakePointingクラスを修正
プレー:7 (人数:5) クリア:2 評価: 0 (0回)
Reversi
タグが設定されていません
require_code 'touch.rb' text :default do origin :center end sprite :default do origin :center end scene :main do sprites = {} texts = {} button_pressed = false button_pressed_count = 0 button_pressed_time = 0 button_size = [rmake_game.screen_width, rmake_game.screen_height].min * 0.5 create do texts[:button] = put_text :default do text "\u{2B1B}" position rmake_game.screen_width * 0.5, rmake_game.screen_height * 0.5 font_size button_size end sprites[:button] = put_sprite :default do position rmake_game.screen_width * 0.5, rmake_game.screen_height * 0.5 src_rect 0, 0, 1, 1 scale button_size, button_size end texts[:click_or_tap] = put_text :default do text 'CLICK or TAP' position rmake_game.screen_width * 0.5, (rmake_game.screen_height - button_size) * 0.25 end texts[:count] = put_text :default do text "You pressed\n0 times" position rmake_game.screen_width * 0.5, rmake_game.screen_height - (rmake_game.screen_height - button_size) * 0.25 end texts[:exit] = put_text :default do position rmake_game.screen_width * 0.5, (rmake_game.screen_height - button_size) * 0.375 font_size 20 end texts[:time] = put_text :default do position rmake_game.screen_width * 0.5, rmake_game.screen_height * 0.5 end texts[:pointer] = put_text :default do end end update do texts[:pointer].text pointer.down? ? "\u{1F446}" : "\u{1F91A}" texts[:pointer].position pointer.x, pointer.y if sprites[:button].tap_down? if !button_pressed button_pressed = true button_pressed_time = $window.Date.call(:now) * 0.001 texts[:button].text "\u{1F7E9}" button_pressed_count += 1 case button_pressed_count when 1 texts[:count].text "You pressed\nonce" when 2 texts[:count].text "You pressed\ntwice" else texts[:count].text "You pressed\n#{button_pressed_count} times" end elsif button_pressed_count > 10 time = 5 - $window.Date.call(:now) * 0.001 + button_pressed_time texts[:time].text time > 0 ? sprintf("%.1f", time) : 'Bye!' end elsif button_pressed button_pressed = false texts[:button].text "\u{2B1B}" texts[:time].text '' if button_pressed_count === 10 texts[:exit].text 'Long press to exit' elsif button_pressed_count > 10 && (($window.Date.call(:now) * 0.001 - button_pressed_time) > 5) game_clear end end GC.start end end start_scene :main
コード一覧
投稿者:Material 315238 1 mini shainy 対象Lv1 公開日:2024年05月12日 05:00:49
プレー内容を公開する

違反を通報する

コメントする

コメントするには、ログインする必要があります。

コメント一覧

コメントはありません。

プレー履歴

プレー履歴はありません。

全てのプレー履歴を見る

新着レビュー

レビューはまだ投稿されていません。 作品の感想を作者に伝えるためにレビューを投稿してみませんか?

全てのレビュー

フォロー/シェア

ブログ/Wiki/掲示板で共有する

Rmake内(ブログ/Wiki/掲示板)に貼り付ける場合は以下のタグを利用してください。

リンク

プレイヤー

外部ホームページに貼り付ける

外部ホームページに貼り付ける場合は以下のタグを利用してください。