steffmeister

Members
  • Content Count

    6
  • Joined

  • Last visited

About steffmeister

  • Rank
    Newbie

Contact Methods

  • Website URL
    http://www.steffmeister.at

Profile Information

  • Gender
    Male
  1. So, your suggestion is wrong I guess, according to the documentation: So, the second parameter resetFrame would be the frame# of the mentioned animation. What I tried now is playing around with setting frame, I put this in the oninput handler instead of the animation.play function: framedemo.frame++;if (framedemo.frame >= 5) framedemo.frame = 0;and this works as expected. I wonder if playing an animation modifies this behaviour, so that setting frame 0 is impossible?!
  2. Thanks for your answer. I also came to that conclusion but why? I understand stop() would do that, but why is the frame=0 line not produce anything? I updated your demo with your suggestion but it has the same effect. :/
  3. This forum is great Thanks for your answers, setting frame looks the way to go, but I have a strange problem, maybe you can see what mistake I am making? I uploaded a demo here: http://www.steffmeister.at/dev/phaser/demos/frame.html Clicking on the number should count to 5 twice, and then get back to 0, but it jumps back to 1, why is that so? This is the code: window.onload = function() { var game = new Phaser.Game(400, 400, Phaser.AUTO, '', { preload: preload, create: create }); var framedemo; function preload () { game.stage.backgroundColor = '#fff4d9'; game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; game.scale.setScreenSize(); game.load.spritesheet('framedemo', 'framedemo.png', 264, 428, 6); } function create () { framedemo = game.add.sprite(10, 10, 'framedemo'); framedemo.animations.add('count', [1,2,3,4,5], 5, true); framedemo.inputEnabled = true; framedemo.events.onInputDown.add(function() { console.log('pressed'); framedemo.animations.play('count'); }, this); framedemo.events.onAnimationLoop.add(function(){ console.log(framedemo.animations.currentAnim.loopCount); if (framedemo.animations.currentAnim.loopCount >= 2) { framedemo.animations.stop(); framedemo.frame = 0; } }, this); } };and this is the spritesheet: I removed everything unnecessary, but it always jumps back to 1 and not 0. Can you help me? Kind regards, Stefan.
  4. Hi there, I have a fundamental question about Phaser Sprites and Animations. What I want is to play an animation and then go back to the first frame of an spritesheet. The first frame of the spritesheet however is not part of the animation. Some code here: figure1 = game.add.sprite(300, 1400, 'figure1');figure1.animations.add('stand', [0], 1, false);figure1.animations.add('dosomething', [1,2,3,4,5,6], 6, false);figure1.inputEnabled = true;figure1.events.onInputDown.add(function() { figure1.animations.play('dosomething');}, this);figure1.events.onAnimationComplete.add(function(){ figure1.animations.play('stand');}, this);So, this should play the "dosomething" animation (frame 1 to 6) when the sprite is being clicked. After the animations completes it should go back to the initial position, which is contained in frame 0 = "stand animation". So here go the questions, is this the way to go? Do I have to create a "stand" pseudo animation? or is there some easier/better way to achieve this? (I am also just seeing, the stand animation would indefinitely fire the onAnimationsComplete event?!) Kind regards, Stefan
  5. Thanks for your code, this is working
  6. Hi I'm new to Phaser and I got through some examples, a thing which I am interested now is a draggable sprite while p2js physics is activated. It is no problem with arcade physics, but when switching to p2js the sprite does not react to drags. I have searched the forums but didn't find a good solution. I also found nothing in the documentation why this is not working as with arcade pyhsics (but I may be a bad searcher). (Basically I want to make a balloon sprite which floats to the top and one should be able to pull it down, after this it should be againt rise to the top.) I have an (non-working) example here (its also here http://steffmeister.at/dev/phaser/demos/balloon.html): <!DOCTYPE html><html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <script src="../phaser-master/build/phaser.min.js"></script> <title>Drag Test</title> </head> <body> <script type="text/javascript"> window.onload = function() { var game = new Phaser.Game(600, 800, Phaser.AUTO, '', { preload: preload, create: create }); var ball; function preload () { game.stage.backgroundColor = '#fff4d9'; game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; game.scale.setScreenSize(); game.load.image('ball', 'ball.png'); } function create () { game.physics.startSystem(Phaser.Physics.P2JS); ball = game.add.sprite(50, 50, 'ball'); game.physics.enable([ball], Phaser.Physics.P2JS); game.physics.p2.gravity.y = -100; ball.inputEnabled = true; ball.input.enableDrag(true); ball.events.onDragStart.add(startDrag, this); ball.events.onDragStop.add(stopDrag, this); } function startDrag() { // You can't have a sprite being moved by physics AND input, so we disable the physics while being dragged ball.body.moves = false; console.log('startdrag'); } function stopDrag() { // And re-enable it upon release ball.body.moves = true; console.log('stopdrag'); } }; </script> </body></html>The events are fireing, so that is not the problem. Can someone tell me what I have to change to make this working? Kind regards, Stefan.