Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Example works on git folder but not in a game


OttoRobba
 Share

Recommended Posts

Hi there folks.

 

I have been trying to wrap my head around Phaser (used to Love2d so this is all quite new to me) and I'm running time and time again into a wall.
The documentation is not clear enough for a javascript newbie like me and so I try my hand at learning from the examples.

Some of the samples, however, just plain don't work for me.

 

For instance, I wanted to work with geometries as placeholders. Well, that doesn't quite work.

var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { create: create, render: render });var floor;function create() {    floor = new Phaser.Rectangle(0, 550, 800, 50);}function render () {    game.debug.renderRectangle(floor,'#0fffff');}

This is a copy-paste from the sample for drawing rectangles (http://gametest.mobi/phaser/examples/_site/view_full.html?d=geometry&f=rectangle.js&t=rectangle) and all I get is a white screen. If I replace 'phaser-example' with '' and replace CANVAS with AUTO I get a black screen.

 

If I try to run the 'first game' from http://www.photonstorm.com/phaser/tutorial-making-your-first-phaser-game it works fine.

 

I'm really lost. Is the example outdated? Am I doing something completely wrong?

I really can't make heads or tails from the documentation :/

Link to comment
Share on other sites

All of the game.debug.renderX functions only work if in Phaser.CANVAS mode, so swapping to AUTO would cause it to not render (as it's running in WebGL).

 

If you don't have a div with an id of 'phaser-example' in your html, then you either need to create one or change that part to ''.

 

Otherwise the above should render an aqua coloured rectangle in the bottom 50px of the screen.

Link to comment
Share on other sites

If you want to render them, yes sort of. There is a Graphics class which allows for WebGL geometry rendering, but if you're talking about a lot of shapes it will start to bog down lots, so better to stick to canvas. The Debug class is literally just for visually debugging various object properties, you'd probably be better off using the bitmapData class so you can just write to your own context however you need.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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