Jump to content

Why is this not working?


Recommended Posts

game.module(    'game.main').body(function() {    game.createClass('Platform', 'Graphics', {        init: function() {                        this.beginFill(0x00cc00, 1);            this.drawRect(0, 0, 100, 100);            game.scene.stage.addChild(this);    });    game.createScene('Main', {        backgroundColor: '#666',        init: function() {            var platform = new game.Platform();        }    });});

I followed this example: http://vermeire.home.xs4all.nl/panda/fiddler.html , which uses "this._super();", and that also doesn't seem to work anymore?


It's just showing a gray screen. Where do i find good documentation/tutorials/examples?

Link to comment
Share on other sites

Hi Ansien, try this:

game.module(    'game.main').body(function() {    game.createClass('Platform', 'Graphics', {        init: function() {                        this._super();            this.beginFill(0x00cc00, 1);            this.drawRect(0, 0, 400, 100);            this.endFill();                        //set fill and draw another rectagle that is filled in addition to the line            game.scene.stage.addChild(this);    	}    });    game.createScene('Main', {        backgroundColor: 0xeeeeee,        init: function() {            var platform = new game.Platform();        }    });});

You where almost there, you just forgot a curling bracket and you DO need this_super() to call the parent constructor function befaore you can use graphics functions.



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...