简体   繁体   中英

Moving a Shape with SFML C#

I'm wanting to easily move a shape around using SFML.Net bindings.

Do I have to do shape.Position = new Vector2f(x, y) all the time?

The following mentions that to build a custom shape with SFML, you have to use the sf::Shape class.

A shape is basically a convex polygon, in which each point can have its own position and color. You can also add an automatic outline to a shape, each point having the ability to define its own color for the outline.

It then goes on to mention that like every drawable object in SFML, shape objects inherit the common functions to set their position, rotation, scale, color and blending mode.

Polygon.SetColor(sf::Color(255, 255, 255, 200));
Polygon.Move(300, 300);
Polygon.Scale(3, 2);
Polygon.Rotate(45);

Unfortunately Move(), Scale() and Rotate() do not exist within C# as far as I can tell.

For SFML.Net the Transformable class (from which Shape inherits) has the properties Position , Rotation and Scale . Just use the setter/getter methods.

src/Graphics/Transformable.cs

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