Jump to content

Search the Community

Showing results for tags 'preload.js'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 1 result

  1. Hello All, I am completely new to Phaser. For learning purposes, I did a little game from a recent book that I bought, and put it on my website, that I use for testing my stuff. Here is the URL: http://www.retroinvaders.net/shump/build/index.html The issue is that the game assets won't load properly at first time, it's only when I refresh the page, at least 4 times, that I see all the assets of the game properly loaded. The Web Console (Firefox) says: Phaser.Cache.getImage: Key "enemyBullet" not found in Cache. Same error for all the game assets is repeated again and again, so not just "enemyBullet", but all the assets. Here is the code of the Preload.js file. export default class Preload { constructor() { this.asset = null; this.ready = false; } preload() { this.load.image('loading_bg', '../assets/images/loading_bg.jpg'); } create() { //background for game this.add.sprite(0,0, "loading_bg"); this.asset = this.add.sprite(this.game.width/2,this.game.height/2, 'preloader'); this.asset.anchor.setTo(0.5, 0.5); this.load.onLoadComplete.addOnce(this.onLoadComplete, this); this.load.setPreloadSprite(this.asset); //do all your loading here //this.load.image('player', '../assets/images/player.png'); //width and height of sprite this.load.image('bg', '../assets/images/bg.jpg'); this.load.image('bullet', '../assets/images/bullet.png'); this.load.image('enemy', '../assets/images/enemy.png'); this.load.image('explosion', '../assets/images/explosion.png'); this.load.spritesheet('player', '../assets/images/gunbot.png', 214, 269); //width and height of sprite this.load.image('hexagon', '../assets/images/hexagon_particle.png'); //this.load.image('bullet', '../assets/images/bullet.png'); this.load.image('enemyBullet', '../assets/images/enemyBullet.png'); //this.load.image('bg', '../assets/images/bg.jpg'); this.load.image('health_bar', '../assets/images/health_bar.png'); this.load.image('health_holder', '../assets/images/health_holder.png'); this.load.image('circle', '../assets/images/circle.png'); //staaaart load this.load.start(); } update() { if(this.ready) { this.game.state.start('game'); } } onLoadComplete() { this.ready = true; } } What am I doing wrong? Aany help, would be greatly appreciated. Thank you.
×
×
  • Create New...