Jump to content

Bringing up "Hello World" project in Ionic 2


bryantmakesprog
 Share

Recommended Posts

I'm unsure if this is the best location for this sort of question since the project utilizes both ionic and phaser, but I figured I'd give it a shot.

So I am attempting to bring up the "Hello World" project formatted to work in ionic https://gist.github.com/photonstorm/46cb8fb4b19fc7717dcad514cdcec064

I've generated the following preload, create, and update functions:

 

function PHASER_preload() {
    console.log("Preloading Assets");
    this.load.setBaseURL('http://labs.phaser.io');
    this.load.image('sky', 'assets/skies/space3.png');
    this.load.image('logo', 'assets/sprites/phaser3-logo.png');
    this.load.image('red', 'assets/particles/red.png');
}
function PHASER_create() {
    console.log("Setting Up Phaser");
    this.add.image(400, 300, 'sky');
    var particles = this.add.particles('red');
    var emitter = particles.createEmitter({
        speed: 100,
        scale: { start: 1, end: 0 },
        blendMode: 'ADD'
    });
    var logo = this.physics.add.image(400, 100, 'logo');
    logo.setVelocity(100, 200);
    logo.setBounce(1, 1);
    logo.setCollideWorldBounds(true);
    emitter.startFollow(logo);
    console.log("Setup Complete");
}
function PHASER_update() {
    // Run's on update.
}

In ionic, on page load we perform the following:

 

ionViewDidEnter() {
        this.ConfigurePhaser();
    }

    ConfigurePhaser() {
        console.log("Configuring Phaser")
        var config = {
            type: Phaser.AUTO,
            width: window.innerWidth,
            height: window.innerHeight,
            physics: {
                default: 'arcade',
                arcade: {
                    gravity: { y: 200 }
                }
            },
            scene: {
                preload: PHASER_preload,
                create: PHASER_create,
                update: PHASER_update
            }
        };
        this.game = new Phaser.Game(config);
    }

So basically it's the normal Phaser setup, just embedded in ionic.

When I run it however, the game doesn't show up. All the functions execute as expected (no errors and I see the console output), just nothing renders. See attachment.

Thoughts?

 

phasersample.png

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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