Need help with asteroid movement

Get help using Construct 2

Post » Sun Dec 16, 2012 5:22 pm

In an attempt to increase my skill level with C2 I am making my own version of the classic "Asteroids" and I need help with the asteroids. For one, I want them to spin while they are in space, and they do that but they do it way way outside of their origin. Second, I want them to float freely around the world and very slowly be attracted to me, the player, that's in the center. How do I make this happen? Also, How do I make them re-spawn?
B
6
Posts: 90
Reputation: 690

Post » Sun Dec 16, 2012 5:49 pm

You can set the origin point in the animation editor. On the left under the toolbar is a button with the target on it. It lets you move the origin point to the middle of your graphic, and can move frame to frame if you animate. (remember, if it is animated, you are only editing one frame, you can right click on it and have it set all the frames to match.)
The origin is the coordinate location for the sprite as well, so you may have to adjust your calculations on spawning and such.

On respawning, you have lots of choices. You can count picked sprites of that type, without actually filtering any to see how many exist, and if it's too few, spawn one.
Or "On sprite destroyed" you could "wait" a few seconds, then spawn a replacement.
Watch the player's score and have them spawn on key values.

There are lots of ways to make them attracted to the player as well, but you almost need to be more specific, as that is a lot to cover.
It could be an invisible sprite surrounding the player, and when the asteroid touching it, it turns slightly toward the player. (the longer it touches the further it turns.)
Or it could always turn just slightly toward the player. (the bullet behavior speed would keep the angle changing, so it would appear to work like gravity.)
There are also plugins for actual gravity points.


B
200
S
51
G
30
Posts: 896
Reputation: 36,494

Post » Sun Dec 16, 2012 6:04 pm

Woah, that's a lot of information. First off, is it the image point that it centers around? I gave it the spin behavior and not sure if that helps or not. Also, The bullets explode outside the asteroid, like there's a invisible box around it. i want to explode when it's touching the asteroid and I'm not sure what's going on there.
B
6
Posts: 90
Reputation: 690

Post » Sun Dec 16, 2012 9:42 pm

You might want to do the basic beginner's guide to C2 which will show/teach you the basic workflow and the basics of how to work with C2.
You would then see that your issue with a bounding collision box is because you haven't set correctly the collision polygon of your sprite.
Then you might want then to also check my tutorial Asteroid in less than 100 events which will take you even a bit further.
It will show you a few tricks about respawn and warp, different waves/levels of asteroids and more.

You might also want to check the manual, especially the interface part which will answer some of your questions.

Finally, once you'll have already gone through all this previous documentation you can check the "How do I FAQ" that has a lot of examples about different mechanics and technic stuff like "attracting objects one to another".
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791


Return to How do I....?

Who is online

Users browsing this forum: currypuff, makotto, randomly, Walessio and 28 guests