khleug35

Members
  • Content Count

    60
  • 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

    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
  2. khleug35

    About two virtual button mouse down at same time

    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
  3. khleug35

    Full Game Tutorial: Making Minesweeper

    Thank you for your tutorial, very detail and helpful!!
  4. 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!!!
  5. 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!!!!!!
  6. khleug35

    How to make gravity not affect some sprite.

    @enpu Thank you for your help , It work!!!!!!
  7. game.createScene('Main', { gravity: 2100, init: function() { this.world = new game.Physics(); this.world.gravity.y = this.gravity; ...... }); game.createClass('Bird',{ ....... this.body.velocityLimit.y = 1; //It can make the sprite prevent gravity ...... }); I use this code to make some sprite prevent gravity this.body.velocityLimit.y = 1; but I think this is not best way to solve problem. the sprite can't move to y position any idea?? Thanks
  8. khleug35

    How make saves in Phaser?

    save game localStorage.setItem("item-key", "item data"); get save data localStorage.getItem("item-key"); delete save localStorage.removeItem("item-key");
  9. Oh, Many Thank you for your help @Wolfsbane Finally I work on it !!!!!!!! Really Really Thanks !!!!!!!! firstly I added this code on player class collide: function(body, dir) { if (body.collisionGroup === 2) { this.onPlatform = true; // default is false this.myPlatform = body; }else{ this.onPlatform = false; } and add this code on float platform update function update: function() { if (game.scene.player.onPlatform) { game.scene.player.body.position.x -= ( this.float_platformer.position.x - this.body.position.x); } this.float_platformer.position.x = this.body.position.x; this.float_platformer.position.y = this.body.position.y; } It work!!!! Thanks again, for the help on this , have a nice day
  10. Hello everyone, I am beginner of panda2. I would like to create a platformer game like Kuru Panda, so I download panda2-template-platformer.zip to start my project. and want to create a float platform that can move right to left or left to right on game like the following demo 2:26 but I am not successful to create that, the player can't move when drive on the float platform game.createClass('Float_platformer', { init: function() { this.float_platformer = new game.Sprite('float_platformer.png'); this.float_platformer.anchorCenter(); this.float_platformer.addTo(game.scene.container); this.body = new game.Body(); this.body.mass = 0; this.body.position.x = 1260; this.body.position.y = 1460; this.body.collisionGroup = 2; var shape = new game.Rectangle(); shape.width = this.float_platformer.width; shape.height = this.float_platformer.height; this.body.addShape(shape); this.body.static = true; this.body.addTo(game.scene.world); game.Tween.add(this.body.position, { x: 1560 }, 2000, { easing: 'Quadratic.InOut', repeat: Infinity, yoyo: true }).start(); }, update: function() { this.float_platformer.position.x = this.body.position.x; this.float_platformer.position.y = this.body.position.y; } }); game.createClass('Player', { ..... collide2: function(other) { if (other.collisionGroup === 2) { this.body.velocity.x = 200; } }, .... )}; any tips or idea??? Thank you very much
  11. khleug35

    Virtual Joystick plugin

    I think that he means Multi-Touch. right?? @BillyKane My case: the joystick of movement control on left hand side, the shoot button on right hand side of screen. when I hold movement joystick and touch the ''shoot button" on mobile. it have an effect on movement control. My solution is disable joystick's mousedown function on right hand side of screen. (but I’m Not Sure Is it the best way to solve the problem) open the joystick.js file , and try this code on update update: function() { if(game.input.mouse.x < 550){ if (!this.active) return; var angle = this._mouseDownPos.angle(game.input.mouse); var dist = this._mouseDownPos.distance(game.input.mouse); var radius = this.bg.shapes[0].shape.radius / 2; if (dist > radius) dist = radius; this.pad.position.x = Math.cos(angle) * dist; this.pad.position.y = Math.sin(angle) * dist; this.axis.x = this.pad.position.x / radius; this.axis.y = this.pad.position.y / radius; } }
  12. khleug35

    Panda2 on gamefromscratch !

    Good Job!!!! Panda is great!!
  13. khleug35

    How to active Virtual Joystick plugin on game??

    I solved this, I modified Player class update function movement code, it worked😀, thx @enpu if (game.keyboard.down('LEFT') || joystick.axis.x < 0) { this.body.velocity.x = -this.walkSpeed; } else if (game.keyboard.down('RIGHT') || joystick.axis.x > 0) { this.body.velocity.x = this.walkSpeed; } else{ this.body.velocity.x = 0; } if (game.keyboard.down('UP') || joystick.axis.y < 0) { this.body.velocity.y = -this.walkSpeed; } else if (game.keyboard.down('DOWN') || joystick.axis.y > 0) { this.body.velocity.y = this.walkSpeed; } else { this.body.velocity.y = 0; }
  14. khleug35

    How to active Virtual Joystick plugin on game??

    Thx. @enpu I added it but still not work, I try to add the following code this.body.velocity.x += game.scene.joystick.axis.x * 200 * game.delta; this.body.velocity.y += game.scene.joystick.axis.y * 200 * game.delta; the player still not move , anyidea? thanks