rbailey83's Forum Posts

  • I am using lerp for the health bar so that when the player upgrades their health, the amt of health can increase but the health bar width will stay the same. What happens though is that when the player gets damaged the health bar width is increasing instead of decreasing. Here is some screenshots of what I have setup for the lerp, using maxHealth for the global variable that will change with the upgrades and inst_maxHealth for the instance variable to transfer the value to and have another instance variable inst_health that is set to the health bar width.

  • Check that you player's health and fullHealth are the same at the start of the game.

    Actually, you don't even need lerp (I like it so much I use it everywhere ), this formula is easier:

    bar.width=110 * (player.health/player.fullHealth)

    dop2000 yep that did it, the health was initially set to the 110 but for some reason it got reset to 0. Put it back to 110 and it worked like a charm.

    haha I like the lerp so I think I'll keep it in there and get used to using it. Thank you so much for the help, you've been awesome

  • Ok so the section on the lerp kinda made sense to me, that makes things really easy lol.

    One thing though the health bar width at start of game is just a little bit shorter than the width of the 110, or at least what it shows at 110 in the editor. I double checked the width of the health bar and it is 110

  • You can use lerp function.

    Healthbar -> Set width to Lerp(0, 110, (player.currentHealth/player.maxHealth))

    So, for example if player.maxHealth=130 and currentHealth=65, then the healthbar.width will be set to 55px

    dop2000 Ok cool thank you. I am not familiar with Lerp so I will look that up in the manual and do a little reading on that. Appreciate the help

  • So using a health bar in a game and have it setup for the health bar set width to player instance health variable.

    the health value is set to the same width of the health bar width.

    What I am wanting to do in the game is allow the player to upgrade health to give them more health. How do I do this yet keep the health bar the same width?

    So the width is 110 and the health value is 110, if player does the upgrade and say adds 20 health the health value changes to 120 but I need the health bar width to stay at 110

  • tarek2 I hadn't even noticed that, I had just quickly taken a look and ran the project to see the outcome, hadn't tried implementing it or studying it yet so you beat me to that. I did update it in the sample project that you gave me. Thanks for that!

    Def a good thing to take a break for a while and when come back to the project just quickly check things over again with a fresh mind.

  • zenox98 oh sorry, yes using chrome. I didn't think about a browser problem since the only time it happens is running the construct 2 project so that thought didn't even enter my mind. Just another reminder not to assume things lol. Thank you

  • tarek2 I apologize for not responding sooner, I haven't been feeling well the last few days. The events 20 and 21 I didn't actually have them in at the same time when I was testing, I just put them in for the screen shot to show the two ways that I had tried to do the < 0 health event is all.

    Ok i think I get what you mean, I created a new event for the fight that was outside the event where the tile that called the detection and spawned the enemy, so it is no longer dealing with the reference point for the tile id that actually spawned the object.

    I feel like an idiot, that is so obvious now after looking at the example project you posted. And thank you for that by the way. If i could recommend you for some kind of forum award for being helpful I would definitely be doing that.

  • so when i run a project to test it the project comes up fine in one tab but it also opens a second tab with this page:

    this just recently started, why is is doing that and how do i get it to stop?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • tarek2 Hope you don't mind another question. I don't need the full solution I just want to know if I am barking up the right tree or if I need to switch my solution method.

    So I have setup the function and animations and all that jazz, When the enemy appears the player needs to be able to tap and interact with it and I could not get it to allow me to do that as an animation so I had that family tile spawn a new object with the enemy and then set the family tile animation to empty so that it wouldn't duplicate the enemy with the animation enemy.

    I then setup for the tap fight, and on enemy killed destroyed the enemy. In order to get the tiles to turn back to the default (tappable) tiles i set the instance variables back, both active and animated, to false after enemy destroy, and set the family tile animation back to default. I also tried just calling the function again after enemy destroyed. But that then also puts the tile back up on the one where the enemy had appeared and player defeated instead of staying empty.

    Here's an image of the code and link in case image doesn't show, Just want to know if I am heading in the right direction with destroying the object and resetting the animation no need to give the solution, i usually figure stuff out by trial and error i just don't want to spend hours on it if I am not even going in the right direction.

    I highlighted the area for on enemy death i didn't run it with both enemy death events i just did one at a time but included both for easier screenshot, but included full code in case you needed to see what i've done.

  • tarek2 Great! thanks for the extra breakdown of the event sheet, helps to simplify it a bit more. Was understanding most of what was going on, took me a minute to catch on to the family part lol.

    This has been great and thanks so much for not only being informative and helpful but even making the example project for me! Much appreciated!

  • nevermind, i created a new project and looked from that and the function is showing, just wasn't showing for me when i tried looking for it in the example project you sent me

  • Yeah that's right the Detector is the one checking for the neighbor's tiles of the enemy tile when is spawn but only checks overlap if the enemy was spawn, I used the function because is a Trigger so it checks the overlap once and also the Function are really good because you can pass the UID of the objects so you can do more extra staff to that particular object later on by just picking that UID

    You should definitely learn how to use the Functions if you can as has many benefits, they are very easy to learn and once you learned you will see is not much complicated and very useful

    The Function is an official plugin from c2, you can add the Function Plugin by going to the Right side panel and right click on the folder that says "Object Types" then choose insert new objects and then choose "Function"

    You can read more about it here

    https://www.scirra.com/manual/149/function

    tarek2 Awesome thanks again! I have an understanding of functions from my baseline knowledge of programming language and how useful they can be. The function option is not listed for me though when i right click object types and choose insert new objects. it's up to date and a personal license

  • tarek2 yep that's exactly what i was trying to do thank you so much, So it's the detector that gets called in at enemy spawn, and whatever tiles the detector is overlapping it locks out is that right? How do you do the functions? I haven't seen that ability or is that from a plugin?

  • The player taps a tile and either enemy, loot, or nothing spawns. What i want to happen is that if an enemy spawns then the tiles surrounding the enemy would change to a different object, which i can do fine, but then would not be able to be tapped until the enemy is defeated.

    I imagine that once i switch the tile out with another object that there is no touch command for that would take care of the player not being able to tap the tiles around the enemy but how do i set it up with the events to basically say if enemy spawns then surrounding tiles within 1 tile distance of enemy in all directions are untapable? or in all directions switch to this object?

    Lol i hope that what i am saying is making sense.