defwonder Posted May 15, 2014 Share Posted May 15, 2014 Hi guys, I'm looking for a solid HTML5 platform to develop my game on and I thought I'd start by reviewing Phaser - It looks like it has everything I need! However, moving to HTML5 development, I realise I have to run the game on a local server, which I've never done before. Immediately trying to follow the first Phaser tutorial here I run into a CORS issue trying to load the star. I've followed the setup instructions as listed on the Phaser site, I've browsed the forums and done multiple google searches and... to be honest... I don't really understand any of what I'm being instructed to do. The error in the log appears as: Uncaught SecurityError: Failed to execute 'texImage2D' on 'WebGLRenderingContext': The cross-origin image at file:///Applications/MAMP/htdocs/phasertest/phaser_tutorial_02/assets/star.png may not be loaded. What do I do? A little step-by step would help a lot. I'm developing on OSX and running a local server through MAMP, if that's any help. Thanks so much! - Greg Link to comment Share on other sites More sharing options...
Mike Posted May 15, 2014 Share Posted May 15, 2014 Your image path should be something like: http://localhost:8888/phasertest/phaser_tutorial_02/assets/star.png not a file path: file:///Applications/MAMP/htdocs/phasertest/phaser_tutorial_02/assets/star.png Link to comment Share on other sites More sharing options...
defwonder Posted May 15, 2014 Author Share Posted May 15, 2014 Hey Mike, Thanks for your response! That's the actual path of the image, not what's in script. I'd rather not hardcode asset paths. This is what my script looks like. Sorry, I should have posted this before.var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });function preload() { game.load.image('sky', 'assets/sky.png'); game.load.image('ground', 'assets/platform.png'); game.load.image('star', 'assets/star.png'); game.load.spritesheet('dude', 'assets/dude.png', 32, 48);}function create() { game.add.sprite(0, 0, 'star');}function update() {} Link to comment Share on other sites More sharing options...
Mike Posted May 15, 2014 Share Posted May 15, 2014 Do you open the html form the webserver ? Sounds like you open the html like: file:///D:/xampp/htdocs/Phaser/AdventureJS/index.html Try to open: http://localhost:8888/ also check if the server is running (Apache is started). And your game should be here: http://localhost:8888/phasertest defwonder 1 Link to comment Share on other sites More sharing options...
defwonder Posted May 16, 2014 Author Share Posted May 16, 2014 Wow. It was that simple. I feel like a shmuck for not figuring that out sooner. Thanks for the help. Link to comment Share on other sites More sharing options...
Recommended Posts