One-way sine curve

Get help using Construct 2

Post » Thu Mar 06, 2014 1:02 pm

I'm using a sine wave behaviour to move a sprite but i don't want it to 'dip' below it's starting position. Take a look (please excuse the crude drawings lol!):

sinecurve1.png

The straight line is the sprite's (star) starting position and this is how I have it, as you can see it dips below the sprites starting position. Imagine the straight line is the bottom of the playing area then the sprite would disappear off screen as it dips below and I don't want this.

I would like to have it move like this:

sinecurve2.png

I know I can do this if i start the sprite further up the curve but that's not what I want. Is it possible using the Sine wave behaviour? My maths is non existent so I really don't want to uses mathematical expressions if at all possible.

Any help would be really appreciated. :)
You do not have the required permissions to view the files attached to this post.
B
72
S
25
G
9
Posts: 383
Reputation: 10,661

Post » Thu Mar 06, 2014 1:25 pm

Nickydude wrote:I know I can do this if i start the sprite further up the curve but that's not what I want.

Why not? It is the solution to your problem. The lowest point of a sine wave starts at 75% of the period's length. So, if the period is 2 seconds, the period offset would need to be 1.5 seconds.
Image
B
24
S
8
G
10
Posts: 1,821
Reputation: 8,279

Post » Thu Mar 06, 2014 1:51 pm

Why not? It is the solution to your problem.


Because that's not what I want, I'd like the sprite to start at one side of the screen, sine wave to the other side and back again to the start position. I've played around with the Period (which is 5) and Period Offset but it's still moving off the screen.

You can see what I mean here: http://www.madladdesigns.co.uk/extras/invaderoids
B
72
S
25
G
9
Posts: 383
Reputation: 10,661

Post » Thu Mar 06, 2014 4:38 pm

as tulamide said it is just down to the offset (sine wave) and moving its start point up/across as needed - see attachment.
You do not have the required permissions to view the files attached to this post.
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
33
G
47
Posts: 1,194
Reputation: 30,832

Post » Thu Mar 06, 2014 8:00 pm

Ahh.. there's 'mathery' involved! - spSineWave.Y-spSineWave.Sine.Magnitude and I wouldn't have a clue about this. I was trying to do it straight through the behaviour. Thanks for your help guys and I'll take a good look at the example RamPackWobble and see what I can do. :)
B
72
S
25
G
9
Posts: 383
Reputation: 10,661

Post » Thu Mar 06, 2014 9:46 pm

this translates to

(the y position I wish to start at) -(the distance (magnitude) of the sine wave)

even I can follow that maths... :)
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
33
G
47
Posts: 1,194
Reputation: 30,832


Return to How do I....?

Who is online

Users browsing this forum: jorgmaquoi, kettering bug, senecaa and 17 guests