Tácio Sousa Posted October 1, 2013 Share Posted October 1, 2013 Hi people, i'm here again with new questions. I started a Space Invaders project with Phaser, and I set the ship (player) for move when one sprite (with inputEnabled = true) dispatch his input event (button.events.onInputDown.add(move, this)). The player moves normal, but if you click the button and continues holding him OUT of the button, the player will continue moving forever, until you click one more time in same button to call the onInputUp function. I can use the game.input.onUp to fix the release of button, but here comes the question : How i do for game.input.onDown return a Sprite if there's one clicked? I need something like "return the sprite at inputX and Y" on update function, for substitute the button events for game.input.onDown and make the buttons work like any other game. If a cannot resolve this, the player will always have to click and release all buttons for move instead hold the finger and only move towards the right button, as we make in any virtual D-Pad. Link to comment Share on other sites More sharing options...
RestingCoder Posted October 1, 2013 Share Posted October 1, 2013 I'm not at my computer right now, but would onHold do what you are trying to do? (Not sure if there is a delay of any kind compared to onDown, as I haven't used it myself.) Link to comment Share on other sites More sharing options...
rich Posted October 1, 2013 Share Posted October 1, 2013 Are you trying to make a virtual d-pad? and using a Button object? Link to comment Share on other sites More sharing options...
Tácio Sousa Posted October 2, 2013 Author Share Posted October 2, 2013 I've try use the onHold too RestingCoder, but he don't work. The onHold delay something like 3-4 seconds to activate. Yes Rich, take a look here and you will understand. "Button object" is a sprite with inputEnabled true, only this. Link to comment Share on other sites More sharing options...
Tácio Sousa Posted October 3, 2013 Author Share Posted October 3, 2013 Anyone can help...? Link to comment Share on other sites More sharing options...
rich Posted October 3, 2013 Share Posted October 3, 2013 You don't want to use a Signal for a d-pad, for that you need to poll the input state every frame, not just when it first changes, so I would use sprite.input.pointerDown(), pointerUp(), pointerOver(), etc. on each part of the d-pad. Link to comment Share on other sites More sharing options...
Tácio Sousa Posted October 3, 2013 Author Share Posted October 3, 2013 I make as you said Rich, I change the sprite.input.onDown for game.input.onDown and put the sprite.input.pointerOver() verification in each sprite, and now it works perfectly, but only in browser and without Enable touch events. I upload the index for test, and run inside one iPad 4 (iOs 7.0.2) and other iPad 2 (iOs 6.1.3, here I have another problem, in this iPad the sprite colors have changed to something like "more clean", like 0x0000FF to 0x0000DD) and both iPads don't recognize the Phaser pointerOver method, so the player cannot move or shot. Here's the example. You can see the code if you want. I don't know if i have to use or enabled any other thing to touch mobile works... Link to comment Share on other sites More sharing options...
rich Posted October 3, 2013 Share Posted October 3, 2013 buttonUp.input.pointerOver()If you don't give it a pointer ID it will default to zero, which is probably not the ID of the finger that was pressed onto the canvas. Basically each finger has a unique ID, for example the finger using the d-pad might be ID1 while the finger on the fire button might be ID2 - basically you need to capture the ID when its pressed down on the d-pad and then use that in the pointerOver checks. I know it seems a bit strange, but it's actually quite flexible as it allows for multiple presses on a single Sprite. Link to comment Share on other sites More sharing options...
Tácio Sousa Posted October 3, 2013 Author Share Posted October 3, 2013 Right, but I have 2 questions here : 1 - How I do to give this pointer IDs to the sprites? And what's the pointer of all fingers? 2 - If I put another "capture" style function, i'll have the same problem that I have before (keep pressing down the button as I said). Can you give me a light for this problem? Sorry for boring you so many times Rich, i'm really noob in JS development and more in Phaser. Link to comment Share on other sites More sharing options...
Tácio Sousa Posted October 7, 2013 Author Share Posted October 7, 2013 I still have this problem, if anyone more can help I'll be very very grateful. Link to comment Share on other sites More sharing options...
rich Posted October 7, 2013 Share Posted October 7, 2013 I know, am preparing an example for you (no ETA yet, sorry, but it will be part of the 1.0.7 update) RestingCoder 1 Link to comment Share on other sites More sharing options...
Tácio Sousa Posted October 7, 2013 Author Share Posted October 7, 2013 Ok ok, one more time thanks to you Rich, I'll wait for 1.0.7 update . Link to comment Share on other sites More sharing options...
gabehollombe Posted October 25, 2013 Share Posted October 25, 2013 I know, am preparing an example for you (no ETA yet, sorry, but it will be part of the 1.0.7 update) I've got a working tech demo integrating Austin Hallock's HTML5 virtual game controller (https://github.com/austinhallock/html5-virtual-game-controller) with Phaser 1.1 (dev branch). It's currently written in coffeescript, but would you folks like me to share this here? I'm planning to use it as part of a tutorial I'm putting together, but it may become irrelevant if you're introducing some other sort of virtual dpad support in Phaser.next... Link to comment Share on other sites More sharing options...
rich Posted October 25, 2013 Share Posted October 25, 2013 I would love to see it, regardless what you wrote it in Link to comment Share on other sites More sharing options...
gabehollombe Posted October 27, 2013 Share Posted October 27, 2013 Thanks, Rich. Here's a new example (via pull request) showing how to integrate a virtual joystick into Phaser. https://github.com/photonstorm/phaser/pull/134 Link to comment Share on other sites More sharing options...
Tácio Sousa Posted October 28, 2013 Author Share Posted October 28, 2013 Hi guys, i'm here again. I've try one more time with sprite.pointerOver problem, and still have the same result. I put "buttonUp".input.pointerOver.id = 1,2,3 and always get the same result, running in browser but no in iPad. (The default ID is 1) This is the right way to set ID pointer?Here's the url and the source : Site Sorry for borring all this time along, i'm really VERY noob in JS development, much more in Phaser. =/ Link to comment Share on other sites More sharing options...
Tácio Sousa Posted November 5, 2013 Author Share Posted November 5, 2013 There's no examples about finger ID's? =/ Link to comment Share on other sites More sharing options...
Recommended Posts