Shadow20 Posted January 14, 2014 Share Posted January 14, 2014 I am trying to create a bare-bones rpg battle system, I am trying to figure out a way to manage the turn system for each unit. I want it so that if the current turn of a unit, it will remain in that state until a target is selected and a button is pressed essentially. I thought about only rendering the buttons on screen when it is the players turn but i come up to the issue of how to detemrine whose turn it is and how to change that as needed. I thought about using an array of booleans to determine the current unit to do its action or maybe an int whose number correspond to different units but i am having some issues visualizing it in my mind. Could I get some advice or material to read on this matter to help clear this up? Thanks in advance. Link to comment Share on other sites More sharing options...
Heppell08 Posted January 14, 2014 Share Posted January 14, 2014 I usually find numbers useful for this kind of stuff. Like if a player clicks a button and a turn is taken then change from number 1 to number 2. So if number 2 is active then remove buttons and make the player wait. Afer the player has waited the turn the enemy takes the next turn and resets the number to 1 and the buttons etc are now available and ready to use again. This is how I approach this kind of stuff but there are other ways. Link to comment Share on other sites More sharing options...
XekeDeath Posted January 15, 2014 Share Posted January 15, 2014 Can you store all the units in an array, and then just store an index to the current unit...?When a turn is made, increment the index, when it reaches the end, reset to 0...Store the player in the first position in the array, and then index == 0, show the buttons... Link to comment Share on other sites More sharing options...
Shadow20 Posted January 15, 2014 Author Share Posted January 15, 2014 thanks for the quick response guys, i got it implemented using a number like you guys said and reset to 0 to start a new turn so to speak. Ran into a different issue now, I want the user to select their target and i am trying to get the Phaser.sprite on click event to work but i am having some issues. Here is the code:var e = this.G.add.sprite(200, 200, enemies[i].Sprite); e.inputEnabled = true; e.input.events.OnInputDown.add(this.StartAttack, this); the last line, events is not recognized as a property of sprite.input. I am not sure if this is an error in the typescript definitions or an issue with phaser itself as i dont see events in the docs for the Sprite class. Thanks Link to comment Share on other sites More sharing options...
XekeDeath Posted January 15, 2014 Share Posted January 15, 2014 That would be because it is not a property of input, it is a property of sprite.I make similar mistakes EVERY TIME I add input to a sprite. All available events are found here: http://gametest.mobi/phaser/docs/Events.js.html Link to comment Share on other sites More sharing options...
Shadow20 Posted January 15, 2014 Author Share Posted January 15, 2014 oh wow lol, i was just copy and pasting from one of the examples and overlooked it i guess O.o Thanks again! much appreciated. Link to comment Share on other sites More sharing options...
Recommended Posts