How do I keep a player "on rails"?

Get help using Construct 2

Post » Fri May 15, 2015 2:04 pm

I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri May 15, 2015 3:22 pm

LittleStain wrote:Sorry, another try.. :)


That's it! It works perfectly. Thank you so much for your help. :D

Bonus question: If I were to change the shape of the circle (perhaps to make it more of an oval), how would I change the code? It looks like I'd maybe have to change that "move 0.5*sprite.width pixels" bit?
B
14
S
2
Posts: 73
Reputation: 794

Post » Fri May 15, 2015 3:34 pm

Oval would be pretty hard, haha..
in this particular case 0.5*sprite.width is the radius of the circle, an oval is a bit harder to calculate..

I'm not really that good at math..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri May 15, 2015 4:48 pm

Yeah, I'm no good at math, either, ha.

What if it was more of a pill shape with multiple sprites? Like, two circles for the sides (but only half is used) and two lines in the center connecting them? It doesn't need to be EXACTLY an oval, but my thinking is that I'd like the sprites to rotate around as much of a widescreen window as they can. Something with the sprites changing their movement behavior when they collide with a different part of the pill?

I guess an RC racetrack (in the simplest configuration) would be a better visual analogy?
B
14
S
2
Posts: 73
Reputation: 794

Post » Fri May 15, 2015 5:42 pm

Yeah, a pill- shape could be done..

It would consist of checking the x coordinate of the touch and using an angle of 90/270 degrees when in the straight part and the angle towards touch from the circle center when in the half circle part..
Even nicer would be to give the pil harmonica-movement, so it goes from pill-shaped to circle and back.. :p
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Fri May 15, 2015 9:30 pm

Good advice, I'll give that a shot. Thanks again for all your help!
B
14
S
2
Posts: 73
Reputation: 794

Post » Sat May 16, 2015 7:24 pm

Here's the example tweaked to work with rotated ellipses.
For unrotated ellipses dx and dy are just (Sprite2.x-sprite.x) and (sprite2.y-sprite.y).

https://dl.dropboxusercontent.com/u/542 ... lipse.capx
B
91
S
31
G
102
Posts: 5,232
Reputation: 67,250

Post » Sat May 16, 2015 7:28 pm

R0J0hound wrote:Here's the example tweaked to work with rotated ellipses.
For unrotated ellipses dx and dy are just (Sprite2.x-sprite.x) and (sprite2.y-sprite.y).

https://dl.dropboxusercontent.com/u/542 ... lipse.capx



Nice one, haha..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun May 17, 2015 11:40 pm

Message: donkeyspaceman is not yet permitted to post plain text URLS (300 rep required). 1 URLS removed. Why?
R0J0hound wrote:Here's the example tweaked to work with rotated ellipses.
For unrotated ellipses dx and dy are just (Sprite2.x-sprite.x) and (sprite2.y-sprite.y).


Hey, that's awesome! I was just trying to figure out how to get the center area of my pill shaped track to work (and failing), so this example is a nice surprise.

The only issue is that it doesn't allow for multiple players to move independently (or at all, it seems) like LittleStain's example. How would I go about setting that up here?
B
14
S
2
Posts: 73
Reputation: 794

Post » Mon May 18, 2015 2:13 am

Sorry, I think I neglected the fix in LittleStain's capx. I don't use multi-touch devices so I didn't test. The fix is to do what LittleStain did in his capx.

1st add this event:

Code: Select all
on touched sprite2
--- sprite2: set touchID to touch.touchID


2nd replace sprite2.x and sprite2.y with
touch.XForID(Sprite2.TouchID)
and
touch.YForID(Sprite2.TouchID)

That should make it behave like LittleStain's capx.
B
91
S
31
G
102
Posts: 5,232
Reputation: 67,250

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 3 guests