Jump to content

Search the Community

Showing results for tags 'onDown'.

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

  1. In my game I want my character to instantly move to predetermined points at the press of the left and right arrow keys. The player starts at x coordinate of 0. Here is my current code: var n = 0; cursors = game.input.keyboard.createCursorKeys(); var coordinates = [{x: 0}, {x: 100}, {x: 200}, {x: 300}, {x: 400}]; if (cursors.left.isDown && player.position.x != 0) { n -= 1; player.position.x = coordinates[n].x; } if (cursors.right.isDown && player.position.x != 400) { n += 1; player.position.x = coordinates[n].x; } So this basically works, but the problem is it runs it for however long I have the key pushed down, and I want it to only run once per key stroke. I read that onDown is what I'm looking for, but I'm not sure how to use that. Can someone help me out or suggest a better way?
  2. Hi I have game.input.onDown and mySprite.events.onInputDown listeners in game. I add listener for on game later than on sprite but listener for game triggers before event on sprite. Is there any way i can manipulate event flow. Similar to what we have in DOM events ( event.target event.currentTarget event.preventDefault() event.stopPropagation() ) Can i stop event in game listener (if sprite was clicked too) or force event to trigger on sprite first under some condition?
  3. I already found the solution for my problem. Please delete this topic.
  4. I’m trying to give user an option to choose one from 4 buttons, but when multiple keys are pressed at once, it executes more functions than one. keyQ.onDown.add(upA, this); keyW.onDown.add(upB, this); keyE.onDown.add(upC, this); keyR.onDown.add(upD, this); keyT.onDown.add(dismiss, this); I tried to use isDown like this, but It isn't working outside update function if (this.keyQ.isDown) { upA(); } else if (this.keyW.isDown) { upB(); }
  5. I don't know how to drag sprites in touch device, I'm trying something like that: function Play() {} Play.prototype = { create: function() { this.game.add.sprite(0, 0, 'background1'); this.fitxa1 = this.game.add.sprite(100, 250, 'fitxa1'); // Input Enable the sprites this.fitxa1.inputEnabled = true; // Allow dragging // enableDrag parameters = (lockCenter, bringToTop, pixelPerfect, alphaThreshold, boundsRect, boundsSprite) this.fitxa1.input.enableDrag(); //this.fitxa1.input.onDown.add.enableDrag(); // Enable snapping. For the atari1 sprite it will snap as its dragged around and on release. // The snap is set to every 32x32 pixels. // enableSnap(snapEvery32PixelsOnX, snapEvery32PixelsOnY, snap on drag, snap on released) this.fitxa1.input.enableSnap(15, 15, false, true); // Mobile this.game.input.onDown.add(this.toDrag, this); }, update: function() { }, clickListener: function() { this.game.state.start('gameover'); }, toDrag: function(){ // Input Enable the sprites this.fitxa1.inputEnabled = true; // Allow dragging // enableDrag parameters = (lockCenter, bringToTop, pixelPerfect, alphaThreshold, boundsRect, boundsSprite) this.fitxa1.input.enableDrag(); // Enable snapping. For the atari1 sprite it will snap as its dragged around and on release. // The snap is set to every 32x32 pixels. // enableSnap(snapEvery32PixelsOnX, snapEvery32PixelsOnY, snap on drag, snap on released) this.fitxa1.input.enableSnap(15, 15, false, true); console.log('Hola'); } };but it doesn't work, can you help me please??! Thank you!
  6. Hi everyone, I'm new in Phaser and start make a flying bird game. Ive already searched for my problem everywhere and read examples, still have no clue. My question about onhold on screen, i dont want people keep tapping on screen to get the bird fly. I want the bird fly when people hold finger on screen, and the bird fall when stop hold screen. Here my code: function create() { game.physics.startSystem(Phaser.Physics.ARCADE); // When all assets are loaded, go to the 'menu' state bird = game.add.sprite(100, 0, 'bird'); game.physics.enable(bird, Phaser.Physics.ARCADE); bird.animations.add('bird'); bird.animations.play('bird', 6, true); bird.body.gravity.y = 100; game.inputEnabled = true; game.input.onDown.add(fly, this); // This is Working game.input.onHold.add(fly, this); // This is Not Working } function fly () { bird.body.velocity.y =-10; } Question here http://www.html5gamedevs.com/topic/1574-gameinputondown-question/ close mine, but i don't know how to fix! Thanks everyone!
×
×
  • Create New...