I am trying to manage power-ups in my game.
In my game, I want to create a power-up randomly with 'platform' and one max of one platform (this is a vertical scrolling 'game' type).
So, I have 5 different power-ups and I can do something like this (where PowerUp is a valid class) - '7' given in constructor has the number of sprites in different objects (I.e. they are batches of sprites) - 7 so we can place a space on each platform and can turn them on and off as needed (I have a 'driable' boolean array which I would like to do for individual sprites in a batch Allows to).
PowerUP powerUp1 = new powerup (7); Powerup power up 2 = new powerup (7); Powerup PowerUPS = new powerups (7); Powerup Powerup 4 = New Powerup (7); Powerup Powerup 5 = New Powerup (7);
After that I simply add them to the list of items to be dragged:
powerUpsList.add (powerUp1); // etc ...
Then I can do something like this:
(int i = 0; i The only issue with me is that I am more about making 35 tabs (5 of 7 batches) effective - when I add more powerups. I only < powerUp = new powerup (7);
Then, when I was creating a powerup, After getting it randomly - (for example, for example, PowerUp 1, for example), instead of the people concerned within the relevant batch, I am changing the specific properties of the batch inside the batch. So if the spawn time platform The number is 7, so I'm setting the frame for the 7th phantom in the batch and then i have to run the code to ant.
However, before running the relevant logic I switched the objects on myself F is required to use a switch statement.
Switch (PowerUpType) {case PowerUpType.powerup1: {logicForPowerUp1; Break} Case PowerUpType.powerup2: {logicForPowerUp2; Break} // etc} Is there any way I can run cleaning based on logic? Enum of the object using this batch of 7 sprites? I do not seem to find a way to do this, and using the switch, honestly, I feel dirty.
You can do some porting with enum, assuming that the methods in the logicForPowerUp1 / logicForPowerUp2 class In which the switch statement is
public class PowerUpUser {Private PowerUpType powerUpType; Public PowerUpUser (PowerUpType powerUpType) {this.powerUpType = powerUpType; } Public Zero Experiment PowerUp () {// This switch takes place in the statement PowerUpType.execute (this); } Private Zero logicForPowerUp1 () {} Private Zero logicForPowerUp2 () {} Private enum PowerUpType {PowerUp1 {@Override Public Nero executed (PowerUpUser powerUpUser) {powerUpUser.logicForPowerUp1 (); }}, Power Up 2 {@ Override Public Execution (Power Up User Power User) {powerUpUser.logicForPowerUp2 (); }}; Public abstract zero executed (PowerUpUser powerUpUser); }}
No comments:
Post a Comment