Jump to content

[TypeScript] Trying State and painting in Mid


Recommended Posts

I tried out States with phaser and its working for me. Anyways i tried the example with painting the phaserlogo in mid of screen - My Result isnt what I expected.



My app

class Game extends Phaser.Game{    constructor() {        super(800, 450, Phaser.AUTO, 'content', { preload: this.preload, create: this.create });        this.state.add("Start", Scenes.Start);    }    preload() {                    }    create() {        this.scale.setShowAll();        this.scale.pageAlignHorizontally = true;        this.scale.pageAlignVertically = true;        this.scale.refresh();        this.state.start("Start");    }}window.onload = () => {    new Game();};

My State

module Scenes {    export class Start extends Phaser.State {        preload() {            this.load.image('logo', 'images/phaser2.png');        }        create() {                    }        update() {            var logo = this.add.sprite(this.world.centerX, this.world.centerY, 'logo');             }    }}

Result is attached






Nevermind, forgot the anchor :D


Link to comment
Share on other sites

Hey mate :D


Not sure its related to TypeScript exactly. 

Maybe you missed a line?

var logo = this.add.sprite(this.world.centerX, this.world.centerY, 'logo');logo.anchor.x = 0.5;logo.anchor.y = 0.5;

Actually I just noticed that Point has set(x/y) and setTo(x/y). Ill check it out,  but you could also use logo.anchor.setTo(0.5,0.5)

Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...