0 Favourites

Image points and rotations

  • Hi there, again. <img src="smileys/smiley17.gif" border="0" align="middle" />

    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?

  • 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.

  • Here it is. Possibly, it can also be my lack of knowledge that creates this, though. <img src="smileys/smiley1.gif" border="0" align="middle" />

    Thanks for the help.

    dl.dropbox.com/u/60029808/shooting_halls.capx

  • 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.

  • 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.

  • 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.

    <img src="http://dl.dropbox.com/u/36472942/construct/forumhelp/LayerRotation.jpg" border="0" />

    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).

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • 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...

  • 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

  • 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.<img src="smileys/smiley36.gif" border="0" align="middle">

    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?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)