0

I have been at this problem for days and cant seem to figure it out, I am using Django with Phaser2 framework and Im trying to load some images to the game, but keep getting a 404. Is there some extra settings I have to configure in Django?

This is my index.html file:

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <title>Phaser - Making your first game, part 1</title>
    <script src="//cdn.jsdelivr.net/phaser/2.2.2/phaser.min.js"></script>
    <style type="text/css">
        body {
            margin: 0;
        }
    </style>
</head>
<body>

<script type="text/javascript">

    var game = new Phaser.Game(800, 600, Phaser.AUTO, '', {preload: preload, create: create, update: update});

    function preload() {
        {#game.load.path = '/';#}
        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');
        game.add.image(400, 300, 'sky');
    }

    function update() {
    }

</script>

</body>
</html>

This is my folder structure:

Folder structure

This are the errors I get:

Errors

Any idea has to what might be causing the problem?

Bryam Ulloa
  • 144
  • 2
  • 5
  • 17

1 Answers1

0

I fixed my problem by adding this to my settings.py file:

STATIC_URL = '/static/'

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
Bryam Ulloa
  • 144
  • 2
  • 5
  • 17