Jump to content

Search the Community

Showing results for tags 'signal'.

  • 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 7 results

  1. Hi everyone, I'm trying to make a sprite moving when the mouse is over it and I'd like it to stop when the mouse is not over it anymore. Here is my code: mySprite.events.onInputOver.add(() => touchMouse = true); mySprite.events.onInputOut.add(() => touchMouse = false); and update() { if (touchMouse) { mySprite.x += 5; } } My sprite is correctly moving but the onInputOut signal is not dispatched if I don't move the pointer out of the initial position of the sprite !! This result in my sprite moving out of my pointer and continuing its journey until I move my mouse... Is it a phaser bug? Has anyone a solution to make this work? Thank you very much and have a good day, Simon Edit: I just tried to use the Phaser.InputHandler object instead but I got the same kind of bug. Here is the code: update() { if (mySprite.input.pointerOver()) { mySprite.x += 5; } }
  2. Iorana! I have just a little question about onInputOut behaivour in mobile/touch devices. I have this scenario in Phaser 2.6.2: A small lovely Sprite with inputEnabled activated to handle events, connected with events.onInputOver and events.onInputOut, just for hover actions. No problems there. If I test it in desktop, the signals are dispatched correctly if I move the mouse over the sprite and then move it away from it. But in mobile/touch the behaivour is different. Obviously, you can't "move" a touch Pointer like a mouse, but anyways if you tap the sprite events.onInputOver is dispatched. BUT, after that, if you tap other place somewhere in the screen there's not any events.onInputDown signal, resulting the game acting if there's still hovering the sprite. But keeping pressed the touchscreen and move Pointer it dispatch the desired signal. I know one can make workaround to handle this (if it is mobile check in the next tap, if the pointer is inside bounds of the sprite: If not, manually dispatch events.onInputOut signal), but I have the doubt in mind if this is the correct behaivour of the signal or not. (Probably not, but there's always a bug possiblity). I checked the docs and there's not much thing to say about the event: As yoy can see, the docs don't cover this particular case. If someone explains me this well if this must be work or not... Thanks in advance
  3. Hello, I am trying to make a small basketball free-throw game similar to the emoji basketball game on Facebook. I was following along with an example from Phaser (World Bounds Event) to try to respawn the ball when it hit the edge of the screen. I've tried to implement that below (see code) but the respawn function never fires. Does anyone know what I'm doing wrong? Envirolympics.TestGame = function (game) { //Variables this.score = null; this.scoreText = null; this.ball = null; this.net = null; this.leftMarker = null; this.rightMarker = null; this.launched = false; this.lastPointerPos = null; //Constants this.GRAVITY = 980; this.SHOOT_FORCE = 850; this.EDGE_CUSHION = 10; }; Envirolympics.TestGame.prototype = { create : function () { //Load net sprite this.net = this.game.add.sprite(this.game.world.centerX, 100, 'net'); this.net.anchor.setTo(0.5); //Add hoop children markers this.leftMarker = this.net.addChild(this.game.make.sprite(-50, 40, 'marker')); this.leftMarker.anchor.setTo(0.5); this.rightMarker = this.net.addChild(this.game.make.sprite(50, 40, 'marker')); this.rightMarker.anchor.setTo(0.5); //Load ball sprite this.ball = this.game.add.sprite(this.game.world.centerX, this.game.world.height - 100, 'ball'); this.ball.anchor.setTo(0.5); //Setting up the physics environment this.game.physics.startSystem(Phaser.Physics.ARCADE); this.game.physics.arcade.gravity.y = this.GRAVITY; //Setting up the ball physics this.game.physics.arcade.enable(this.ball); this.ball.body.bounce.setTo(0.35); this.ball.body.moves = false; this.ball.body.velocity.setTo(0, 0); this.ball.body.allowGravity = false; this.ball.body.collideWorldBounds = true; this.ball.body.onWorldBounds = new Phaser.Signal(); this.ball.body.onWorldBounds.add(this.respawn, this); //Enable input this.ball.inputEnabled = true; this.game.input.onDown.add(this.track, this); this.game.input.onUp.add(this.launch, this); //Initialize this.score = 0; this.scoreText = this.game.add.bitmapText(10, 10, 'pixel', this.score, 36); this.lastPointerPos = new Phaser.Point(0, 0); //For mobile Phaser.Canvas.setTouchAction(this.game.canvas, "auto"); this.game.input.touch.preventDefault = false; }, update : function () { //TO DO: //detect collision with net markers //determine if scored //respawn }, track : function () { //Update the last finger position this.lastPointerPos.x = this.input.x; this.lastPointerPos.y = this.input.y; //Set the ball physics to be still this.launched = true; this.ball.body.moves = false; this.ball.body.velocity.setTo(0, 0); this.ball.body.allowGravity = false; }, launch : function () { if (this.launched) { this.launched = false; this.ball.body.moves = true; this.ball.body.allowGravity = true; //Get the direction of finger swipe, normalize it, and apply a scalar to the velocity of the ball var direction = new Phaser.Point(this.input.x - this.lastPointerPos.x, this.input.y - this.lastPointerPos.y); direction.x = this.game.math.snapTo(direction.x, 5); direction.y = this.game.math.snapTo(direction.y, 5); Phaser.Point.normalize(direction, direction); if (direction.y < 0) { this.ball.body.velocity.setTo(direction.x * this.SHOOT_FORCE, direction.y * this.SHOOT_FORCE); } } }, respawn : function () { console.log("Does this function even run?"); //Set the ball physics to be still again this.ball.body.moves = false; this.ball.body.velocity.setTo(0, 0); this.ball.body.allowGravity = false; //Spawn the ball in a new, random location var ballSpawnX = this.game.rnd.integerInRange(this.ball.width + this.EDGE_CUSHION, this.world.width - this.EDGE_CUSHION); ballSpawnX = this.game.math.snapTo(ballSpawnX, 10); //Make sure the ball is in the boundary we set if (ballSpawnX < this.ball.width + this.EDGE_CUSHION) { ballSpawnX = this.ball.width + this.EDGE_CUSHION; } else if (ballSpawnX > this.world.width - this.EDGE_CUSHION) { ballSpawnX = this.world.width - this.EDGE_CUSHION; } this.ball.x = ballSpawnX; } };
  4. Hi, I'm having a problem (it looks like a bug) with phaser.signal detecting when a video has ended when using changeSource function. I'm using phaser 2.4.8 (but it also happened with 2.4.6). To reproduce the issue, please change both videos and the image button with some media you have. Once you run the demo, check your developer console each time button is pressed. The first time the video is stopped, it says "Played 1 times" The second time it says "Played 2 times" AND "Played 3 times" The third time it says "Played 4 times", "Played 5 times" AND "Played 6 times" and so on... It's like it is reporting when each video has stopped, not just the video that has just been "source changed". Here's the code: window.played = 0; var game = new Phaser.Game(1280, 720, Phaser.AUTO, 'gameCanvas', { preload: preload, create: create}); function preload() { game.load.video('Blank', 'vids/blank.mp4'); game.load.image('btn','gfx/btn_conoce.png'); } function create() { button = game.add.button(100, 400, 'btn', btnClick); video = game.add.video('Blank'); video.addToWorld(0, 0, 0, 0, 0, 0); videoOnStop = new Phaser.Signal(); video.onComplete = videoOnStop; game.world.bringToTop(button); videoOnStop.add(function() { played++; console.log("Video Stopped: Played " + played + " times"); }); } function btnClick() { video.changeSource('vids/anothervideo.mp4'); video.play(false); } Greets!
  5. I have on an extended Phaser.Game class the following let game = this; game.onGameStart = Phaser.Signal(); function startGame(){ game.onGameStart.dispatch(); } in an extended Phaser.State class I have the following create(){ let game = this.game; game.onGameStart.add(this.start, this); game.message.on('message', function(){ game.startGame(); } // message is a node server web socket remote trigger response game.paused = true; } function start() { this.game.paused = false; } When game.startGame() gets called start its called but the game._paused and game._codePaused is still set to true. WHY is this?
  6. Hey, I'm pretty new to the Phaser scene, and I was having trouble grokking the Phaser's signal system. I noticed there weren't any code examples in the Examples section, so once I got a handle on it, I made this little signals example: http://phaser.io/sandbox/NUpUhphz Hope this might help anyone else getting to know signals better!
  7. Yesterday I used onComplete to call a function after an animation finished playing. Today I ran the game and this error: Error: Phaser.Signal: listener is a required param of add() and should be a Function.The function still gets called and does its thing, but the game just stops because of the error. This didn't happen yesterday. The odd thing is that I do have a listener as parameter, and it is a function. My code: wait_for_animation: function(name,framerate) { playerState = 0; player.body.velocity.x = 0; player.animations.play(name, framerate, false); player.animations.currentAnim.onComplete.add(this.change_state(1), this); }, change_state: function(x) { //console.log("it works"); playerState = x; },The "wait_for_animation" function is being called once, not multiple times. What this stuff does is stops the player and plays a character animation. When the animation is done, the player can move again. When I comment out the line that adds the listener, the error doesn't come up.
×
×
  • Create New...