# help a noob :)

Get help using Construct 2

### » Thu Nov 07, 2013 2:00 pm

Hi Forum - this first time poster, long time lurker and all time noob needs a hand :)

I'm trying to make a little infinate runner/jumper game that will involve several changes in gravity along the way - I've been looking at the gravity platformer tutorial for inspiration, but it seems to be somewhat overkill for my use...

the concept is very similar to what s made in this video youtube.com/watch?v=o-l6DA9I77E    ( sorry cant post urls yet :/ )

I have no problem getting the player to change gravity orientation from starting position to new position (as in the video - from the earth to the moon) but how can I make a system that enables the player to change back ?

Get it on Google play or play on papio.nu
B
11
S
2
Posts: 79
Reputation: 786

### » Thu Nov 07, 2013 3:17 pm

In that youtube link it looks like you could just do the same again in reverse as he did to jump from earth to the moon?
On collide with "red" & Orbit = 1 Then set angle towards (earth.x,earth.y) & set orbit=0.
B
6
S
2
Posts: 23
Reputation: 712

### » Thu Nov 07, 2013 3:54 pm

yup! thats more or less what I tried in several different ways (not that you coul know sry)

i try to do something like this

player on collide with "red" & orbit 0 then set angle towards (planet.x, planet.y) & set orbit 1

(and the next event reverse it)

player on collide with "red" & orbit 1 then set angle towards (planet2.x, planet2.y) & set orbit 0

but.. that doesnt work - seem like the orbit variable changes and checks cancel each other out and the result is that the player now wont change its initial gravity angle.

Get it on Google play or play on papio.nu
B
11
S
2
Posts: 79
Reputation: 786

### » Thu Nov 07, 2013 4:07 pm

How odd!
Any chance you could upload a capx to peek at?
B
6
S
2
Posts: 23
Reputation: 712

### » Thu Nov 07, 2013 4:14 pm

Since the event sheet works top to bottom, when it gets to the second event, it's also true since the first event set orbit to 1.

I would create a function and call it when the collision happens. Pass it a parameter of orbit. Then in the function, check the param if it's 1 set orbit to 0 and vice versa.   I hope that makes sense, if not I can try to explain it a bit better.
B
101
S
32
G
12
Posts: 1,549
Reputation: 22,103

### » Thu Nov 07, 2013 4:43 pm

Thanks guys! I can't quite graps how the function solition would avoid the "canceling out" problem, but i'll give it a shot and see :) (need to wrap my head around functions anyway :) ) Kali2013-11-07 16:43:28

Get it on Google play or play on papio.nu
B
11
S
2
Posts: 79
Reputation: 786

### » Thu Nov 07, 2013 5:07 pm

Well since you are passing the orbit value into the function as a parameter, it takes the value at the time of calling the function. Changing the value of orbit inside the function won't effect the value that was used when it was called. Does that make sense?
B
101
S
32
G
12
Posts: 1,549
Reputation: 22,103

### » Thu Nov 07, 2013 5:19 pm

I made a rough example. Hope it helps.

https://www.dropbox.com/s/hdpa33idvslenfa/function.capx
B
101
S
32
G
12
Posts: 1,549
Reputation: 22,103

### » Thu Nov 07, 2013 5:32 pm

HAH! Sucess!!! oh the joy !!!

the function worked great - didnt know that the paramater wouldn't interfeer with the initial value... that will certainly come in handy in the future... only hickup was to figure out the right way to compare the paramater value .. but that worked out aswell... so thanks a lot :) Kali2013-11-07 17:32:51

Get it on Google play or play on papio.nu
B
11
S
2
Posts: 79
Reputation: 786

### » Thu Nov 07, 2013 5:52 pm

You are welcome. My example might answer that question for you.
B
101
S
32
G
12
Posts: 1,549
Reputation: 22,103

Next