Jump to content

Newbie struggling with CORS issues.


Recommended Posts

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

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


  • Recently Browsing   0 members

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