{"id":23,"date":"2026-04-15T09:28:59","date_gmt":"2026-04-15T00:28:59","guid":{"rendered":"https:\/\/tate.stars.ne.jp\/wpa\/?p=23"},"modified":"2026-04-25T17:52:49","modified_gmt":"2026-04-25T08:52:49","slug":"player","status":"publish","type":"post","link":"https:\/\/tate.stars.ne.jp\/wpa\/player.html","title":{"rendered":"Player"},"content":{"rendered":"<pre><code class=\"swift\">\nimport Phaser from 'phaser';\nexport default class Player extends Phaser.Physics.Arcade.Sprite {\n private readonly animKeyRun: string = 'run';\n private readonly animKeyRight: string = 'right';\n constructor(scene: Phaser.Scene, x: number, y: number, texture: string) {\n super(scene, x, y, texture);\n scene.add.existing(this);\n scene.physics.add.existing(this);\n this.setDepth(2);\n this.setCollideWorldBounds(true);\n  this.createAnimations(scene);\n this.setFlipX(false);\n  }\n createAnimations(scene: Phaser.Scene) {\n   this.anims.create({\n      key: this.animKeyRun,\n      frames: this.anims.generateFrameNumbers('player', {\n       start: 0,\n       end: 2\n   }),\n    frameRate: 6,\n     repeat: -1\n   });\n    this.anims.create({\n     key: this.animKeyRight,\n    frames: [{key: 'player', frame: 1}],\n    frameRate: 6\n     });\n }\n\nupdate(joyStick: any){\n  const speed = 200;\n  this.setVelocityY(speed);\n  if (joyStick.left) {\n   this.setVelocityX(-speed);\n   this.anims.play(this.animKeyRun, true);\n  this.flipX = true;\n   } else if (joyStick.right) {\n   this.setVelocityX(speed);\n   this.anims.play(this.animKeyRun, true);\n   this.flipX = false;\n  } else {\n  this.setVelocityX(0);\n  this.anims.play(this.animKeyRight, true);\n  }\n if (joyStick.up) {\n    this.setVelocityY(-600);\n   if (this.y < 80) {\n   this.setVelocityY(0);\n     }\n    }\n  }\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>import Phaser from &#8216;phaser&#8217;; e&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,3],"tags":[],"class_list":["post-23","post","type-post","status-publish","format-standard","hentry","category-phaser4","category-typescript"],"_links":{"self":[{"href":"https:\/\/tate.stars.ne.jp\/wpa\/wp-json\/wp\/v2\/posts\/23","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tate.stars.ne.jp\/wpa\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tate.stars.ne.jp\/wpa\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tate.stars.ne.jp\/wpa\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tate.stars.ne.jp\/wpa\/wp-json\/wp\/v2\/comments?post=23"}],"version-history":[{"count":2,"href":"https:\/\/tate.stars.ne.jp\/wpa\/wp-json\/wp\/v2\/posts\/23\/revisions"}],"predecessor-version":[{"id":79,"href":"https:\/\/tate.stars.ne.jp\/wpa\/wp-json\/wp\/v2\/posts\/23\/revisions\/79"}],"wp:attachment":[{"href":"https:\/\/tate.stars.ne.jp\/wpa\/wp-json\/wp\/v2\/media?parent=23"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tate.stars.ne.jp\/wpa\/wp-json\/wp\/v2\/categories?post=23"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tate.stars.ne.jp\/wpa\/wp-json\/wp\/v2\/tags?post=23"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}