开发者

SDL.NET wrapper: how to rotate a sprite?

i'm trying to develop my first and simple videogame. I'm using SDL.NET (wrapper .NET of famous SDL) and c#.

I'm trying to rotate my sprite (my "car") when user press down array, up array .. I'm using something like

this.Surface =  this.Surface.CreateRotatedSurface(90);

But it not work ! I've error on screen... :(

I know i can use something like

this.Surface = new Surface("my-sprite-right.png") // for right

or this.surface = new Surface("my-sprite-left.png") // for left

but i don't like that solution...

Does anyone know how to m开发者_JAVA百科anage "rotation" of sprite ?

Thank you !


I don;t know if you got an answer on this one already but when u rotate your car i believe u must do it like this:

  1. Create a new sprite instance like Surface myCarRotated = myCar.CreateRotatedSurface(int 90, true);
  2. Then blit the new surface to your screen
  3. Finally call your video.Update() Method to refresh the screen

Since the car will be heavily transformed (Well, mainly rotation and speed) it's better to write all your logic in a seperate method though.

Note that rotations are heavy on your CPU, you might want to consider to create your rotation images a sprite sheet as explained here: http://egonrath.eg.funpic.de/old/sdl/sdlnet.html#clipblitting

But I dont think it will matter too much nowadays, as long as you dont have 1000 rotating cars.

I have not much experience with sdl.net but I really love it. I tried a couple of c# game engines and I really love it. Currenly I'm building (trying to build ;) an application which tracks player positions during a live Unreal Tournament game. Kind of mini-map type application.

Good luck!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜