reegankens Posted June 22, 2015 Share Posted June 22, 2015 I'm sory about my english before. first of all I try to download Wants Candy Monster assets of gi. after that I tried to run in localhost initially all was fine. but when I downloaded my pictures from google and put the picture in the folder img, then I load images from preloade. then the picture I call on the create function, after that I tried to run but instead the picture does not appear. after that I tried to check my pictures teryata console extension of his recognizable as text / html. can anyone explain to me why it could happen ? Preloader :Candy.Preloader = function(game){// define width and height of the gameCandy.GAME_WIDTH = 640;Candy.GAME_HEIGHT = 960;};Candy.Preloader.prototype = {preload: function(){// set background color and preload imagethis.stage.backgroundColor = '#B4D9E7';this.preloadBar = this.add.sprite((Candy.GAME_WIDTH-311)/2, (Candy.GAME_HEIGHT-27)/2, 'preloaderBar');this.load.setPreloadSprite(this.preloadBar);// load imagesthis.load.image('background', 'img/background.png');this.load.image('floor', 'img/floor.png');this.load.image('monster-cover', 'img/monster-cover.png');this.load.image('title', 'img/title.png');this.load.image('game-over', 'img/gameover.png');this.load.image('score-bg', 'img/score-bg.png');this.load.image('button-pause', 'img/button-pause.png');this.load.image('images-s','img/images-s.png')// load spritesheetsthis.load.spritesheet('candy', 'img/candy.png', 82, 98);this.load.spritesheet('monster-idle', 'img/monster-idle.png', 103, 131);this.load.spritesheet('button-start', 'img/button-start.png', 401, 143);},create: function(){// start the MainMenu statethis.state.start('MainMenu');}}; create function :Candy.Game.prototype = {create: function(){// start the physics enginethis.physics.startSystem(Phaser.Physics.ARCADE);// set the global gravitythis.physics.arcade.gravity.y = 200;// display images: background, floor and scorethis.add.sprite(0, 0, 'background');this.add.sprite(-30, Candy.GAME_HEIGHT-160, 'floor');this.add.sprite(10, 5, 'score-bg');this.add.sprite(0, 0, 'images-s.png');// add pause buttonthis.add.button(Candy.GAME_WIDTH-96-10, 5, 'button-pause', this.managePause, this);// create the playerthis._player = this.add.sprite(5, 760, 'monster-idle');// add player animationthis._player.animations.add('idle', [0,1,2,3,4,5,6,7,8,9,10,11,12], 10, true);// play the animationthis._player.animations.play('idle');// set font stylethis._fontStyle = { font: "40px Arial", fill: "#FFCC00", stroke: "#333", strokeThickness: 5, align: "center" };// initialize the spawn timerthis._spawnCandyTimer = 0;// initialize the score text with 0Candy._scoreText = this.add.text(120, 20, "0", this._fontStyle);// set health of the playerCandy._health = 10;// create new group for candythis._candyGroup = this.add.group();// spawn first candyCandy.item.spawnCandy(this);}, Link to comment Share on other sites More sharing options...
drhayes Posted June 22, 2015 Share Posted June 22, 2015 It looks like the image wasn't found. If Chrome can't find the image then it doesn't know the type and will display it as text/html. Link to comment Share on other sites More sharing options...
Recommended Posts