Image points and rotations

Get help using Construct 2

Post » Tue Jan 31, 2012 5:41 pm

Hi there, again.

I'm doing good with C2, got the basic setup and way of my game in my mind and construct is helping heaps. Now, I'm using the GREAT feature that image points is, but I'm having a doubt.

I set my plane to fire on space press (check)
Thing is, putting my plane to shoot it's origin point works ok, but I want to make it fire through the wings. I set up image points in both and can make it fire ok, unless I TURN. The image point seems to not rotate, while the sprite does.

Is this normal behaviour?
B
25
S
8
G
7
Posts: 184
Reputation: 6,040

Post » Tue Jan 31, 2012 8:09 pm

Image points rotate with the object. So that does not sound like normal behavior. Did you add the image point to *all* animations and animation frames? Adding it to 1 frame only adds it to that 1 frame unless you right click and apply to whole animation, then also set it for other animations.

Otherwise, sharing your .capx is always good to help us solve your problem.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Wed Feb 01, 2012 3:54 pm

Here it is. Possibly, it can also be my lack of knowledge that creates this, though.
Thanks for the help.
http://dl.dropbox.com/u/60029808/shooting_halls.capx
B
25
S
8
G
7
Posts: 184
Reputation: 6,040

Post » Wed Feb 01, 2012 10:37 pm

Well, you spawn your bullets in the "Background" layer (the one which gets rotated) and not in the "Player" background.

I guess this is what's giving you the impression the imagepoint doesn't turn.
Actually the sprite does not turn, it is the background underneath it that does.
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

Post » Wed Feb 01, 2012 11:09 pm

Well, but the image point does. And the bullets are supposedly created where the sprite, after rotation, has the image points in.

Am I missing something here? I'm almost positive that I'm having the most logic thinking here:
Spawn bullet at a specific point, following it's merry way.
Rotating the sprite, the image points follow

That does not seem to be the case, though.
B
25
S
8
G
7
Posts: 184
Reputation: 6,040

Post » Thu Feb 02, 2012 12:21 am

You have to remember that you're using two different layers and that the X,Y coordinates of a rotated layer will be the same, even if visually the object appears at a different position.



Hopefully this figure will illustrate what I mean.
The little black rectangle is your object.
Both black X's marks the spot.... I mean represent your imagepoints.
The big black rectangle is your non rotated layer.

In red, the rectangle represents a rotated layer, and the red X's are the visual position, according to the black X's coordinates (both the red and black X have the same x and y for C2).

It is doing exactly what you say, it spawns at the coordinates of the image point.
But visually it is not the spot/angle you're looking for.
So solution is to spawn the bullets on the same layer as the plane. This way the position will always be the good one.
Else, you need to recalculate the position thanks to a bit of sin/cos. (there were already quite a few posts about this issue since the beginning of the competition).
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

Post » Thu Feb 02, 2012 9:35 am

Thanks for the reply. Very useful. And the drawing as well. Helped to clarify this particular item. You are a very friendly individual.

Now, this particular mechanic doesn't really make much sense to me, though I was half expecting it would be exactly this, because of C2's "layering", though it doesn't look it the right thing to do.

I mean, I want to spawn the bullet at a specific place, wherever it is. It doesn't make any sense that the bullets spawn in a different layer in an image point that shouldn't be there!

Were not image points supposed to work as exact coordinates?

Oh, well...
B
25
S
8
G
7
Posts: 184
Reputation: 6,040

Post » Thu Feb 02, 2012 12:10 pm

That's your solution rotatingPlaneShoter.capx

Layers have their own coordinate space, the behavior you get is logical and expected. But unfortunately not well understood.
The answer is that you don't really want to rotate a layer, but to rotate the entire layout and counter rotate the plane.

Also I tweaked the shoting... just for fun.Yann2012-02-02 12:10:56
Last edited by Yann on Sun Sep 14, 2014 9:46 pm, edited 1 time in total.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Thu Feb 02, 2012 3:05 pm

[QUOTE=Yann] That's your solution http://dl.dropbox.com/u/23551572/C2/rotatingPlaneShoter.capx

Layers have their own coordinate space, the behavior you get is logical and expected. But unfortunately not well understood.
The answer is that you don't really want to rotate a layer, but to rotate the entire layout and counter rotate the plane.

Also I tweaked the shoting... just for fun.[/QUOTE]
The key was rotating the layout and adjust the plane's rotation to follow the layout?

Thanks guys!

Though I now understand (both of your replies make sense), I don't really think it's logic. But I can adapt to it if it is how it is.

So basically, I'll have to make EVERYTHING rotate using the layer the player is at as reference, including the whole layout?
B
25
S
8
G
7
Posts: 184
Reputation: 6,040


Return to How do I....?

Who is online

Users browsing this forum: mercuryus and 13 guests