"Throw" object in tow-down view with Sine behavior

0 favourites
  • 7 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • CAPX: https://www.sugarsync.com/pf/D6025908_4317202_6900854

    The game play is a top-down view. What I'd like to do is create an item (object GrenadeFlash) that, when "thrown" from the player (object CharFinn), it will appear as if it's rising in elevation as you look down. Naturally, as something comes closer to you, it appears to be getting larger. This is where the Sine behavior comes in.

    The problem I'm facing, though, as I learn how to use the Sine behavior is how to stop it mid-period. Let's say the object I'm using is 10 pixels wide and I want its size to expand by 10 (to a max of 20) during its run through the Sine behavior. I've noticed, however, that it will shrink to less than 10 pixels before it finishes its cycle.

    What I want to do is set it so that when it is launched, it will increase to my desired max size then return to its original size and then be destroyed. I can figure out the movement of the object and destroying it. What I'm not sure about is how to cut it off mid-period.

    Any suggestions?

    Thanks!

  • I'm not quite sure how it is supposed to work, for I haven't used Sine-behaviour myself.

    This workaround seemed to work though:

    • adding a timer-behaviour to the grenade.
    • add a subevent on spawn to set the timer to half the sine-period
    • on timer - destroy grenade.

    I added another sine and set it to forward-backward and period to 8

    This really gave the idea of throwing and by setting the magnitude you can decide on the distance of the throw.

    it's not a very clean workaround, but did get reasonable results.

  • The sine behavior is not designed for that. Its destination is to loop indefinitely.

    Luckily, doing your own sine-based behavior is one of the easiest things in programming (at least if your ever heard of sin and cos in school and know how to use wikipedia).

    Here's a simple example (copy.com link): throw_sine.capx

  • Thanks, guys. I appreciate the feedback. :)

  • Dear tulamide

    I can't get your example from copy.com.

    I might doing something wrong but I registered in order to download it and if I click on download I get this:

    {"result":"error","error_code":"1012","error_string":"Cannot find requested object id "}

    If I send it on the copy folder and try to download it from there, it comes as an 22kb zipped file which is empty?!

    Can you check on the copy.com link or provide us an other download option to your (very informative I am sure) example? <img src="smileys/smiley2.gif" border="0" align="middle" />

    Thank you,

    Elias

  • Seems, copy.com does have issues. I used it mainly to test exactly that. However, I updated the link here:

    throw_sine.capx

    I expect it to render invalid soon, so grab it while it's hot^^ Does anybody know if copy.com links have a time window?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This second link did the trick for me!

    Man, this is the simple programming?!? <img src="smileys/smiley5.gif" border="0" align="middle" /> <img src="smileys/smiley4.gif" border="0" align="middle" />

    Thank you very much tulamide !!! Again, once more an excellent example!!!

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