khleug35

Members
  • Content count

    31
  • Joined

  • Last visited

  1. Thanks!! samme It work!! but Is it just work for tilemap?? ? Is it working for sprite ?? Thanks
  2. Is it possible to create steep path without NINJA PHYSICS? make the player stand on oblique platform or steep path and the player will slip down, Thank you very much https://jsfiddle.net/0z76tofy/ var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update}); var player; var platforms; var cursors; var jumpButton; function preload() { game.stage.backgroundColor = '#85b5e1'; game.load.baseURL = 'http://examples.phaser.io/assets/'; game.load.crossOrigin = 'anonymous'; game.load.image('player', 'sprites/phaser-dude.png'); game.load.image('platform', 'sprites/platform.png'); game.load.image('platform2', 'sprites/platform.png'); } function create() { player = game.add.sprite(100, 100, 'player'); game.physics.arcade.enable(player); player.body.collideWorldBounds = true; player.body.gravity.y = 500; platforms = game.add.physicsGroup(); platforms.create(-100, 200, 'platform'); platforms.setAll('body.immovable', true); cursors = game.input.keyboard.createCursorKeys(); jumpButton = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR); } function update () { game.physics.arcade.collide(player, platforms); platforms.angle = 20; player.body.velocity.x = 0; if (cursors.left.isDown) { player.body.velocity.x = -250; } else if (cursors.right.isDown) { player.body.velocity.x = 250; } if (jumpButton.isDown && (player.body.onFloor() || player.body.touching.down)) { player.body.velocity.y = -400; } }
  3. Is this a smart way to code the player slash function?

    Oh!!!Thank you for your help and guidance !! Your code is clear and efficient.
  4. Hello everyone, I would like to create a platform game like Castlevania. Here is my full code of the example. This following code can achieve the slash effect, but I do not know is this a smart way?? Thanks https://jsfiddle.net/4m3uv052/ First, I prepared two image, One for main character , one for slash. The last position of slash.png is blank The purpose is when finish slash.png animation, the slash.png will disappear, no residue slash.animations.add('slash_attack', [0, 1, 2, 3 ,4], 20, false); Firstly, Make the slash not visible. If I make the slash image visible, when I run the game, it will show on game. slash.visible = false; Add the player slash logic in function update() if (player_sword_attack == false) { if (attackButton.isDown) { player_sword_attack = true; } } if (player_sword_attack == true) { attack(); game.time.events.add(Phaser.Timer.SECOND * 0.2, attack_stop, this); } fix the slash effect positon function attack() { slash.animations.play('slash_attack'); slash.body.x = sprite.body.x-5; //fix the slash effect positon slash.body.y = sprite.body.y-36; } function attack_stop() { player_sword_attack = false; } is this a smart way to code the player slash function? i am sorry for my poor english? Thank you very much https://jsfiddle.net/4m3uv052/
  5. Is it possible to set the fix point for sprite rotation?

    Thanks for remind!! I just use photoshop to set the image size , i works for me! Thanks
  6. I use the following example to get start. https://phaser.io/examples/v2/arcade-physics/shoot-the-pointer Is it possible to set the fix point for sprite rotation? Like the following images I try to use sprite..anchor.setTo (0.1,0.5), but not successful, Thanks you very much
  7. Works perfectly!!! You are so awesome!!!Thank you very much and have a nice day!!
  8. I use the following example to get start. https://phaser.io/examples/v2/arcade-physics/shoot-the-pointer When the arrow's angle <= 90 and >= 90, the arrow will stop move and can not shoot to the left!!!! I use the follow code function update() { //right if(sprite.angle <= -90 && sprite.angle >= -180){ sprite.angle=-90; } else if(sprite.angle >= 90 && sprite.angle <= 180){ sprite.angle=90; } //left /* if(sprite.angle >= -90 && sprite.angle <= 0){ sprite.angle = -90; } else if(sprite.angle <= 90 && sprite.angle >= 0){ sprite.angle = 90; } */ } But I hope the bullet not shoot to the left, any idea??? Thanks you so much Here is the jsfiddle link, Thanks https://jsfiddle.net/sjrup0h2/
  9. How to get the Sprites that is different position and size on Spritesheet?? Thx I want to get this "the Biggest dude" on this image use phaser and without use scale method function preload() { game.load.spritesheet('dude', 'assets/dude.png',32,48); } function create() { player = game.add.sprite(100, 200, 'dude'); player.animations.add('left', [0, 1, 2, 3], 10, true); player.animations.add('right', [5, 6, 7, 8], 10, true); //the dude become bigger, but I have no idea how to set it player.animations.add('Big', [?????], 10, true); } function update() { player.animations.play('Big'); } I want to get this "the Biggest dude" in the image bottom, it width is 72 and height is 72, Thanks you very much.
  10. [Solved]How to rotate the object and reverse the image

    Thanks!!!! It works!!! thanks 3man7!!!! thank you for your help!!! you are awesome, Thanks
  11. Happy New Years every one. I use this sample to create some game that the user can use their mouse to change the gun direction https://phaser.io/examples/v2/arcade-physics/angle-to-pointer I use the gun image to replace the arrow.png image I hope when the object rotate to left or right ,the image(gun) can reverse like the following image. The following image is when the pointor go to the top left Here is my Script: var sprite; var faceRight = false; var faceLeft = true; //I try to use the follow script to fix the sprite postion if(sprite.angle <= 90 && sprite.angle >= -90){ console.log("Right"); if (faceLeft == true) { sprite.scale.y *= -1; sprite.anchor.y = 0.5; faceLeft = false; faceRight = true; } }else{ console.log("Left"); if (faceRight == true) { sprite.scale.y *= -1; sprite.anchor.y = 0.5; faceRight = false; faceLeft = true; } } But not successful, The following image is my fail example, any idea how to do it?? thx Thanks you very much, I am sorry for my pool English.
  12. Delete

    Delete
  13. Delete

    Delete
  14. thanks for reply I using ogg and mp3 ....... I try to convert this example to android apk file https://phaser.io/examples/v2/audio/play-music It also can't run the game about audio error......... when I use this code game.load.audio('boden', ['assets/audio/bodenstaendig_2000_in_rock_4bit.mp3', 'assets/audio/bodenstaendig_2000_in_rock_4bit.ogg']); but I use this code ,it is work game.load.audio('boden', ['http://examples.phaser.io/assets/audio/bodenstaendig_2000_in_rock_4bit.mp3', 'http://examples.phaser.io/assets/audio/bodenstaendig_2000_in_rock_4bit.ogg']); I find that phonegap can't play local audio...... but this audio problem just occurs on android
  15. hello ,thank you for reply. I used Adobe PhoneGap, but when I build the game to apk file and run it on android It can't play the audio , I need to use phonegap media api to instead of Phaser audio code...... and I run the game on the android platform below 5.0 versions, It is very lag................ It is run very prefect on browser and IOS,^_^ thx