Jump to content

Search the Community

Showing results for tags 'Keyboard'.

  • 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

  1. At the moment I'm just trying to switch in between game states by having the user press the spacebar. However, when the user holds down the spacebar, it continues to change. Is there a simple way to have the state change only once even when the spacebar is held down? I came across something called JustPressed, but it seems to be behaving in the same fashion as isDown. (rather than cycling through them infinitely when the spacebar is held down) I am brand new to Phaser and Javascript so a simple solution that's easy to understand would be amazing! // define game var game = new Phaser.Game(900, 500, Phaser.AUTO); // define MainMenu state and methods var MainMenu = function(game) {}; MainMenu.prototype = { preload: function() { console.log('MainMenu: preload'); }, create: function() { console.log('MainMenu: create'); game.stage.backgroundColor = "#facade"; }, update: function() { // main menu logic if(game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR)) { game.state.start('GamePlay'); } } } // define GamePlay state and methods var GamePlay = function(game) {}; GamePlay.prototype = { preload: function() { console.log('GamePlay: preload'); }, create: function() { console.log('GamePlay: create'); game.stage.backgroundColor = "#ccddaa"; }, update: function() { // GamePlay logic if(game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR)) { game.state.start('GameOver'); } } } // define GameOver state and methods var GameOver = function(game) {}; GameOver.prototype = { preload: function() { console.log('GameOver: preload'); }, create: function() { console.log('GameOver: create'); game.stage.backgroundColor = "#bb11ee"; }, update: function() { // GameOver logic if(game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR)) { game.state.start('MainMenu'); } } } // add states to StateManager and start MainMenu game.state.add('MainMenu', MainMenu); game.state.add('GamePlay', GamePlay); game.state.add('GameOver', GameOver); game.state.start('MainMenu');
  2. Collect the falling books and rack the highest combos as you can to achieve the best score! Watch out for fireballs! A community made game using Phaser 2! Link: https://tinyurl.com/y37jpqua Features: Global Leaderboard, Discord Authentication, Touch Controls, Keyboard Controls Our Discord: https://discord.gg/DfxF3HPKqQ
  3. Hi, Hope someone can help if I try to do a key press my animation stops until I let go of the key. (keys a and d) to move left and right - is there a way for the key press .onDown to be used once or an aletrantive way to have my animation play when the key is held down, I've tried using the docs but can't seem to find a solution eg demo below http://html5gamer.mobi/2019/ code snippet when pressing d if (this.keyRight.isDown){ this.player.anims.play('walkProper'); this.player.flipX = false; this.player.setVelocityX(150); } Thanks in advance Eric
  4. Hi everyone, are fine ? Sorry if this question is too simple but I'm losing my sanity for some hours and I don't reach solve the problem alone. I migrating a old project made in Phaser2 to Phaser3 and maybe I the lost the way to do things in Phaser3 way. I trying to the something bellow(phaser2) in Phaser3: input.keyboard.addKey(Phaser.Input.Keyboard.LEFT).onDown(callback); But it don't work on Phaser3, Key don't have onDown method (don't have any method that I see in source code) and I don't know a way to add eventListener to keys. I really don't espect to use verifications on update function, has another way to process keyboard input events ? Thanks for any help.
  5. How to pass the cursor object to a method that belongs to a class that inherits the Phaser.Sprite class? I have a class that inherits from Phaser.State in which I create a cursor object and pass it to the update method from another class. class Play extends Phaser.State { create() { this.physics.startSystem(Phaser.Physics.ARCADE) ... this.player = new Player({ game: this.game, x: 32, y: this.world.height - 150, asset: 'dude' }) this.game.add.existing(this.player) } update() { const cursors = this.input.keyboard.createCursorKeys() this.player.update(cursors) } } Player class - problem occurs in the if condition: class Player extends Phaser.Sprite { constructor({ game, x, y, asset }) { super(game, x, y, asset) this.game.physics.arcade.enable(this) this.body.bounce.y = 0.2 this.body.gravity.y = 300 this.body.collideWorldBounds = true this.animations.add('left', [0, 1, 2, 3], 10, true) this.animations.add('right', [5, 6, 7, 8], 10, true) } update(cursors) { this.body.velocity.x = 0 if (cursors.left.isDown) { this.body.velocity.x = -150 this.animations.play('left') } } } Error message: "TypeError t is undefined"
  6. Reservoir Cleansing. Short arcade type game, just kill the enemies each level: ARROWS (UP & DOWN) - Switch character Z - Attack X - Heal C - Power up (Character upgrades when bar fills) (MAX is Golden armour) It was just a small project to take a break from a big one (kaeBLUE). Won't be doing much to this , but any feedback will help improve any future versions, or even other games. - PLAY ON KONGREGATE - Thanks ?
  7. hello, Phaser 3: I use this code for a simple text input to get the value of it on ENTER press event: enterE = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.ENTER); but as chrome and some other mobile browsers user "go" instead of "enter", the above event does not trigger! is there any keyCode other than ENTER for that ?? or should use jquery??
  8. Hi all, I'm having an issue where sometimes .onup isn't registering after releasing a key, has anyone else encountered this? Is there a workaround that will still allow multiple keypresses? Any help is greatly appreciated, many thanks!
  9. Hey there, I'm trying to get a key to always call a certain function, regardless of which state my game is in. At the moment, my code is this: var escKey = null BasicGame.Boot = function (game) { //... }; BasicGame.Boot.prototype = { init: function () { escKey = game.input.keyboard.addKey(Phaser.Keyboard.ESC); escKey.onDown.add(function(){console.log("esc")}, game); } And so on. escKey stays defined in all states, but onDown doesn't trigger. If I move the two lines within init to a state, I can use ESC in that state, but not in any state after that. Is there a way to do this?
  10. I am working on a game which allow the player to enter the answer for math questions. Codes for typing the numbers are working such as: key1 = this.game.input.keyboard.addKey(Phaser.Keyboard.ONE); key1.onDown.add(this.press1, this); However, I can't seem to get the minus(-) working, it does not even trigger the key pressed. keyminus = this.game.input.keyboard.addKey(Phaser.Keyboard.MINUS); keyminus.onDown.add(this.pressminus, this); Is there any way I can implement the typing of '-'?
  11. Hi all. I have a problem managing the ghost character. I need that when the left button is pressed - the character flies to the left up, and play fly sound. But when the right button is pressed while the left button is pressed, the character stopped and stopped playing fly sound. if (this.leftKey.isDown) { //Play Fly sound, when LEFT key is pressed this.playFlySound(); this.ghost.body.moves = true; this.ghost.body.velocity.x = -120; this.ghost.body.velocity.y = -160; //Stop Fly sound, when LEFT key is pressed & RIGHT key pressed to if (this.rightKey.isDown) { this.stopFlySound(); this.ghost.body.moves = false; this.ghost.body.velocity.x = 0; this.ghost.body.velocity.y = 0; } } In my version of the code, the fly sound start play when the left button is released. Please help me with the problem.
  12. My code has a setup function that runs at the start. Within that setup function I have the left and right arrow keys setting up movement like so: left = keyboard(37); left.press = function(){ moveCharacterLeft(); }; It works fine. But then when I get a gameover my game runs a reset code and all variables are reset back to their former states and the setup function runs again. Well this means that the above function runs again as well, and this makes it so that each time I get a gameover and reset the game, the above function will run multiple times for each button press. So after one game over, if I hit the left key, the moveCharacterLeft() function will fire twice, and my character moves twice as far.. Three times for the next gameover.. ect.. Does anyone know how I can prevent this from happening? Admittedly I don't quite understand what's happening here..
  13. I'm using the following code to capture key entry, just numbers for now, but I would like to capture all keys. this.key0 = game.input.keyboard.addKey(Phaser.Keyboard.ZERO); this.key1 = game.input.keyboard.addKey(Phaser.Keyboard.ONE); this.key2 = game.input.keyboard.addKey(Phaser.Keyboard.TWO); this.key3 = game.input.keyboard.addKey(Phaser.Keyboard.THREE); this.key4 = game.input.keyboard.addKey(Phaser.Keyboard.FOUR); this.key5 = game.input.keyboard.addKey(Phaser.Keyboard.FIVE); this.key6 = game.input.keyboard.addKey(Phaser.Keyboard.SIX); this.key7 = game.input.keyboard.addKey(Phaser.Keyboard.SEVEN); this.key8 = game.input.keyboard.addKey(Phaser.Keyboard.EIGHT); this.key9 = game.input.keyboard.addKey(Phaser.Keyboard.NINE); for (let i = 0; i <= 9; ++i) { this['key' + i].onDown.add(this.keyPress, this); } and keyPress(key) { let character = String.fromCharCode(key.keyCode); this.keyInput += character; this.checkForCode(); } Do I need to call game.input.keyboard.addKey for every single key I want to detect? I feel like I missing be missing some functionality that listens for any key press. This doesn't need to work on phones, the purpose is cheat code entry in a computer browser only for my own testing purposes.
  14. Hi, In a menu state of mine, instead of pressing spacebar, I would like to let the player press any key to continue. What would be the best way to detect if any key is pressed?
  15. Hello there, I'm new to phaser and the first thing I had a minor quip with was the way animation calls were handled (they look messy and unorganized). I have experience coding in engines such as Vylocity ( http://vylocity.com ) where icon states are handled and managed by the direction the player/npc has chosen to go in. A player is set with an icon "state" which is a specific type of animation, each with its own directional states spit up (with the same number of states for each direction). This state references a file that is icons from a number to a number that those states are bound to. Here is an example of how the icon file looks, and i was wondering if there'd be an easy way to split up these images manually in code by specifying where each direction is, and then storing the file that they are referenced to as a string that would then be called. Then to set a character's animation, you would call this function that assigned the animation to it, grab the direction, and select the chosen section of the png file that contained that character's movement state. Maybe if I were to reorganize the icon file into something a bit easier for the engine to keep track of it wouldn't end up messy code-wise, especially when I needed to edit something. I could just split up each character direction into it's own file - the initial state would be for inactive movement while facing that direction, while the rest of the states would play while moving (e.g. while the key is being held) Can I get some idea on how I'd go about coding this. or if there already exists a library that simplifys animation calls.
  16. Hello everyone, can you told me why my code is not working ? i don't understand why is not working, i got inspired with this : https://phaser.io/examples/v2/input/keyboard-hotkeys my code: function preload(){ game.load.image('bulleRpg', 'assets/bulleRpg/bulleRpg.png'); } var spaceKey; function create(){ spaceKey = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR); spaceKey.onDown.add(drawBulleRpg, this); } function drawBulleRpg() { game.add.sprite(game.world.centerX + 250, game.world.centerY + 150, 'bulleRpg'); } i want just display an image when i press the spacebar. Thx lot of
  17. Hi everyone, I just tested the keyboard input examples of Phaser on Microsoft Edge and it doesn't work as it should. Sometimes it won't detect key presses or keep a key pressed down even if I already stopped pressing it. I had the same problem with a game we're developing and I even noticed that some of the old games we've developed have the same problem when testing on Edge. Has anyone else had this problem? Should I raise it as an issue on the repository?
  18. In my main scene I add keyboard event listeners to specific keys in the init() state. Also some of those keys need to be disabled at specific time and re-enabled at specific time. How can I disable/enable input on specific keyboard buttons at runtime?
  19. Hi everyone, I'm having some weird issues with Safari on Mac : it seems like using the arrow keys in combination with A messes up the keyboard language. I have a french keyboard (azerty), and if I press A, no issue, A is triggered. If I press the right arrow + A, the A becomes a Q. Is that a known issue? Is anyone having the same issue? Is there something wrong with the way I handle the keys? Here is a JSFiddle to illustrate the issue (open the console to see the logs) : http://jsfiddle.net/PQVnT/1718/ Thanks a log guys!
  20. Hi, I'm currently learning Phaser, and i need to handle key events, so i saw some tutorials and if i want to move my character, i need to know if key is down so, in the "phaser" way, things are done like this: window.checkInputs = () => { let key = Phaser.Keyboard if ( game.input.keyboard.isDown(key.LEFT) ) { console.log('Left is down !') } } And i need to call this method in the update loop, so 60 times / s, phaser will check if left arrow is down, like i come from node.js, i don't like this, i mean it waste resources no ? So, is this methode better ? : window.addInput = () => { document.onkeydown = (e) => { if (e.code == 'ArrowLeft') { console.log('Left is down !') } } } Thanks !
  21. Hi Guys. I am new to HTML5 game development.I want to implement 4 buttons on screen(left, right,up and down), which controls the camera.has someone idea how to implement it?? @Dad72, @davrous, @Deltakosh
  22. Hello, I'm trying to call the keyboard on click (InputDown) event. Everything works fine in Android, but on iOS the keyboard doesn't show. I'm running the app through Cocoon Developer App using .zip file openKeyboard: function() { Cocoon.Dialog.showKeyboard({ type: Cocoon.Dialog.keyboardType.TEXT, }, { insertText: function(inserted) { console.log(inserted); }, deleteBackward: function() { console.log("deleteBackward"); }, done: function() { console.log("user clicked done key"); }, cancel: function() { console.log("user dismissed keyboard"); } }); } showKeyboard function is called because I've checked that using console logs, but actual keyboard is not appearing... Anyone encountered simillar problems? Or maybe you can recommend some other option to display keyboard in native app?
  23. I already found the solution for my problem. Please delete this topic.
  24. Is there a way to see the full list of keyboard buttons? For example Phaser.Keyboard.SPACEBAR, Phaser.Keyboard.ONE, Phaser.Keyboard.TWO etc... I cannot see these "constants" in the phaser 2.2.2 docs. For example I need dot, single quote, dash(minus), ~
  25. I have this code: var myKey = SI.gameObject.input.keyboard.addKey(SI.gameObject, 32); myKey.onDown.add(function () { console.log("space"); }, SI.gameObject); When pressing Space the browser scrolls down. I want to prevent this but still be able to detect when i pressed Space. Yes there is method game.input.keyboard.addKeyCapture() which does the job, but it also disables Space button completely i.e I don't detect when the button is pressed. Any ideas if this is possible in Phaser?
×
×
  • Create New...