简体   繁体   中英

c# XNA 2d vector points relative to origin

I have a query on manipulating Vectors in c# XNA. I currently have a 2d texture with an origin set to the centre of the sprite, and two separate vectors that are relative to that origin, like so:

ship1.Engine1.X = (float)Math.Cos(ship1.Angle) * 50 + ship1.Position.X;
ship1.Engine1.Y = (float)Math.Sin(ship1.Angle) * 50 + ship1.Position.Y;
ship1.Engine2.X = (float)Math.Cos(ship1.Angle) * -50 + ship1.Position.X;
ship1.Engine2.Y = (float)Math.Sin(ship1.Angle) * -50 + ship1.Position.Y;

Both of these engine vectors have particle effects for rockets, and so need to be positioned over the exhausts on the sprite. They are lined up along the relative X axis of the ship texture, but I cannot work out the math behind moving them downwards, in the relative y axis. How would I go about doing that? Thanks in advance.

What I mean: http://i.stack.imgur.com/S5bkS.png

You're giving the points the same rotation as the ship.

Try replacing ship1.Angle with either ship1.Angle + MathHelper.PiOver2 or ship1.Angle - MathHelper.PiOver2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM