• Content count

  • Joined

  • Last visited

  1. Hello, I have 2 sprite animations. Once first one is played, via below function I'm checking frame index (which frame is currently playing). When current frame is my desired frame, I want to play another sprite. animations.currentAnim.onUpdate Below is my full code: firstSprite.visible = true; firstSprite.animations.currentAnim.enableUpdate = true;'firstSprite', 14, false); firstSprite.animations.currentAnim.speed = 80; firstSprite.animations.currentAnim.onUpdate.add(function () { if(firstSprite.animations.currentAnim.frame > 5){ secondSprite.visible = true;'secondSprite', 30, false); secondSprite.animations.currentAnim.speed = 60; } }, this); On desktop in a browser it works perfectly, but on mobile devices it is being stucked and once frame is greater than 5 (if(firstSprite.animations.currentAnim.frame > 5){...}), then it stops at that frame and doesn't continue to play first sprite. Is there something I'm missing. Thanks
  2. Hey guys, Is there a way to detect when the ball stopped moving inside input.onUp callback function? game.input.onUp.add(gameUpAction, this); function gameUpAction(pointer){ if (Math.abs(ballGraphic.body.velocity.x) < 1 && Math.abs(ballGraphic.body.velocity.y) < 1) { console.log("ball just stopped moving"); } } With above code it doesn't working (actually I understand why it is not working). I think here I need to use it in some other way. Any ideas please? Thanks
  3. Thanks. It is really nice idea. I used holes and updated the logic a bit and now can control the ball. Thanks a lot.
  4. Yes, now I see that ball moves when there is a gravity and without gravity ball doesn't move. But my issue is that can't find any logic formula between gravity, friction and damping so that can stop the ball at a place where I want it to be stopped (i.e near the holes,etc...). For example, with below code it is near to first hole, but I just played with below numbers to get this result which makes things harder: game.physics.p2.gravity.y = -250; game.physics.p2.friction = 6; ballGraphic.body.velocity.y = -200; ballGraphic.body.damping = -1; Maybe you or someone has something in your mind re this? Thanks
  5. Seems found some temporary solution for pointer. Re your example - when I add this line `game.physics.p2.enable(ballGraphic);`, the ball starts immediately to go around the channel. Why it starts to move? And also when it starts to move, then it comes back, how to stop that behaviour? I mean either move ahead or stop at certain point. Do you have any ideas please?
  6. Thanks for the suggestions on how to move the ball and also for the updated example. Though in your example the ball sometimes moves and sometimes no. In your example you use game.input.activePointer.isDown, how can I check activePointer for specific sprite? I wanna reach it for pressing the ball holder so that I can move the ball to the corresponding part depending on pressed duration. Here is my code: var ballButton; ballButton = game.add.sprite(196, 100, 'ballHolder'); ballButton.inputEnabled = true;, this); function inputDownAction(ballButton, pointer) { /* returns 0 */ console.log( pointer.duration); } pointer.duration is not working and returns 0. But game.input.activePointer.duration inside update() function is working and returns duration. if (game.input.activePointer.duration > 200 && game.input.activePointer.duration < 500){ console.log('first range '+game.input.activePointer.duration); }else if(game.input.activePointer.duration > 500 && game.input.activePointer.duration < 700){ console.log('second range '+game.input.activePointer.duration); }else if(game.input.activePointer.duration > 700){ console.log('third range '+game.input.activePointer.duration); } Any ideas on how to get activepointer for the specific sprite? Thanks
  7. Thanks for sharing the tool and codepen example with me. How I can move the ball at certain point? Like once my holder sprite is pressed, ball should move correspondingly. How to make it move ahead? And also I can't make the ball to move all around the channel, do you have any idea on how to do that please?
  8. Hi, Thanks for the feedback. Attached please find my graphic look and the json file which I created with PhysicsEditor program. I think something is wrong with my json file. Can you please have a look at it? I checked your json file and it is different from mine. I generate the json files like this: 1. Adding my sprite png file into the program 2. Then I use "Shape tracer" tool and click "Ok" in opened window. 3. From Exporter dropdown choosing "Lime + Corona (JSON)" 4. Click on "Publish" button to get the json file. I'm missing something? Thanks myChannelRoad.json
  9. Hello, I'm creating my first mobile game via Phaser framework and canvas. So for creating the channel (please check attached screenshot of my spiral channel) I imported my sprite into Physics Editor program, did what is described in this tutorial. Now trying to prepare the part when user will press/touch the ball holder, after touch/press the ball should rotate around the channel and depending on the speed it should fall into holes. Did some research but can't find any example on how I can make the ball move around the channel. Any ideas will be appreciated. I have following code for loading spiral sprite and its json file: preload: function() { game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; game.load.image("spiral", "assets/images/pinball-channel.png"); game.load.image("ballHolder", "assets/images/ball-holder.png"); game.load.image("ball", "assets/images/ball.png"); game.load.physics("physicsData", "assets/sprite_physics.json"); }, create: function() { var ballHolderGraphic; ballHolderGraphic = game.add.sprite(196.5, game.height-98, 'ballHolder'); ballHolderGraphic.width = 60; ballHolderGraphic.height = 104; ballGraphic = game.add.sprite(213, game.height-ballHolderGraphic.height-23, 'ball'); ballGraphic.width = 28; ballGraphic.height = 28; var channel; game.physics.startSystem(Phaser.Physics.P2JS); channel = game.add.sprite(225, 365, 'spiral'); channel.width = 400; channel.height = 550; game.physics.p2.enable(channel, false); channel.body.clearShapes(); channel.body.loadPolygon('physicsData', 'spiral'); } Also I have one issue, after this line (channel.body.loadPolygon('physicsData', 'spiral');) nothing (image, button,etc...) is being displayed in the screen but once I add them before this channel part, it works perfectly. Any ideas why? Thanks