rjat

Members
  • Content Count

    3
  • Joined

  • Last visited

  1. Thanks, you've solved the problem. For the game i started trying to make, I had copied the folder structure from the "Making your first game" tutorial and then I started editing and changing things from there. So I was using the phaser.min.js file from that tutorial. I didn't consider the possibility of that phaser.min.js being old and not including the functionality of the game.create.texture method. I have placed the latest downloadable phaser.min.js file in my js folder and now it works. Lesson learnt, make sure you are using the latest phaser framework file ! Thanks for the help.
  2. Thanks for the response Zeterain. I have created a very cut down version of the "More Sprites" example, to make posting the complete code easier. In the cut down version, I have just included the "chick" sprite. I have pasted the complete code I have used below. When I edit the "More Sprites" example to do the same in the online code editor on the "More Sprites" page, the code runs successfully and I see just the chick. When I run the code below locally (using the python SimpleHTTPServer), I see nothing apart from a black window. When I look in the Developer Tools in Chrome, I see the error: Cannot read property 'texture' of undefined. It could easily be something very basic I am doing wrong, as this is the first time I have looked at Phaser. The complete code I am trying to run is pasted below: <!doctype html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>Testing</title> <script type="text/javascript" src="js/phaser.min.js"></script> <style type="text/css"> body { margin: 0; background-color: #0F0F0F; } </style> </head> <body> <script type="text/javascript"> var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { create: create }); function create() { var pixelWidth = 6; var pixelHeight = 6; var chick = [ '...55.......', '.....5......', '...7888887..', '..788888887.', '..888088808.', '..888886666.', '..8888644444', '..8888645555', '888888644444', '88788776555.', '78788788876.', '56655677776.', '456777777654', '.4........4.' ]; game.create.texture('chick', chick, pixelWidth, pixelHeight); game.add.sprite(150, 200, 'chick').anchor.y = 1; } </script> </body> </html>
  3. When i try to use game.create.texture from the Phaser examples, I get an error: Cannot read property 'texture' of undefined. For example, if I copy the example code from the "Generate Sprite" example, or the "More Sprites" example and try to run them locally, I get the error. The "game" variable is declared globally, for example (from the "More Sprites" example): var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { create: create }); And then within the create function, game.create.texture is used, for example: game.create.texture('chick', chick, pixelWidth, pixelHeight); I assume the error means that the "create" property doesn't exist for the "game" object. I can't spot what I'm doing wrong. Any help would be useful, thanks.