Can't add image in non Scene class

Recommended Posts

Hey there guys! I working on first MVC project with Phaser 3(3.4.0) with Typescript

export class Game extends Phaser.Scene {

        constructor() {
                key: GAME_SCENE_KEY

        create() {
            console.log('This is game scene');

            this.add.image(500, 300, BLACK_CELL_IMAGE_KEY);
            this.add.image(564, 300, WHITE_CELL_IMAGE_KEY);
            this.add.image(500, 364, WHITE_CELL_IMAGE_KEY);
            this.add.image(564, 364, BLACK_CELL_IMAGE_KEY);


So this code fragment works perfectly. But when I try to add a image in non Scene class it doesn't work. 

export abstract class UIElement{

        game: Phaser.Game;
        cellSprite: Phaser.GameObjects.Image;
        position: Phaser.Geom.Point;

        constructor(game: Phaser.Game, rowPos: number, columnPos: number) {
            this.game = game;
            this.position = new Phaser.Geom.Point(rowPos, columnPos);
            this.add.image(this.position.x, this.position.y);


This is a part of the View that I'm working for the MVC but I can't really get away from this. 

this.add.image(this.position.x, this.position.y);

Any ideas?

Share this post

Link to post
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.