Jump to content

Search the Community

Showing results for tags 'angular cli'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 1 result

  1. Hi all! I am new on Phaser, just got it working with my FireLoop project. FireLoop generates Angular 2 project with Angular CLI. I made my own TypeScript game into that and it works just great, well almost. I have the following code in my project: /// <reference path="../../../node_modules/phaser/typescript/phaser.d.ts" /> import { SessionInterface, Session, FireLoopRef } from '../shared/sdk/models'; import { RealTime } from '../shared/sdk/services'; import { LoopBackConfig } from '../shared/sdk'; export class SimpleGame { session: Session; sessions: Session[] = new Array<Session>(); sessionRef : FireLoopRef<Session>; game: Phaser.Game; sessionsText: Phaser.Text; constructor(private rt: RealTime) { this.game = new Phaser.Game(800, 600, Phaser.AUTO, 'content', { create: this.create }); this.rt.onReady().subscribe(() => { this.sessionRef = this.rt.FireLoop.ref<Session>(Session); this.sessionRef.on('change').subscribe((sessions: Session[]) => { this.sessions = sessions; this.updateText(); }); // this.sessionRef.stats().subscribe((stats: any) => console.log("stats:", stats)); }); this.rt.onDisconnect().subscribe((error: string) => { console.log('Disconnected', error); }); this.rt.onUnAuthorized().subscribe((error: string) => { console.log('UnAuthorized', error); }); this.rt.onAuthenticated().subscribe((error: string) => { console.log('Authenticated', error); }); } create() { let text = "Hello World!"; let headerStyle = { font: "65px Arial", fill: "#ff0000", align: "center" }; let textStyle = { font: "24px Arial", fill: "#ff0000", align: "center" }; this.game.add.text(0, 0, text, headerStyle); this.sessionsText = this.game.add.text(0, 100, "Initializing...", textStyle); } updateText() { let sessionsString: string; if (this.sessions) { sessionsString = "Hosts: " + this.sessions.map(session => session.host) + ", Clients: " + this.sessions.map(session => session.client); console.log(sessionsString, this.sessionsText); this.sessionsText.setText(sessionsString); } } } The problem is with sessionText variable. When I console.log it right at the end of "create"-function, it seems to be proper object. Anyhow when I try to console.log it anywhere else, it is undefined. So, this setText line never works: this.sessionsText.setText(sessionsString); Instead, it gives an error. So, I guess it isn't saving the variable at the create like it's supposed to. Any solutions. Here's also a screenshot:
×
×
  • Create New...