khleug35

Members
  • Content Count

    69
  • Joined

  • Last visited

About khleug35

  • Rank
    Advanced Member
  • Birthday 09/08/1995

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. khleug35

    How to detect device before game initialisation?

    @enpu Great!!! Thank you very much!!
  2. How to detect desktop or mobile before game initialisation?? I use the following code to detect var DetectDevice = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent); if (DetectDevice) { console.log("You are using Mobile"); } else { console.log("You are using Desktop"); } Is there any easy way to detect?? thank you very much
  3. Oh!!! Thank you so much!! that is what I want
  4. thanks I want to create a html5 game in my office(free time ). but my office computer will reset all setting to default after a restart, due to I am not enough permission install software (such as XAMPP), so if I need to contact office administrator to help me install each time .....................
  5. Finally I use Bracket Editor Live Preview function to open the index.html It is no bug, but still can't show the image
  6. Is it possible to load image with out web server ?? function preload () { this.load.image('einstein', 'assets/ra-einstein.png'); } It can run in loacal sever, eg. localhost/GAME/myphaser3project/index.html It can load the image but if I double click the index.html, Is show this error Is it possible to load image with out web server?? Thanks you very much
  7. khleug35

    Is it possible to rotation the body?

    @enpu ok, thank you for your help, cheer
  8. I would like to create slopes platform and make the player stand on it I use rotation method, it is work on sprite , but not work in body.......any idea, thank you very much game.addAsset('sprite.png'); game.createScene('Main', { init: function() { this.sprite = new game.Sprite('sprite.png'); this.sprite.anchor.set(50, 50); this.sprite.position.set(game.width / 2, game.height / 2); this.sprite.addTo(this.stage); var shape = new game.Rectangle(); shape.width = this.sprite.width; shape.height = this.sprite.height-20; this.body.addShape(shape); this.body.addTo(game.scene.world); }, update: function() { this.sprite.position.copy(this.body.position); this.sprite.rotation = 0.4; this.body.rotation = 0.4; // not work } });
  9. The following code is my way to create start menu but I think it is stupid way and hard code .................. Full Code: game.module('game.main').body(function() { game.addAsset('font.fnt'); game.addAsset('select_arrow.png'); game.createScene('Main', { backgroundColor: "#000000", init: function() { this.StartGame = new game.Text('Start Game'); this.StartGame.anchorCenter(); this.StartGame.x = game.width / 2; this.StartGame.y = game.height / 2; this.StartGame.addTo(this.stage); this.StartGame.interactive = true; this.StartGame.mousedown = function() { game.system.setScene('Stage1'); }; this.HowtoPlayGame = new game.Text('How To Play'); this.HowtoPlayGame.anchorCenter(); this.HowtoPlayGame.x = game.width / 2; this.HowtoPlayGame.y = game.height / 2 + 150; this.HowtoPlayGame.addTo(this.stage); this.HowtoPlayGame.interactive = true; this.HowtoPlayGame.mousedown = function() { game.system.setScene('HowToPlay'); }; this.ExitGame = new game.Text('Exit'); this.ExitGame.anchorCenter(); this.ExitGame.x = game.width / 2; this.ExitGame.y = game.height / 2 + 300; this.ExitGame.addTo(this.stage); this.ExitGame.interactive = true; this.ExitGame.mousedown = function() { game.system.setScene('Exit'); }; this.arrow_select = new game.Arrow_Select(game.width / 2, game.height / 2); this.arrow_select.arrow_select.addTo(this.stage); }, update: function() {} }); game.createClass('Arrow_Select', { init: function(x, y) { this.arrow_select = new game.Sprite('select_arrow.png'); this.arrow_select.selectTime = true; this.arrow_select.anchorCenter(); this.arrow_select.position.set(x, y); }, reset: function() { if (!this.arrow_select.selectTime) { game.Timer.add(500, function() { game.scene.arrow_select.arrow_select.selectTime = true; }); } }, update: function() { // Movement if (game.keyboard.down('UP') && this.arrow_select.selectTime && this.arrow_select.y != 360) { this.arrow_select.y = this.arrow_select.y - 150; this.arrow_select.selectTime = false; this.reset(); } else if (game.keyboard.down('DOWN') && this.arrow_select.selectTime && this.arrow_select.y != 660) { this.arrow_select.y = this.arrow_select.y + 150; this.arrow_select.selectTime = false; this.reset(); } switch (this.arrow_select.y) { case game.scene.StartGame.y: if (game.keyboard.down('ENTER')) { game.system.setScene('Stage1'); } break; case game.scene.HowtoPlayGame.y: if (game.keyboard.down('ENTER')) { game.system.setScene('HowToPlay'); } break; case game.scene.ExitGame.y: if (game.keyboard.down('ENTER')) { game.system.setScene('Exit'); } } } }); }); The code is working!!!! But I think it is not the clever way do make it, It is hard code In Arrow_Select class I set it to 500 time to select up or down to avoid the Arrow_Select move very fast. reset: function(){ if(!this.arrow_select.selectTime){ game.Timer.add(500, function() { game.scene.arrow_select.arrow_select.selectTime = true; }); } }, In Arrow_Select update tag When Arrow_Select.y equal the menu choose.y and down "Enter" button , it can start the scene update: function() { // Movement if (game.keyboard.down('UP') && this.arrow_select.selectTime && this.arrow_select.y != 360) { this.arrow_select.y = this.arrow_select.y - 150; this.arrow_select.selectTime = false; this.reset(); } else if (game.keyboard.down('DOWN') && this.arrow_select.selectTime && this.arrow_select.y != 660) { this.arrow_select.y = this.arrow_select.y + 150; this.arrow_select.selectTime = false; this.reset(); } switch (this.arrow_select.y){ case game.scene.StartGame.y: if (game.keyboard.down('ENTER')){ game.system.setScene('Stage1'); } break; case game.scene.HowtoPlayGame.y: if (game.keyboard.down('ENTER')){ game.system.setScene('HowToPlay'); } break; case game.scene.ExitGame.y: if (game.keyboard.down('ENTER')){ game.system.setScene('Exit'); } } } Any other best way???? Thanks
  10. khleug35

    Getting the console.log from mobile

    I use this way to get the console.log value on mobile.... for example: I want to get player.position.x value init: function() { .... this.DebugText = new game.SystemText(''); this.DebugText.addTo(this.stage); .... ), update: function(){ //console.log(this.player.position.x); this.DebugText = this.player.position.x; } Other issues: game.Debug.updatePanel is not work on Panda Remote (The screen is blank); Is it my mistake or forget to set something??? Thx
  11. khleug35

    DEL

    Sorry,It is my mistake Yesterday ,I tried to update and edit the question on my phone. I deleted the entire post accidentally, so I need to ask this question again. sad
  12. khleug35

    DEL

    DEL
  13. khleug35

    Full Game Tutorial: Making Minesweeper

    Thank you for your tutorial, very detail and helpful!!
  14. khleug35

    Problem about collision Between two sprites

    @Wolfsbane awesome !!! it work!!!!! Thank you very much for the awesome code and teaching me!!! Have a nice day!!! Thanks again!!!
  15. My Full code game.module( 'game.main' ) .require( ) .body(function() { game.addAsset('logo.png'); game.createScene('Main', { init: function() { this.world = new game.Physics(); this.world.gravity.y = 0; this.Box1 = new game.Box1(220,800); this.Box1.sprite.addTo(this.stage); this.Box2 = new game.Box2(game.width/2,game.height/2); this.Box2.sprite.addTo(this.stage); this.Box1Text = new game.SystemText(''); this.Box1Text.position.set(100,100); this.Box1Text.size = 36; this.Box1Text.addTo(this.stage); this.Box2Text = new game.SystemText(''); this.Box2Text.position.set(100,150); this.Box2Text.size = 36; this.Box2Text.addTo(this.stage); } }); game.createClass('Box1', { init: function(x, y) { this.body = new game.Body(); this.body.collisionGroup = 1; this.body.collideAgainst.push(2); this.body.position.set(x, y); this.body.collide = this.collide.bind(this); this.sprite = new game.Sprite('logo.png'); this.sprite.anchorCenter(); var shape = new game.Rectangle(this.sprite.width, this.sprite.height); this.body.addShape(shape); this.body.addTo(game.scene.world); this.body.collide = this.collide.bind(this); }, collide: function(body) { if (body.collisionGroup === 2) { game.scene.Box1Text.text = 'Box1 is connect'; } return true; }, update: function() { if (game.keyboard.down('RIGHT')) { this.body.velocity.x = 250; } else if (game.keyboard.down('LEFT')) { this.body.velocity.x = -250; }else if (game.keyboard.down('UP')) { this.body.velocity.y = -250; }else if (game.keyboard.down('DOWN')) { this.body.velocity.y = 250; }else { this.body.velocity.set(0,0); } this.sprite.position.copy(this.body.position); } }); game.createClass('Box2', { init: function(x, y) { this.body = new game.Body(); this.body.collisionGroup = 2; this.body.collideAgainst.push(1); this.body.position.set(x, y); this.body.collide = this.collide.bind(this); this.sprite = new game.Sprite('logo.png'); this.sprite.anchorCenter(); var shape = new game.Rectangle(this.sprite.width, this.sprite.height); this.body.addShape(shape); this.body.addTo(game.scene.world); this.body.collide = this.collide.bind(this); }, collide: function(body) { if (body.collisionGroup === 1) { game.scene.Box2Text.text = 'Box2 is connect'; } return true; }, update: function() { if (game.keyboard.down('D')) { this.body.velocity.x = 250; } else if (game.keyboard.down('A')) { this.body.velocity.x = -250; }else if (game.keyboard.down('W')) { this.body.velocity.y = -250; }else if (game.keyboard.down('S')) { this.body.velocity.y = 250; }else { this.body.velocity.set(0,0); } this.sprite.position.copy(this.body.position); } }); }); When user keydown the "UP or DOWN or RIGHT, or LEFT" key can move the Box1 Class When Box1 move to Box2 body and they are colliding. The Box1text is show " Box1 is connect" collide: function(body) { if (body.collisionGroup === 2) { game.scene.Box1Text.text = 'Box1 is connect'; } return true; }, and Box2text is show " Box2 is connect", collide: function(body) { if (body.collisionGroup === 1) { game.scene.Box2Text.text = 'Box2 is connect'; } return true; }, but only Box1text successful show the text. I have set collide: function to box1.class and box2.class, what is the problem game.createClass('Box1', { .......... this.body.collisionGroup = 1; this.body.collideAgainst.push(2); this.body.collide = this.collide.bind(this); .......... collide: function(body) { if (body.collisionGroup === 2) { game.scene.Box1Text.text = 'Box1 is connect'; } return true; }, .......... }); game.createClass('Box2', { .......... this.body.collisionGroup = 2; this.body.collideAgainst.push(1); this.body.collide = this.collide.bind(this); }, collide: function(body) { if (body.collisionGroup === 1) { game.scene.Box2Text.text = 'Box2 is connect'; } return true; }, .......... Please don't use the following method //the following code is Work, but I don't use this method ,thanks you very much game.createClass('Box1', { .......... this.body.collisionGroup = 1; this.body.collideAgainst.push(2); this.body.collide = this.collide.bind(this); .......... collide: function(body) { if (body.collisionGroup === 2) { game.scene.Box1Text.text = 'Box1 is connect'; game.scene.Box2Text.text = 'Box2 is connect'; } return true; }, .......... }); Thank you very much!!!!!!