Jump to content

[TypeScript] Trying State and painting in Mid


Kapsonfire
 Share

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

 

 

 

 

//EDIT

Nevermind, forgot the anchor :D

post-4891-0-55531600-1399460245_thumb.pn

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

 Share

  • Recently Browsing   0 members

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