• Content Count

  • Joined

  • Last visited

About steffmeister

  • Rank

Contact Methods

  • Website URL

Profile Information

  • Gender
  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 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: 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; { console.log('pressed');'count'); }, this);{ 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; {'dosomething');}, this);{'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 <!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);, this);, 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.