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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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