Jump to content

Phaser 0.9 Update


rich
 Share

Recommended Posts

I put one console.log in render and nothing was showed, so the render is not being called. How a call him manually?

 

Edit : Same to the other functions, none of them is being called.

 

Edit 2 : I put this.render(); in init and the console was called in render funcion, but the texts still don't add.

 

Main = function (game){    this.game = game;}Main.prototype ={    init : function()    {        this.game.camera.backgroundColor = 'rgb(50,50,50)';        this.render();    },    create : function()    {    },    update : function()    {    },    render : function()    {        this.game.stage.context.fillStyle = 'rgb(255,255,255)';        this.game.stage.context.font = 'bold 48px Arial';        this.game.stage.context.textAlign = 'center';        this.game.stage.context.fillText("Teste", 10, 20);        console.log("test");    }}
Link to comment
Share on other sites

Ok I know what the problem was. You had an init function, but you didn't load any files - so loader never got to call 'create' or start the game loop.

 

However I've fixed this in v0.9.2 which I just pushed. It will call init and if the loader is still empty it'll automatically call create like it should :)

Link to comment
Share on other sites

Hi Rich, i'm here again to boring you one more time.

 

I exchange the files for the new version 0.92 and update the index, and now he shows a new error : "Uncaught time error : undefined is not a funcion", but i don't change nothing in all code, before the Phaser cannot calls the "init", and now he searching for "undefined" method?

I have only 2 files, the index and one Main.js, can you help me again?

Index : 

<!DOCTYPE html><html><head>    <title></title>    <script src = "Phaser/phaser.js"></script>    <script src = "Main.js"></script></head><body>    <div id="game"></div>    <script type="text/javascript">    var myGame = new Phaser.Game(this, 'game', 800, 600);    myGame.switchState(Main);    </script></body></html>

 

Main.js :

Main = function (game){    this.game = game;}Main.prototype ={    init : function()    {        this.game.camera.backgroundColor = 'rgb(50,50,50)';        //this.render();    },    create : function()    {    },    update : function()    {    },    render : function()    {        /*this.game.stage.context.fillStyle = 'rgb(255,255,255)';        this.game.stage.context.font = 'bold 48px Arial';        this.game.stage.context.textAlign = 'center';        this.game.stage.context.fillText("Teste", 10, 20);        console.log("test");*/    }}
Link to comment
Share on other sites

Ok that's interesting - I'm using the same version as you and also the latest Canary build and they are running without error. Can you bring up the dev console settings and make sure Disable cache is set. Also do you have any extensions loaded at all? Does it do the same for other browsers? I just tried Firefox 20.0.1 on the gametest links and they running ok.

 

Do the examples on gametest.mobi run for you (or just broken locally)?

Link to comment
Share on other sites

Do you still get the "undefined time error" ? Chrome handles Date.now just fine - it's old browsers like IE8 that don't. When you see the error in the dev console it should have the little arrow next to it that lets you expand where it occurred, and also a line-number next to it (on the far right) - if you click the line number it will open phaser.js and show you the line with the error - please copy/paste or screen grab to me :)

Link to comment
Share on other sites

Believing or not...i put all in html and he throws the same problem ("Uncaught TypeError : undefined is not a funcion")...he is the all code : 

 

<!DOCTYPE html><html><head>    <title></title>    <script src = "Phaser/phaser.js"></script>    <!-- <script src = "Main.js"></script>--></head><body>    <div id="game"></div>    <script type="text/javascript">    //var myGame = new Phaser.Game(this, 'game', 800, 600);    //myGame.switchState(Main);    /// <reference path="Phaser/Game.ts" />    (function () {        var myGame = new Phaser.Game(this, 'game', 840, 400, init, create, update);        function init() {            myGame.camera.backgroundColor = 'rgb(50,50,50)';        }        function create() {        }        function update() {        }    })();    </script></body></html>

 

I know that i'm turning a annoying person, but i really want make the Phaser work, so please forgive me for my "spam question posts".

Link to comment
Share on other sites

Hi, I'm able to reproduce your problem. You can fix it by referencing one of the phaser.js builds in the build folder of the distribution instead of the one in the Phaser folder:

 

<head>    <script src = "build/phaser-092.js"></script></head> 
Link to comment
Share on other sites

Don't work...

I don't know if my organization is right, but i'll put the codes here, and one screen of my folder here for you see if i'm doing anything wrong. (The project folder is the top finder)

 

HTML :

<!DOCTYPE html><html><head>    <title></title>    <script src = "build/phaser-093.js"></script>    <!--<script src = "Phaser/phaser.js"></script>-->    <script src = "Main.js"></script></head><body>    <div id="game"></div>    <script type="text/javascript">        var myGame = new Phaser.Game(this, 'game', 800, 600);        myGame.switchState(Main);    </script></body></html>

 

JS : 

 Main = function (game){    this.game = game;}Main.prototype ={    init : function()    {        this.game.camera.backgroundColor = 'rgb(50,50,50)';    },    create : function()    {    },    update : function()    {    },    render : function()    {        this.game.stage.context.fillStyle = 'rgb(255,255,255)';        this.game.stage.context.font = 'bold 20px Arial';        this.game.stage.context.textAlign = 'center';        this.game.stage.context.fillText("Teste", 50, 50);    }}

Phaser folder :

 

sc%20phaser.png

 

Build folder : 

 

sc%20build.png

 

I hope that this help you.

Link to comment
Share on other sites

Ah-ha! Ok yes that explains it. You're linking to just the compiled version of the Phaser.ts file, which of course has virtually nothing in it! I thought you were linking to the version in the Tests folder (that would work fine). Or just use the one in the build folder, it really doesn't matter which. There isn't a compiled version of the full thing in the Phaser folder itself, it gets compiled to /build and /Tests.

Link to comment
Share on other sites

Humm, i know that this .js was so much empty XD.

So, i need to put always the Phaser folder, together with the latest version of the phaser.js in build or test folder, in my project folder for works right? Is it?

 

Anyway, thanks for your super support Rich, i hope that the Phaser continues increasing day by day with your hands, and i'll use him always when i need. :D

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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