lionz's Forum Posts

  • Yep that looks fine, are you saying that it's working now or do you need some help?

  • I can't see an image but I guess what you need is to check If wallet money < product value * quantity.

  • No problem, glad it helped!

  • ignoring the bar, you need to set a current max energy for the player. lets called this 'energyMax'.

    When you say character with 5 energy, you mean he has 5 energy to start so that is 'energyMax'.

    the current energy is 'energy', and you set this to 'energyMax' at the start of the game and I imagine you decrease 'energy' by using it.

    so you start with 5/5 energy.

    we now calculate a percentage regardless of starting energy, whether its 5 you are slotting in or 1000.

    fill = energy/energymax* 100 = 5/5*100. what you have now is a percentage of fill for the bar.

    so if your guy now dropped to 3 energy. the fill of the bar would be energy/energymax*100 = 3/5*100 = 60%

    To answer your question, using the fill bar formula, the energy that the player starts with which is what I think you are trying to slot in is energyMax.

    This also auto-resolves the bar decrease speed because it is always a percentage. if you have 5 energy it will drop 20% of the bar a time, whereas if you have 1000 energy to start with and decrease by 1 you will see almost no change because it is going to 999, 998 etc which is a small percentage of the bar.

    The next step is how you want to apply that percentage outcome (fill var) to the bar width. You can just say object.width = fill which means its width would be between 0-100 just to test it out, then multiply this later if you need it larger. You could also use the built in object progress bar to test it out and set progress=fill.

    To summarise after you've read that and understood what I mean with the values, you just need 3 variables and a formula :

    energy - the current energy,

    energymax - the max energy allowed or total given at the start,

    fill - a variable to store the percentage,

    set var fill = energy/energymax*100

  • Do you have a purchase mechanic? How does it work currently? You said you saw the wallet go into negative value so that implies there is a purchase mechanic already and you tried something. In the general sense you are looking to use conditions, which are kind of like 'if statements' for construct. When you say in a condition 'player money greater than product price', it will only run the actions, a purchase in this case, if that is true.

  • This just seems very easy to do but we don't know how your game works. You would just check if the player money is greater than the product price before purchasing and if not then disable purchase. For the selling I would add product amount to the array (unless product is product amount and not product name) and then say if that value is 0 then you cannot sell.

  • You will most likely have conflicting events for animations such as when you jump and move left/right it tries to play other animations together. You will need to get into the habit of trying to limit which animations are playing with conditions. If you post a screenshot of the events or share capx then I can help.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hmm try 180 instead of -180, also where's the angle of motion action for the right facing bit at the bottom?

  • 'Each player has a different amount of energy' - that's the variable maxHP in my example

    calculate hp% = hp/maxHP*100

    So if hp is 5 and max is 10 then hp% = 50

    if hp is 5 and max is 100 then hp% = 5

    if hp is 10 and max is 10 then hp% = 100

    if hp is 2 and max is 2 then hp% = 100

    Set the bar width to hp% (it'll be from 0 to 100)

  • I will assume you have used simulate control for the jump also? Best way to resolve is to use 'platform on jumping' play jump animation.

  • You only update the high score text object if score is greater than high score. Maybe your score is less than high score which means the text object would not update. If your score is actually greater than high score then it's possible the game over layout isn't using the event sheet.

  • If you look in Construct you cannot set a local or global bool, there is only an instance variable bool which applies to a particular object. If you are trying to pass a general bool value through a function or return a true/false then there are other ways to do it. Using the bool in conditions or actions should be enough, if you are trying to do something specifically then post exactly what you are trying to do and I can assist.

  • Nice! Gary's got strong arms..

  • Hi, you can use another variable on the object to identify it as a player. For example, in events if object.char=1, set the rest of the variables to a,b,c etc. If object.char=2, set the rest of the variables to d,e,f etc. You can also then refer to specific character types elsewhere in conditions like this, where object.char=1 is always character type 1.

  • It's not clear why you find true/false options unsuitable for a bool, but yes you can say if a variable string = the literal string "true" or "false", or you can say if a variable int = 0 or 1.