Majirefy

Members
  • Content Count

    22
  • Joined

  • Last visited

About Majirefy

  • Rank
    Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. How can we get more accurate TS def from JSDoc? There are always many mistakes in auto-generated TS def file.
  2. Thanks for reply! This npm package is for Phaser-CE, not Phaser 3, I think. Since Phaser CE comes with TS defination files in node modules, there is no need to install manually. But I think it would be helpful to have Phaser 3 types too.
  3. Why not publish Typescript definition file to @types? So we can install TS types easily with npm install --save @types/phaser. It will auto update when we run npm update and no need to check this repo manually.
  4. @JinzThanks! I will try ticker first.
  5. So it's better to use app.ticker.add to make game loop? Or just use requestAnimateFrame?
  6. As PixiJS introduced Application class, I find there is a function start(): In PixiJS examples, the game loop always starts like: // Animate the rotation app.ticker.add(function() { anim.rotation += 0.01; }); But some examples use app.start(). So what is the best way for game loop? requestAnimateFrame? app.ticker.add? app.start?
  7. Thanks. I found out. Because I used a Phaser Template. It loads everything in assets folder automatically and gives keys by file name. So this happened.
  8. I load a sprite sheet image file in preload states: this.game.load.spritesheet('rings', Assets.Images.ImagesBlocksRings.getPNG(), 100, 100); Assets.Images.ImagesBlocksRings.getPNG() returns url of image file like "../assets/rings.png". Then I add a Phaser.Image object in main state: this.ring = this.game.add.image(this.game.world.centerX, this.game.world.centerY - (this.game.world.centerY / 2), 'rings'); But when I run my game, instead of showing a frame, it shows the whole sprite sheet image, not slicing into frames. If I change the key of sprite sheet to "_rings", it will work fine. Or If I put load into the preload function in main state, it will work fine, too. Why is that? PS: I check the key in Phaser.Cache, it will return true unless after load.
  9. I don't think so. Later I loaded a sprite sheet image file and gave it "rings" key. It also failed to slice into frames. Then I have to change key to "_rings", then it worked. So wired. It only happens on sprite sheet image loaded from different state.
  10. @PhasedEvolution @samme I know what's wrong. I set the key of sprite sheet is "buttons". After I changed it to "_buttons", it works. But I don't know why.
  11. In many examples and tutorials, there is usually one "must have" state: Preload state. There also discussion on preload state: Do we need load all assets files in preload state? BTW, I found if I load a sprite sheet from an image file in preload state, and add to game in my main state, sometimes it fails to slice my sprite sheet into each frames. Recently I load an image sprite sheet file for buttons in preload state, and add to my title state, I got the whole image show on the screen, regardless what I set frame width and height in load function in preload state. Then I put this load into the preload function of title state, it worked well. So. this made me more confused. Is this a bug? Or there are some rules for file loading? If we can't load many assets in preload state, why we need it?
  12. @ldd Thanks for reply. I create a text in the center of screen like this: this.localFontText = this.game.add.text(this.game.world.centerX, this.game.world.centerY, '测试本地字体效果', { font: '50px ' + Assets.CustomWebFonts.FontsFangsong.getFamily() }); this.localFontText.anchor.setTo(0.5); This works fine. But for my map, this doesn't work.
  13. Hi! I created a tile map in Tiled,then I want to display this tile map in the center of the screen. I do it as below: let ground = this.map.createLayer('Ground'); // "map" is Phaser.Tilemap ground.fixedToCamera = false; ground.position.set(this.game.world.centerX, this.game.world.centerY); ground.anchor.setTo(0.5); But it not work. The tile map still show on the top left of the screen. What should I do?
  14. @Rune Kode Thanks for your work! I really love that. What I am doing now is make a project like yours by myself. So I can learn how to bundle all these things together, and do more in the future. @Tom Atom And eventually I found why TS compile cannot find Phaser: There are duplicate files of Phaser defination file:phaser.d.ts and phaser.comment.d.ts. In genneral, we do not need these *.comment.d.ts files. After simply deleting these comment files, everything is well now. This topic discussed about these unuseful comment files: And it will be fixed next week:https://github.com/photonstorm/phaser-ce/pull/33 But I do not know why we should have two files...
  15. @Tom AtomThanks! I will try it later. I love TypeScript, so these obstacles shall not stop me using Phaser with TypeScript.