How do I manage state?

0 favourites
  • 7 posts
From the Asset Store
State Machine
$10.99 USD
State Machine is a great tool for managing the state of anything in your game.
  • Hi guys,

    I want to make some kind of small RPG, in this RPG the battle happens automatically. So the player would run/walk and meet enemy, and they'd automatically fight.

    My game has several state, one of them is "inBattle" state. In that state there are a few phases, like: defineAttacker, calculateHit, calculateCritical, calculateDamage, and dealDamage. The problem I'm having is in the dealDamage phase.

    what I want to achive is character (player) and monster take turn attacking depending on who is attacking this turn (decided in defineAttacker). But it seems while the monster is in the process of attacking, the attacker changes to character. So the character attack before the monster even deal its attack.

    I think the problem is in the attacker variable, because the value change fastly when it is monster's turn. I know that is the problem but I don't know why that problem happens, because the attacker is decided in the defineAttacker phase.

    So I want to know, is there a good way to manage states (or phases), or there is a way specific for construct to manage it

    here's the file in dropbox: dropbox.com/s/t6i9qf725vcvglz/EXP%20project.capx

    thanks

  • ouch, no reply yet?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I usually group said phases into functions. And call them accordingly, in a 'queue'. Let me check your capx first though. And happy to know a fellow countryman here in C2 forums :D

  • Rough modification to functions: sdrv.ms/1258Rzu

  • owh, I need a newer version of construct to open the file. Turns out mine isn't up to date enough.

    I'll check it out later, but thanks

  • wait, there's a "function" in there? how come I never notice? must be a new feature

    anyway, thanks :D

  • Yeah, Function plugin was introduced somewhere in February. Forgot the version number. Scirra pushes new releases pretty often so it might be a good idea to sign up for their newsletter

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)