• Content count

  • Joined

  • Last visited

About strivinglife

Contact Methods

  • Website URL
  • Twitter

Profile Information

  • Gender

Recent Profile Visitors

478 profile views
  1. strivinglife

    Using a simple spritesheet animation without key

    For what it's worth, doing the following did work: // TypeScript // Creating the animations. for (let i = 1; i <= 13; i++) { for (let j = 1; j <= 19; j++) { this.anims.create({ key: 'stand_monsters_' + i + '_' + j, frames: this.anims.generateFrameNumbers('monsters_' + i + '_' + j, null), frameRate: 5, repeat: -1 }); } } // Calling this when creating the custom objects.'stand_monsters_' + style); Is there a recommended best practice on where to setup the animations? Since they're global, that would suggest creating them somewhere that might get called once. For my setup with multiple scenes (with the called order as below), I'm thinking in the Preloader.create() function, instead of where I have it now, instead MainGame.create(). this.scene.add(Boot.Name, Boot); this.scene.add(Preloader.Name, Preloader); this.scene.add(MainMenuScene.Name, MainMenuScene); this.scene.add(MainGame.Name, MainGame);
  2. strivinglife

    Using a simple spritesheet animation without key

    That makes sense, but each actual Sprite may have a different spritesheet. So I've got my monsters definition (Character doesn't add anything of importance, but extends Phaser.GameObjects.Group, in case it matters), where you can supply the style of monster asset to use. // TypeScript import Character from "./Character"; export default class Monster extends Character { constructor(scene: Phaser.Scene, x: number, y: number, style: string) { super(scene); // The base doesn't actually move at all. var characterBase = this.scene.add.sprite(x, y, 'avatar_1_1'); this.asset = 'monsters_' + style; this.body = this.scene.add.sprite(x, y, this.asset); } } A preloader scene is adding these as: // Load monsters. this.load.path = 'assets/monsters/'; for (let i = 1; i <= 13; i++) { for (let j = 1; j <= 19; j++) { this.load.spritesheet('monsters_' + i + '_' + j, 'monsters_' + i + '_' + j + '.png', { frameWidth: 16, frameHeight: 24 }); } } (Spritesheets are all just two frames.) So I guess that means doing this (the 3.9.0 TS defs don't have a `generateFrameNumbers()` yet for what you've provided, hence the null)? for (let i = 1; i <= 13; i++) { for (let j = 1; j <= 19; j++) { this.anims.create({ key: 'stand', frames: this.anims.generateFrameNumbers('monsters_' + i + '_' + j, null), frameRate: 5, repeat: -1 }); } } That gets me the following, which is what I was expecting to see. So now I'm thinking each sprite needs to have a 'stand' set (`key: 'stand_monsters_' + i + '_' + j`)? Or am I misunderstanding and there's an easier way to write the code? Since you're on the thread, rich, here's more of what I'm trying to convert to Phaser 3, in case it helps with animation usage. // TypeScript - Phaser 2 import { MonsterRarity } from "../Enums"; import Character from "./Character"; export default class Monster extends Character { private monsterBody: Phaser.Sprite; private asset: string; public experience: number; public rarity: MonsterRarity; constructor(game: Phaser.Game, x: number, y: number, style: string) { super(game); // The base doesn't actually move at all. var monsterBase =, y, 'avatar_1_1'); monsterBase.anchor.setTo(0.5); this.monsterBody =, y, 'monsters_' + style); this.monsterBody.anchor.setTo(0.5); this.monsterBody.animations.add('stand');'stand', 5, true); this.monsterBody.inputEnabled = true;, this); this.add(monsterBase); this.add(this.monsterBody); // Add this to the game immediately. game.add.existing(this); } logInfo() { console.log(this.monsterBody.key); } }
  3. strivinglife

    Using a simple spritesheet animation without key

    So, I'm using TypeScript and `this.asset` doesn't appear to be valid. If that's pseudo-code, then I think the issue is that each animated item would have a different asset to pull from.
  4. In Phaser 2 I was able to load a spritesheet and then define a simple animation that would loop through the spritesheet frames. // Defined in the preloader state. this.load.path = 'assets/avatar/'; for (let i = 1; i < 8; i++) {'avatar_1_' + i, 'base/avatar_1_' + i +'.png', 16, 24); } // Use the spritesheet when adding the sprite. this.hero =, y, 'avatar_1_' + style); // Define an animation and start playing it. this.hero.animations.add('stand');'stand', 5, true); With Phaser 3 I'm trying to understand how to convert this to the new animations model. // Still loading the spritesheets in the preloader. this.load.path = 'assets/avatar/'; for (let i = 1; i < 8; i++) { this.load.spritesheet('avatar_1_' + i, 'base/avatar_1_' + i +'.png', { frameWidth: 16, frameHeight: 24 }); } // This doesn't appear to have changed much either. this.body = this.scene.add.sprite(x, y, this.asset); // Now I've tried just creating the animation: this.anims.create({ key: 'stand', frameRate: 5, repeat: -1 }); // And then using it on the sprite, but it's complaining about that it: // Cannot read property 'frame' of undefined'stand'); Is it still possible to define an animation that just loops through the sprite's spritesheet's frames? If not, do I need to define an animation for every spritesheet I'm using? (Such as in the official Phaser 3 tutorial, Thanks!
  5. strivinglife

    Prevent game pause

    Wouldn't you want to handle most of the computations on the server anyway? Once the client reconnects they would get sent the current state of the world.
  6. strivinglife

    Is it still acceptable to use Phaser 2?

    I completely agree with mazoku. I'm working on a new game and am using Phaser 2 CE. Although now that 3.6.0 dropped with container support I might start looking at using that for pieces of what I'm doing. Being so new, 3 is going to continue changing rapidly, while 2 should be pretty stable.
  7. strivinglife

    Does this version support typescript?

    Does anyone know if the workflow when using NodeJS is going to continue to be npm install phaser --save and then download the TS defs from the repo? Or might we see the TS defs included as part of the phaser package?
  8. strivinglife

    Detect and measure circular pointer motion?

    Did you ever come up with a solution for this? I was thinking about something similar this morning, but thought about implementing it by just having hit boxes that would be checked for sequential mouse over.
  9. strivinglife

    Should we merge Pixi v4 with Phaser?

    I agree with the others in that Lazer dev makes more sense since you're doing Pixi in that.
  10. I'm not the OP, but I found this as well.'Preloader', true, false);The way I move between states is given above (for example, the above is in my Boot state). I got hung up briefly the first time I ran into this, but then I figured the load manager was probably for the entirety of the game, so it makes sense it would persist between state changes.
  11. strivinglife

    How does one use Plugins in TypeScript?

    Found this linked to from another thread and found it very useful. FYI, based upon the official photon storm plugin TypeScript definition, the constructor accepts a Phaser.Game and Phaser.PluginManager. constructor(game:Phaser.Game, parent: Phaser.PluginManager);
  12. Hello. I'm looking at the example under Debug Display on the official site, at Within the render() there's the following call: game.debug.spriteCorners(sprite, true, true);Unfortunately, I don't see that this actually exists. Is it safe to assume that this example just contains an out of date call, or am I missing something? Thanks! James