Jump to content

Search the Community

Showing results for tags 'animations phaser newbie'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 1 result

  1. Hello, i'm new to programming and i'm using phaser just for a few days. I'm trying to add a animation to my player, but when i do that, the game crashes. What i'm doing wrong? thats my code: window.onload = function() { var game = new Phaser.Game(800, 400, Phaser.AUTO, '', { preload: preload, create: create, update: update }); var player; function preload () { game.load.atlasJSONHash('walk', 'walk.png', 'walk.json'); game.load.atlasJSONHash('idle', 'idle.png', 'idle.json'); } function create () { //var background = game.add.sprite(0, 0, 'cityscene', 'background'); player = game.add.sprite(0, 325, 'walk', 'walk_0001.png'); player.scale.setTo(0.5,0.5); player.animations.add('walk', Phaser.Animation.generateFrameNames('walk_', 1, 31, '.png', 4), 10, true, false); player.anchor.setTo(.5,.5); player.animations.currentAnim.speed = 30; // Altera velocidade da animação. player.animations.add('idle', Phaser.Animation.generateFrameNames('idle_', 1, 99, '.png', 4), 10, true, false); } function update() { //player.x += 6; if(player.x > 800) { player.x = 0; } else if (player.x < 0){ player.x = 800; } if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) { player.scale.setTo(-0.5,0.5); player.animations.play('walk'); player.x -= 4; } else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) { player.scale.setTo(0.5,0.5); player.x += 4; player.animations.play('walk'); } else { // Stand still //player.animations.play(idle); } // if (game.input.keyboard.isDown(Phaser.Keyboard.UP)) // { // player.y -= 4; // } // else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) // { // player.y += 4; // } } }; I'm trying to add that "idle" animation. Thanks! (I'm not a native english speaker.) Edit: I can normally put the walk animation or the idle animation, when i put both animations, one of them don't work...
×
×
  • Create New...