Search the Community

Showing results for tags 'input'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Coding and Game Design
  • Frameworks
    • Phaser
    • Pixi.js
    • Babylon.js
    • Panda.js
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Found 160 results

  1. [Plugin] phaser-input

    Hey all, Just wanted to let you know that I created a phaser text input plugin. Should work like a normal input text box, and unlike CanvasInput it also works in WebGL renderer. It's also tested on iOS9 and mobile Chrome. There are some limitations right now for using it, but the basic concept works. Head on to github to check it out :)
  2. Input not reactivating on mobile

    Hello GameDevs, I am doing a turn-based board game as a college project for both desktop and mobile browsers using PhaserJS framework. However I have ran into a problem regarding the input on mobile. Here's a part of my code: function move (sprite){ //disabling input so the user can't interrupt the moving sprite game.input.enabled = false; //move the selected sprite to a blue tile game.physics.arcade.moveToObject(spriteSelecionado,sprite,60,600); //function to stop the sprite from moving permanently game.time.events.add(600, function () { //stops the sprite spriteSelecionado.body.velocity.x = 0; spriteSelecionado.body.velocity.y = 0; //clean the tiles used for moving the sprite movimentacao.callAll('kill'); /*This is where the problem resides. While on desktop browers it works just fine, the line above doesn't re-enable the input on mobile after a couple times it is used */ game.input.enabled = true; }, this); } I am currently disabling all the input while the moving sprite hasn't reached its destination so the player doesn't end up clicking midway on it and screwing up the game animations. After the turn ends, I reactivate the input so game continues. The problem is that this just works twice on mobile, If I try to move the game sprites twice all my Input stops responding. (if I click on the console whi
  3. Hello, everyone. I am using Phaser 2.8.3 Basically I want to add a sprite to two groups. In my game I want three columns so I have three column groups. this.leftColumn = game.add.group(); this.middleColumn = game.add.group(); this.rightColumn = game.add.group(); Later I add buttons into these groups this.spawnRateButton = []; this.spawnRateButton.push(this.leftColumn.create(0,0,"custom-left-button")); this.spawnRateButton.push(this.middleColumn.create(0,0,"custom-middle-button")); this.spawnRateButton.push(this.rightColumn.create(0,0,"custom-right-button")); for(var i=0;i<3;i++){ this.spawnRateButton[i].inputEnabled = true; this.spawnRateButton[i].events.onInputDown.add(this.buttonPress,this); } However here comes my problem. I want these columns to be scrollable, so I have to utilize this https://github.com/trueicecold/phaser-scrollable . this.scroller = game.add.existing(new ScrollableArea(x, y, width, height, {horizontalScroll: false})); //... this.scroller.addChild(this.leftColumn); this.scroller.addChild(this.middleColumn); this.scroller.addChild(this.rightColumn); this.scroller.start(); The scrolling works, however, the events.onInputDown of the spawnRateButtons do not. I click the buttons and nothing happens. When I take away the scroller everything works fine except for the scrolling, of course. When I add the sprites individually to the scroller it doesn't work either. I am guessing this is because I am trying to add the sprites to two groups? Is there a correct way to do this?
  4. Hi! My default interface requires at least 2 touch pointers, but I could provide a slightly more awkward alternative with only 1 touch point requirement if I detect that the device does not support simultaneous touches. Two questions: 1) Can it be done with Phaser (or JavaScript in general)? 2) Is it necessary anyway? I personally don't even know any devices with only 1 touch point, but I guess the templates that come with Phaser have .maxPointers = 1 for a reason. Are there many devices with only 1 touch point? Thanks for help. To clarify, my interface would be as follow: - touch left side of the screen to move left, - touch right side of the screen to move right, - you can't move left and right at once, but I want the 2nd touch (for example, right) to be detected even if the user is still touching left - this way I think it's slightly more responsive.
  5. Hey, Everyone I'm dying making attempts to scale canvas for high dpi mobiles and get everything work correctly. Problem: When I start Phaser with 100% width/height for canvas it will be created according to css pixel size of device (window.innerWidth/innerHeight). So iPhone 6S for example, gets, 375x667 canvas, but in fact, of course it should be 2x bigger because devicePixelRatio is 2. Result, everything is blurry and not as expected. Ok, I decided to set width and height with devicePixelRatio included and then set CSS size of canvas to 100% of view port. let w = window.innerWidth * window.devicePixelRatio; let h = window.innerHeight * window.devicePixelRatio; let game = new Game(w, h) // And then in style sheet: canvas { width: 100vw !important; height: 100vh !important; } Now, it seems like everything looks perfect and as expected (is it correct way to do it?). But, another problem rises. Seems like after this events.onInputDown do not work correctly. When I click on sprite nothing happens, but in different location click handled. Seems like coordinates of input arena is messed up. Can someone help me this this?
  6. Keyboard input + Microsoft Edge

    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?
  7. Phaser and gyro

    Hi, Does phaser play nicely with gyro.js? Does it have a built in gyro support for ios input? I could not find anything in the documentation or example. Thanks!
  8. 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; } }
  9. Input Forms in pixi

    Hello everyone, first of all I am almost completly new to the whole javascript world, especially pixi.js. But due to I am planning to get a graphic intense project done, I try to figure out wheater pixi is the right choice. I will have a lot of user interaction, where I want to store certain input in my database. There will be a php backend handling ajax request and answering with json. I am looking for convenient ways to get user input. Is there any option to create input fields directly in pixi? I saw another approach where inputs are handled in modals, and therefore are "independent" from pixi. e.g. https://de2.big-bait.com/ What is the most common approach to get various data from the pixi frontend to my php backend? Best Regards Queue
  10. Hi guys, I'm having a hard time figuring out how to move a given object to the destination of a clicked mesh. Playground link (similar recreated scenario): http://www.babylonjs-playground.com/#2CFAMI#13 As you can see, the first two actions (hovering mouse in/out effect) work fine with every tile, but the animating action seems to always extract the position of the last added tile. I'm suspecting it's because I'm overwriting the tile variable (and thus its position values) or something. I also suspect that using instances for the tiles might be a better option, since in the game they also just use 5 different materials that are loaded before-hand...but first things first. Thanks in advance for taking a look!
  11. Multiple Clicks

    Hello. I'm new here and finally found a reason to post. I'm also new to this kind of development. To the point: I am creating a transition using Tween and a container. My issue is when the play/user clicks on the hit box to start the animation/tween it doesn't account for multiple clicks which then plays the animation again. How do I not allow the function to execute when is it already running? I'm developing with CreateJS in case that matters. Thanks in advance.
  12. 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?
  13. Howdy, In my game I lock the cursor to canvas, so I use a pointer lock and then track/draw a "virtual cursor" manually. However, this causes sprite click callbacks to no longer trigger: sprite.inputEnabled = true; sprite.events.onInputUp.add(this.OnSpriteClick, this); Is there any way to get it working ? As a workaround, I figured I can manually check but I am having a hard time since figuring it out. sprite.getBounds() returns local bounds - how do I translate the my cursor position to sprite's local space? I couldn't find a matrix member under Sprite definition in the docs... Any
  14. CSS and Phaser input problem.

    Hey guys, I have made some scaling of the game via CSS so I can have my game always the proper size in the browser window. However, I lose my onInputDown because for some reason the game container overflows but visually is okay.... here is my CSS styling (visually it looks perfect): html { height: 100%; margin: 0; padding: 0; } body { height: 100%; margin: 0; padding: 0; } #content { height: 100%; } #content > canvas { margin: 0 auto; height: auto !important; width: auto !important; max-height: 100%; max-width: 100%; position: relative; top: 50%; transform: translateY(-50%); } Here is my game init class: import Boot from 'states/Boot'; import Preload from 'states/Preload'; import GameState from 'states/GameState'; import * as Constants from 'data/Constants.js' class Game extends Phaser.Game { constructor() { let height = window.screen.height; let width = window.screen.height / Constants.SIXTEEN_TO_NINE; super(width, height, Phaser.AUTO, 'content', null); this.state.add('Boot', Boot, false); this.state.add('Boot', Preload, false); this.state.add('GameState', GameState, false); this.state.start('Boot'); }; } new Game(); If I don't have any css code - the input works. I believe it is because the game is still bigger than what it visually appears. Has anyone had this issue?
  15. Hi! I'm currently implementing some actions via the ActionManager class in my project. I want to control a sprite with the keypad, and so I'm mixing the actual sprite animation (player.playAnimation) with a position animation where the sprite is moving a certain distance (custom animation with easing via scene.beginAnimation). Problem is, I'd like to have successive inputs blocked until the movement animation has finished so that the functions don't get called again during that time. Is that somehow possible ? Thanks in advance!
  16. I bought Construct 2 to see how good i am in drag-and-drop game development. It's not that i sucked, but with a programmer background i hate it. So i tried out Phaser and loved it from the beginning. But now after working for 5 days on my game i had to find out that there is no microphone input for phaser. Am i correct? I need it to work on my mobile device. At the moment i thought that i build the game via phoengap, but how do i activate a microphone input? Anyone of you had any chance in making this possible? Greetings from this croner of the planet and thanks for your time.
  17. Finding mouse position in world

    How can I find the pointer's x/y coordinates in the world? Can I convert between camera and world coordinates?
  18. Hello, I am working on a game using tilemap and phaser framework. I want select the multiple coordinates on tilemap using phaser (cursor) and then can be able to store into an array. Is this possible using phaser? suggest me some solution for this.
  19. I have pixijs webgl app with some inputs. I have an input which uses native html input which placed out of scene and dispatches some events to my input and so on (like old pixi.input project) Yesterday I've update pixijs from 4.3.5 to 4.4.1, and input has broken. When hidden input is focused and I've move mouse (like usual text selection) native unfocus event has been emmited on my hidden input without stack trace (by browser as I think). Keydown events also doesn't work on hidden input (maybe it previously unfocused by mouse up or mouseclick event after it has been focused). Pixi 4.4.1 Chrome - bug Mobile chrome - bug Mozilla - ok Desktop Chrome with mobile emulation - looks OK, but didn't test it enough Downgrade to Pixi 4.3.5 - all browsers works OK
  20. I have some sprites that are set to horizontal drag only. What I want to do is, if someone drags vertically up from one of those sprites, when they leave the bounds of that sprite (top edge), spawn a new sprite and be actively dragging that new sprite. The user should not have to release the mouse button, they should just instantly be dragging the new sprite. I can successfully calculate when the pointer is leaving the first sprite, and spawn a new sprite at that location, but I can't seem to transfer the drag control. I tried Pointer.swapTarget, but that doesn't seem to work - the new sprite is spawned, but just sits there and I have to release the mouse button and re-click on the new sprite in order to drag it. How can I make the transfer seamless?
  21. I'm writing an FPS (Asteroids in 3D) and need to change the input mapping and some of the behaviour of the camera (currently Universal Camera). 1. rotate left and right (about the y-axis) instead of move - it does this for the mouse, but not keys 2. when rotating tilt into the direction of roatation - to emphasise the motion and give a "swooping" feel 3. control key sensitivity Are these behaviours / properties directly configurable? Or do I need to subclass a new camera type, or develop a different input control mechanism?
  22. 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 !
  23. Gamepad Disconnection Problems

    My Phaser.js version: `v2.6.2 "Kore Springs"` Gamepad: generic Logitech Dual Action controller OS: OSX Sierra Browser: Chrome Update: I can confirm that this also occurs with an XBOX 360 controller. Also see @Cyclone112's comments below for more troubleshooting info. I'm adding gamepad support to my current project, and am encountering the following error when disconnecting the gamepad from the USB input: Uncaught TypeError: Cannot read property 'timestamp' of undefined at c.SinglePad.pollStatus (phaser.js:43607) at c.Gamepad.update (phaser.js:43003) at c.Gamepad.reset (phaser.js:43169) at c.Input.reset (phaser.js:37282) at c.Game.gameResumed (phaser.js:36532) at c.Stage.visibilityChange (phaser.js:31966) at HTMLDocument._onChange (phaser.js:31905) This happens regardless of whether or not I register `onDisconnectCallback` to the gamepad. May also be worth mentioning that I encounter the error when disconnecting from this example: https://phaser.io/examples/v2/input/gamepad-buttons If the Github issue tracker would be a more appropriate place for this, I can post there instead. Any recommendations for a workaround would be great. Thanks!
  24. Input events propagation

    I have a very trivial nested-sprites situation, similar to this: function create() { var sprite = game.add.sprite(0, 0, 'phaser'); sprite.width = 100; sprite.width = 100; sprite.inputEnabled = true; sprite.events.onInputDown.add(function(){console.log("parent clicked")}); var child = game.make.sprite(0, 0, 'phaser'); child.width = 10; child.width = 10; sprite.addChild(child); child.inputEnabled = true; child.events.onInputDown.add(function(){console.log("child clicked")}); //child.input.priorityID = 1; } http://phaser.io/sandbox/edit/pfAcVgtC The problem is that by default the parent catches the click event and does not propagate it to the child. How do I make both child and parent catch the click event?