dop2000's Recent Forum Activity

  • When P1 sprite is mirrored, its width is a negative value. So (P1.X-(P1.Width/2)) really becomes (P1.X+(P1.ImageWidth/2))

    Instead, use BBoxLeft and BBoxRight expressions.

    Level.TileAt(Level.PositionToTileX(P1.BBoxLeft-edgeDistTolerance),Level.PositionToTileY(P1.Y-10))

  • Maybe the value is stored as string in the array? You can test this by printing Stats.AsJSON to console log. If the value is shown as "1.3", then it's a string.

  • Is there a way to have the health bar show the proper status before the function call five second command?

    Yes, you can call the function on start of the layout with amount=0. It will not change the variable, but will update the health bar and everything else. Or you can simply update the health bar on start of layout:

    -> Sprite_Health: Set animation frame to int(HungryScore)

  • Don't rely on the health bar, it can show 0 when the value is really 0.95

    Run the game in Debug Mode (Shift+F4 or Shift+F5) and check the variable value there.

  • It's not a bug, this is how strings are concatenated. Add round brackets:

    ... & "/" & (25*Stats.at(Hardness,1))

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • "Event eat" sheet belongs to Eat layout, so events from it will only work in Eat layout. If you want these events to be available in other layouts, you need to include "Event eat" sheet there - right-click -> Include event sheet.

    This is not required if you only want to call the function from other layouts.

    .

    When I run Eat layout directly, I can see in the debugger how HungryScore decreases by -0.05 every 5 seconds.

    .

    Also, events 10-15 are not needed. You already have "Sprite_Health: Set animation frame to int(HungryScore)" action which updates the health bar.

    Events 16-26 need to be inside the function.

  • I ran the code you gave as an example it deducts .5 and shows on the health bar but then stops subtracting and stays there.

    It should stop once the variable reaches 0. If you want to allow negative values, then remove the "Set HungryScore to clamp()" action.

    Also, you probably still have lots of other events in the project that can change the value of HungryScore variable and mess with your test.

  • Press P to add a function parameter. Or right-click

  • Also, do not use 'wait 4 seconds' before loading AJAX data, as the contents of AJAX.lastData may have changed by the time the wait ends. (if you make several AJAX calls)

  • or trying to add a new instance variable to the food family? I tried that but then when I go to add it as an action it won't appear as an option.

    Yes, these should be instance variables defined on the family. They will be accessible on the family itself and on all its members. Say, you can use Food.burpAmount, or you can use Food_Cookie.burpAmount

  • Create a function, call it only when HungryScore is changed, and put all checks inside the function. This way they will not run on every tick! And you will have a single event where all changes to the HungryScore are handled, not a hundred of events all over the project, which will make debugging a lot easier.

    This is just an example of what it may look like, don't copy it to your project:

  • This is what I'm trying to explain to you - when an event runs on every tick (the one highlighted on your screenshot), all its actions are repeated 60 or more times per second! That's why your animation is constantly restarted.

    And never use "wait" action in such events! Because all actions after the "wait" will continue repeating many-many times even after the event is no longer running, resetting the variable.

dop2000's avatar

dop2000

Member since 26 May, 2016

Twitter
dop2000 has 260 followers

Connect with dop2000

Trophy Case

  • 8-Year Club
  • Entrepreneur Sold something in the asset store
  • Jupiter Mission Supports Gordon's mission to Jupiter
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • Forum Hero Made 1,000 posts in the forums
  • Forum Wizard Made 5,000 posts in the forums
  • Forum Unicorn Made 10,000 posts in the forums
  • x5
    Popular Game One of your games has over 1,000 players
  • x2
    Coach One of your tutorials has over 1,000 readers
  • Educator One of your tutorials has over 10,000 readers
  • Regular Visitor Visited Construct.net 7 days in a row
  • Steady Visitor Visited Construct.net 30 days in a row
  • Enduring Visitor Visited Construct.net 90 days in a row
  • Unrelenting Visitor Visited Construct.net 180 days in a row
  • Continuous Visitor Visited Construct.net 365 days in a row
  • RTFM Read the fabulous manual
  • x3
    Quick Draw First 5 people to up-vote a new Construct 3 release
  • x13
    Great Comment One of your comments gets 3 upvotes
  • Delicious Comment One of your comments gets 10 upvotes
  • Email Verified

Progress

28/44
How to earn trophies