How do I execute an event once, but the contents of this event multiple times?

Not favoritedFavorited Favorited 0 favourites
  • 6 posts
From the Asset Store
Very simple code without excess options (15 events for server and 11 events for client)
  • Visuals:

    When I run the game, I notice the value 'xx K' above the Houses keeps increasing, infinitely.

    I've tried various things. Even tried Functions, but Functions only run once, and they mean it!

    I basically want every House that is spawned, to run an event, where it first chooses if the price goes up or down after it's spawned (the 'Wait 2 seconds' delay is just for testing). When the MaxValueIncrease becomes 0, it should stop the increase of the StartValue.

    I was also trying to exponentially increase the rate (seconds) that the value goes up or down. So basically, in the beginning it should increase faster and exponentially slow down.

    I thought I had it going until I got bogged down with this problem and had to strip it from the code to debug.

    You'd think this should work but it doesn;t!

  • I suggest using Tween instead. Here is a demo

    dropbox.com/s/z52d010zta1fvkv/TweenValue.c3p

  • Thanks!! With a bit of fiddling I was able to use different tweens. My code is probably a bit too cumbersome, but I got it to work thanks to your example.

  • Hey dop2000 I got a bit stuck at this part, was hoping you could assist me once more?

    The problem is, that even when the sprite House its 'MediumHouse' animation is playing, it still uses the StartValue from 'Trailer' at line 40, instead of that of MediumHouse.

    I suspect it might have to do something with line 38, if I disable the part 'On Created' it does use the proper StartValue from MediumHouse if that animation is playing. But then the Arrows visually start switching between frame 1 and 2 really fast, and the value of House, regardless of its animation, always goes down, never up.

    Also, if I set the initial animation of 'House' sprite to 'Default' (which are empty frames), the House values always start at 0. Maybe it'll help to know that?

    Thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • How do you create the House sprite, with an event? When you create an instance in runtime, "On created" is triggered immediately, even before you select a different animation for the newly created sprite. So in the "On created" event the sprite will have the default animation, which I suppose is "Trailer".

    You need to initialize the tween values in the same event where you are creating the house. Or make a function, which you can call after you've created a new house and set the right animation for it.

  • Thanks! Took your advice and converted the events to a function. It works perfectly now. :)

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