khleug35

Members
  • Content Count

    111
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by khleug35

  1. My code is here var game = new Phaser.Game('100%','100%', Phaser.AUTO, '', { init: init, preload: preload, create: create, update: update, }); var background; function init(){ game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; } function preload() { game.load.image('space', 'assets/images/space.png'); } function create(){ background = game.add.tileSprite(0, 0, game.world.width, game.world.height, 'space'); background.autoScroll(0, 30); game.physics.enable(background,Phaser.Physics.ARCADE); } function update(){} When I run the game first time, It was worked, I can success to load the background. but when I refresh the game, it have error message and can't run the game. it said that phaser.2.7.7.min.js:3 Phaser.Cache.getImage: Key "__default" not found in Cache. getItem @ phaser.2.7.7.min.js:3 phaser.2.7.7.min.js:3 Phaser.Cache.getImage: Key "__missing" not found in Cache. getItem @ phaser.2.7.7.min.js:3 phaser.2.7.7.min.js:3 Uncaught TypeError: Cannot read property 'base' of null so when this error is happen, I need to clear cache form chrome or go to other page then return the game, it can success to run the game. but when I refresh the game, an error occurred.Does anyone know what problem is that ?? Thanks you very much
  2. OH!!!!!!Thanks It work for me!!!!!!!!!!! Thanks!! samid737!!!!!!!!!! Thx for your link!!!! My problem is solved!!!!!!
  3. THX finally, I use addChild() to add the player sprite, like this , I make the graphics's element follow the user graphics = game.add.graphics(0, 0); game.physics.arcade.enable(graphics); graphics.beginFill(0xFF0000, 1); player.addChild(graphics.drawCircle(0, 0, 30)); but when I move the player right left, the graphics's element position will change....... the graphics's element is leave the player body, how to fix it to center, thx I think that the scale problem is make it happen the problem............. if (faceRight == true) { player.scale.x *= -1; player.anchor.x = 0.5; player.x = player.x - 10; faceRight = false; faceLeft = true; bullet_direction = 'right'; } } and player.body.velocity.x = -250; if (faceLeft == true) { player.scale.x *= -1; player.anchor.x = 0.5; faceLeft = false; faceRight = true; bullet_direction = 'left'; }
  4. I would like to create some object follow the player movement , this situation like to call game.debug.body(player); method.......... the green square follow/pin the player any idea??? THX
  5. OH!!!!!Super Many Thanks Great !!! It Work for me !!!!!!!! Thanks!! magig!!!!!!!!!! Thx for your link!!!! My problem is solved!!!!!!
  6. Hello everyone, I am developing a platform game like Super Mario style. I try to build a lives list system. like the photo that named "full_lives.PNG." i use this code to make the lives group (number of heart's icon)display on screen. //list the lives icon(number of heart's icon) on screen lives = game.add.group(); lives.fixedToCamera = true; for (var i = 0; i < player_health; i++) { //player_health = 12; lives.create(300 - (i * 30), 0, 'live'); } When enemy collide the player or player get hurt, it remove one live in lives group and remove one heart's icon from screen // When enemy collide the player or player get hurt, it remove one live in lives group and remove one heart's icon from screen var reduce_heart = lives.getFirstAlive(); player_health = player_health -1; if (reduce_heart) { reduce_heart.kill(); } when the player heal his life, the lives will increase one live in lives group and one heart's icon from screen. //when the player heal his life, the lives will increase one live in lives group and one heart's icon from screen. var increase_heart = lives.getFirstExists(false); player_health = player_health +1; if (increase_heart) { increase_heart.revive(); } Here is my Problem, The heart's icon is increase in the lives list last position, you can see the photo that named "increase_health_icon.PNG". var increase_heart = lives.getFirstExists(false); player_health = player_health +1; if (increase_heart) { increase_heart.revive(); } This code is revive the first remove heart's icon, but I hope it can revive heart's icon reverse, How to do it??? thank you very much. I am sorry about my poor English , sorry
  7. Hello everyone, I am developing a platform game like super Mario , I hope the enemy can move left and right horizontal and loop this. I just use very stupid way to make it. I use this code is work. if (enemy.x<= 450){ enemy.body.velocity.x = +200; } else if (enemy.x>= 800){ enemy.body.velocity.x = -200; } if I have more than one enemy, I need to set each of their values. I try to use game.add.tween eg game.add.tween(enemy).to({ x: enemy.x+80 }........, It also work!!!!!!! but same problem , I need to set each of their values. I try to use time.events, but no success. What are the easy way to set enemy auto move left and right horizontal and loop this? Thanks you very much.