{"id":157,"date":"2026-07-15T14:45:58","date_gmt":"2026-07-15T05:45:58","guid":{"rendered":"https:\/\/tate.stars.ne.jp\/wpa\/?p=157"},"modified":"2026-07-15T14:45:58","modified_gmt":"2026-07-15T05:45:58","slug":"myplayer2bossbullet","status":"publish","type":"post","link":"https:\/\/tate.stars.ne.jp\/wpa\/myplayer2bossbullet.html","title":{"rendered":"myPlayer2BossBullet"},"content":{"rendered":"<pre><code class=\"swift\">\nimport * as Phaser from 'phaser';\nexport class BossBullet extends Phaser.Physics.Arcade.Sprite {\nconstructor(scene: Phaser.Scene, x: number, y: number) {\nsuper(scene, x, y, 'bossbullet');\n scene.add.existing(this);\n scene.physics.add.existing(this);\n}\n\/\/ \u5f3e\u3092\u767a\u5c04\u3059\u308b\u30e1\u30bd\u30c3\u30c9\uff08\u30d7\u30ec\u30a4\u30e4\u30fc\u306e\u73fe\u5728\u4f4d\u7f6e\u3068\u79fb\u52d5\u901f\u5ea6\u304b\u3089\u672a\u6765\u4f4d\u7f6e\u3092\u4e88\u6e2c\u3057\u3066\u72d9\u3046\uff09\npublic fire(targetX: number, targetY: number, targetVx: number, targetVy: number, speed: number = 300, angle: number) {\n this.setActive(true);\n this.setVisible(true);\n \/\/  this.setAngle(Phaser.Math.RadToDeg(angle));\n\/\/ \u7c21\u6613\u7684\u306a\u504f\u5dee\u5c04\u6483\uff08\u5f3e\u304c\u5c4a\u304f\u307e\u3067\u306e\u6642\u9593\u3092\u4e88\u6e2c\u3057\u3066\u7740\u5f3e\u70b9\u3092\u88dc\u6b63\uff09\nconst distance = Phaser.Math.Distance.Between(this.x, this.y, targetX, targetY);\nconst timeToTarget = distance \/ speed;\n\/\/ \u30d7\u30ec\u30a4\u30e4\u30fc\u306e\u79fb\u52d5\u65b9\u5411\uff08\u901f\u5ea6\uff09\u3092\u52a0\u5473\u3057\u305f\u4e88\u6e2c\u4f4d\u7f6e\nconst predictX = targetX + targetVx * (timeToTarget * 0.5); \/\/ \u88dc\u6b63\u73870.5\u3067\u9069\u5ea6\u306b\u72d9\u3046\nconst predictY = targetY + targetVy * (timeToTarget * 0.5);\n\/\/ \u4e88\u6e2c\u4f4d\u7f6e\u306b\u5411\u3051\u3066\u89d2\u5ea6\u3092\u8a08\u7b97\n\/\/const angle = Phaser.Math.Angle.Between(this.x, this.y, predictX, predictY);\n\/\/ \u7269\u7406\u4f53\u306b\u901f\u5ea6\u3092\u8a2d\u5b9a\n if (this.body) {\n  this.scene.physics.velocityFromAngle(Phaser.Math.RadToDeg(angle), speed, this.body.velocity);\n }\n }\nupdate() {\n\/\/ \u753b\u9762\u5916\u306b\u51fa\u305f\u3089\u81ea\u52d5\u7684\u306b\u975e\u30a2\u30af\u30c6\u30a3\u30d6\u5316\nif (this.y < 0 || this.y > this.scene.scale.height || this.x < 0 || this.x > this.scene.scale.width) {\nthis.setActive(false);\nthis.setVisible(false);\n}\n}\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>import * as Phaser from &#8216;phase&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-157","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\/157","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=157"}],"version-history":[{"count":1,"href":"https:\/\/tate.stars.ne.jp\/wpa\/wp-json\/wp\/v2\/posts\/157\/revisions"}],"predecessor-version":[{"id":158,"href":"https:\/\/tate.stars.ne.jp\/wpa\/wp-json\/wp\/v2\/posts\/157\/revisions\/158"}],"wp:attachment":[{"href":"https:\/\/tate.stars.ne.jp\/wpa\/wp-json\/wp\/v2\/media?parent=157"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tate.stars.ne.jp\/wpa\/wp-json\/wp\/v2\/categories?post=157"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tate.stars.ne.jp\/wpa\/wp-json\/wp\/v2\/tags?post=157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}