Sub-tick events?

Not favoritedFavorited Favorited 0 favourites
  • 3 posts
From the Asset Store
Very simple code without excess options (15 events for server and 11 events for client)
  • I'm using the new MIDI plugin (that I requested on the GitHub page) to finally fix an abandoned project, and have gotten pretty far. However, I'm starting to have issues with other things. I have a background note (9-Patch) created on the piano key, and it sets the height to `note.height + 1` every 1/120 seconds until the note is released. I then have logic to make it stop resizing and enable the move to behavior with the speed set to 120 pixels per second, and 0 acceleration. However, I noticed a speed difference, and after further investigation, it all relates to the tick rate. In the Construct 3 Documentation:

    This means that it's actually resizing 60 times per second, not 120. This could easily be resolved by setting it to resize 2 pixels instead of 1 and making it longer intervals, but that would make it more choppy, and I'm still left with one question. How is the move to behavior able to move smoothly? Is there any way I can implement this sub-tick behavior portrayed in the height resizing?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can incorporate time delta (dt). Basically rate*time=distance.

    Your growth rate is 1 pixel per 1/120th of a second or 1/1/120 which is 120.

    That would basically look like this in events:

    midi: key is down
    — 9patch: set height to self.height+120*dt
  • This could easily be resolved by setting it to resize 2 pixels instead of 1 and making it longer intervals, but that would make it more choppy

    Your game or app should produce the same results regardless of the framerate. Some people will run it at 240 fps, others at 60 or maybe even 30. Then your "Every 1/120 seconds" condition won't work. If you want to resize the object properly with events, do it on every tick and make sure to use delta-time.

    I would suggest using the Tween behavior instead - it's a lot easier. You just set the target size and time and it will resize the object properly. One added bonus is that you can choose a nice easing effect.

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