Sprite along circumference of a circle

Discussion and feedback on Construct 2

Post » Mon Feb 02, 2015 8:01 pm

I want my sprite to follow the (path) circumference of a circle.
When I press the left arrow key the sprite should move left following the path and when I press the right arrow key the sprite should move back right.

I've tried using the formula

X1 = X + radius * cos(angle)
Y1 = Y + radius * sin(angle)

But I'm not sure if I'm heading in the right direction :?:

I've uploaded an example. The blue sprite should follow along the black path.

I hope someone can help me out on this one.
You do not have the required permissions to view the files attached to this post.
Image
B
31
S
8
G
5
Posts: 75
Reputation: 4,360

Post » Mon Feb 02, 2015 8:39 pm

B
19
S
6
G
6
Posts: 1,101
Reputation: 5,646

Post » Mon Feb 02, 2015 8:43 pm

The simplest way would be not using math at all, instead pin the Blue Sprite on the Circle Sprite and rotate the later...

Here is an example capx.

@Somebody , thanks for the link! The things that I should read to educate my self grows exponentially! :)
You do not have the required permissions to view the files attached to this post.
composer - multimedia artist
www.eli0s.com/en/
B
63
S
26
G
4
Posts: 1,145
Reputation: 9,517

Post » Mon Feb 02, 2015 9:01 pm

Thanks. I'll take a look at the .capx file.

I got mine working with a formula. I forgot to increment the degrees after every press of the key! Duh :)
You do not have the required permissions to view the files attached to this post.
Image
B
31
S
8
G
5
Posts: 75
Reputation: 4,360

Post » Mon Feb 02, 2015 9:19 pm

Thanks eli0s! I figured out how to make the sprite move faster a long the path, but how do I make it follow an invisible path. I can't have a black path on top of my backgound scene :P
Image
B
31
S
8
G
5
Posts: 75
Reputation: 4,360

Post » Tue Feb 03, 2015 12:53 am

@Justin1967 , just use a different (invisible) Sprite for the rotation and keep the one with the Circle as a graphical backdrop. You should align the pivot point of the invisible Sprite with the Circle's center of course.
composer - multimedia artist
www.eli0s.com/en/
B
63
S
26
G
4
Posts: 1,145
Reputation: 9,517

Post » Wed Feb 04, 2015 12:20 am

Thanks eli0s! I figured out how to make the sprite move faster a long the path, but how do I make it follow an invisible path. I can't have a black path on top of my backgound scene :P


Can't you just set: FollowPathOfCircle properties - Initial visibility to Invisible ?
B
32
S
10
G
1
Posts: 14
Reputation: 2,437

Post » Wed Feb 04, 2015 1:40 am

@Gunter , you are right. I had misinterpreted Justin1967's question. I thought that he was asking for the Circle sprite to be visible but not move. Setting the visibility options to invisible is the way to go.
composer - multimedia artist
www.eli0s.com/en/
B
63
S
26
G
4
Posts: 1,145
Reputation: 9,517

Post » Wed Feb 04, 2015 7:33 pm

Thanks for all your help guys. Is there btw a tutorial on 'enemy attack waves' ? Not one the moves on a straight path, but a more complex one like curves, circles etc. What's the best approach?

Couldn't find anything on the forum or on Google.
Image
B
31
S
8
G
5
Posts: 75
Reputation: 4,360

Post » Wed Feb 04, 2015 8:28 pm

There are some very well paced videos on Scirra's Youtube channel. There is one in particular that tackle the basics of a wave pattern system.
This one is older but is more in depth and maybe more instructive.

You can use multiple behaviors and build very complex systems but all that need some experimentation. Also try the Circle behavior, perhaps it can help you build even more complex stuff.
composer - multimedia artist
www.eli0s.com/en/
B
63
S
26
G
4
Posts: 1,145
Reputation: 9,517

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 5 guests