vernonr Posted November 22, 2014 Share Posted November 22, 2014 Hi guys, I'm really new to Phaser and programing in general so I'm getting stuck really often with my first game. What I'm trying to do is some sort of a two players fighting game (this is a game for gamepads and keyboards, no mobile here). I kinda have the basics going, I mean, my characters move! But i have a list of things to do that keeps growing! Here I have my first two problems for you, kind people: Problem number 1: The thing I'm trying to do is to have my character perform a special move with a combination of buttons. I'm guessing there should be a timer involved somehow. The idea is that if you press button 1 and quickly press button 2 and 3, a special move will happen (a set of frames of my animation sheet) but if you don't press them fast enough, then you will have the animations for each instead (button 1 is used for punching, button 2 is used for kicking and button 3 for blocking). Problem number 2: How can the punch o the kick hit player 2? I have the two sprits on screen, each of them are moving but they don't hit each other. I would need to have some sort of lifemeter or something, one for each player, and a value for punching, kicking and any other special move, which will affect the lifemeter of the player being hit. Many thanks in advance! I love this Phaser engine and the community in this forum. I'm really excited with this game Link to comment Share on other sites More sharing options...
eguneys Posted November 23, 2014 Share Posted November 23, 2014 Great idea, I suggest search "fight" in http://www.reddit.com/r/gamedev, for useful resources. Here's some: http://www.reddit.com/r/gamedev/comments/1yu4px/how_to_properly_handle_tons_of_inputs_in_a/http://www.reddit.com/r/gamedev/comments/168ue0/2d_sprite_fighting_engine/ Let us know how it goes. Link to comment Share on other sites More sharing options...
vernonr Posted November 23, 2014 Author Share Posted November 23, 2014 Many thanks! I'm looking but there's nothing phaser oriented. I know that to many of you it would be easy to translate an idea from one code to another but for me is very difficult. I'll keep looking but if someone around here could give me a hint as from where to begin the resolution of these issues, that would be the greatest Link to comment Share on other sites More sharing options...
vernonr Posted November 23, 2014 Author Share Posted November 23, 2014 Ok, so I was checking the forum and I found this idea about how to get a double tap action. Think that I could use it with a combination of keys for what I need to do. Here's the idea: You could do 2 things:1. Always have a short delay on keyup.e.g.keyup-> check if timer active,if yes -> cancel timer and emit charge forward,if no -> timer = setTimeout(normaltap, 100); <- or whatever delay 2. check last tap time keyup-> check if difference between time and last time you pressed the key is less than 100 ms (or whatever delay you prefer)if yes, set the time to 0 and emit charge forward (0 so that the next keyup wont trigger another double tap if you mash the key too fast)if no, emit normaltap and save the current time for this key The thing is that I don't know how to do this. Any ideas? Thanks! Link to comment Share on other sites More sharing options...
eguneys Posted November 24, 2014 Share Posted November 24, 2014 I've implemented double tap functionality in my game, see the code here lose-your-marbles. i suggest you also check out how to use it in game in the same repo. There is also a library that handles user gestures http://hammerjs.github.io/, it is an overkill though, just for tapping. Link to comment Share on other sites More sharing options...
vernonr Posted November 27, 2014 Author Share Posted November 27, 2014 Thanks a lot! Your code has been really helpful but I finally ended up using a JS library called mousetrap. It allows combinations of keys to be used. It works for now so I'll think I'll stick in my code. I still have to solve my problem number two, though Link to comment Share on other sites More sharing options...
SoulBeaver Posted November 27, 2014 Share Posted November 27, 2014 I know this is from the now more-or-less defunct XNA framework, but luckily code doesn't stagnate. If you have some C# chops, why not try reading the source code for their sample "Input Sequence" which is a demonstration of doing just what you asked. It shouldn't be too hard to port their example to Phaser, I believe. http://xbox.create.msdn.com/en-US/education/catalog/sample/input_sequence_sample Link to comment Share on other sites More sharing options...
vernonr Posted November 27, 2014 Author Share Posted November 27, 2014 Thanks man! I'll give it a try Link to comment Share on other sites More sharing options...
lewster32 Posted November 28, 2014 Share Posted November 28, 2014 Something recently caught my eye which may help a lot here: https://github.com/mightyiam/combokeys Link to comment Share on other sites More sharing options...
NumberOneRobot Posted February 4, 2015 Share Posted February 4, 2015 I'm trying to make a fighting game using Phaser as well! Have you worked at all on how to create different hitboxes for each frame? I'm not sure if I should create a different collision group for each frame and then cycle through the collision groups as I cycle through animation frames, or if I should be doing something else entirely. Link to comment Share on other sites More sharing options...
eguneys Posted February 4, 2015 Share Posted February 4, 2015 @NumberOneRobot, I don't have any experience, but I thought you don't need different hitboxes for every frame, but for different states like "sitting", "standing", "jumping", "kicking". You can toggle these states as the player animates to them. Later you can grow/shrink certain boxes, as you transition between states. Link to comment Share on other sites More sharing options...
Recommended Posts