phaser-framework

String of moving sprites following the player, most efficient way to do it?

孤人 提交于 2019-12-24 02:11:49
问题 I'm working on a JavaScript game using Phaser, where the player picks up blobs and the blobs then follow the player. So there will be a string of sprites following the player's movements, kind of like the "options" in Gradius or the line of balls in the game Zuma. My question is, what is the best way to get this effect? At the moment my method is like this: Keep a large array of x/y positions For each frame update, go to next array index Put the player x/y position in the array at current

Click event is working only in the circle centre

偶尔善良 提交于 2019-12-24 00:58:42
问题 When I use a circle, only its centre receives the event, if I click anywhere it doesn't work, only when I click in the circle centre. How can I make the whole circle clickable? const circle = this.add.circle(300, 300, 25, 0xff0000, 1); circle.setInteractive(); circle.on('pointerdown', function() { console.log("click"); }); Update : Using phaser 3 回答1: var config = { width: 800, height: 600, type: Phaser.AUTO, parent: 'phaser-example', scene: { create: create } }; var game = new Phaser.Game

Can I make a multiplayer Phaser game using Lance?

最后都变了- 提交于 2019-12-22 09:08:03
问题 How do I take an existing Phaser game and make it multiplayer? Can I use the Lance library for this purpose? Both libraries control their own game objects so I don't know how to use the two frameworks together in the same game. 回答1: Disclaimer: I am one of the co-creators of Lance Unfortunately, Phaser's 2.* architecture makes it hard to pair with Lance to make Realtime Javascript Multiplayer games. The issue is that Phaser makes a lot of assumptions that don't hold for a multiplayer setting.

How can I scale the size of a sprite in Phaser/PixiJS without changing its position?

♀尐吖头ヾ 提交于 2019-12-22 03:17:19
问题 I'm making a game in Phaser using some large images that I want to scale down in the actual game: create() { //Create the sprite group and scale it down to 30% this.pieces = this.add.group(undefined, "pieces", true); this.pieces.scale.x = 0.3; this.pieces.scale.y = 0.3; //Add the players to the middle of the stage and add them to the 'pieces' group var middle = new Phaser.Point( game.stage.width/2, game.stage.height/2); var player_two = this.add.sprite(middle.x - 50, middle.y, 'image1',

How can I scale the size of a sprite in Phaser/PixiJS without changing its position?

筅森魡賤 提交于 2019-12-22 03:17:06
问题 I'm making a game in Phaser using some large images that I want to scale down in the actual game: create() { //Create the sprite group and scale it down to 30% this.pieces = this.add.group(undefined, "pieces", true); this.pieces.scale.x = 0.3; this.pieces.scale.y = 0.3; //Add the players to the middle of the stage and add them to the 'pieces' group var middle = new Phaser.Point( game.stage.width/2, game.stage.height/2); var player_two = this.add.sprite(middle.x - 50, middle.y, 'image1',

Uncaught TypeError: Cannot read property 'apply' of undefined with phaser

ぐ巨炮叔叔 提交于 2019-12-21 19:57:24
问题 Im having the same problem again, i dont know how to fix this. Ive notced though the error pops up when the blue enemy reaches the bottom. Please help! JSBin Format click edit on top right corner to edit code Code: var game = new Phaser.Game(500, 550, Phaser.CANVAS, 'gameDiv'); var CountDown = { preload: function() { }, update: function() { }, render: function() { } } var player; var enemy; var bullets; var shields; var enemies; var greenEnemies var explosions; var score = 0; var scoreText;

TypeError: undefined is not a function (Phaser JS)

与世无争的帅哥 提交于 2019-12-13 08:19:48
问题 Hi everybody i'm just trying executing a method inside a class and it's not working. I got an "Uncaught TypeError: undefined is not a function" error. I'm calling others functions and it's working well so I don't understand. I've tried to change the name and nothing. I think that there is a problem with Phaser that I'm using but I've no idea... Bomb.prototype.collisionBlocs = function() { if (!this.hasBounced) { this.bounce(); this.hasBounced = true; } } Bomb.prototype.bounce = function() {

Phaser P2 Physics Hollow sprite

本小妞迷上赌 提交于 2019-12-12 18:35:35
问题 I am making a game with Phaser using P2 physics and I want to make a "Hollow" sprite. What I mean is I want a sprite in the shape of a square/rectangle that the player can be inside, so it cant be a solid body. I would also like to make one with a hole in it so the player can move inside. Currently the ways that I can think of of making it are a custom polygon or multiple sprites, Are there simpler ways? and, If I make a custom polygon that has no hole can I avoid a line going through it at

Destroying sprites in Phaser

孤者浪人 提交于 2019-12-12 10:28:52
问题 I'm having trouble destroying Sprites in Phaser. I have a JavaScript object, let's call it Block. Block has a sprite property, that gets set like so: this.sprite = this.game.add.sprite(this.x, this.y, 'blocks', this.color); At a certain point in my code, Block is referenced by two different arrays: square[0] = Block; destroy[0] = Block; On a certain Update() cycle, I need to destroy the sprite, so I'm using the following code: square[0].sprite.destroy(true); //Destroy the sprite. square[0] =

Disable auto-resizing in Phaser

扶醉桌前 提交于 2019-12-12 05:28:02
问题 I'm creating a responsive game with Phaser. The width is fixed to 360 and the height gets calculated to a fitting ratio. var height = (360 * screen.height) / screen.width; var game = new Phaser.Game(360, ratio, Phaser.AUTO, "", {preload: preload, create: create, update: update}); In the create() function I then resize it to 100%, so the screen is filled: function create () { document.querySelector("canvas").style.width = "100%"; document.querySelector("canvas").style.height = "100%"; // more