Jump to content
  • Advertisement
Sign in to follow this  
Ekim_Gram

Unity SdlDotNet Sprite not drawing where it should

This topic is 4883 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Yet again I have run into another problem with this fun fun library of mystery and lack of decent tutorials. Today I decided that before I venture into making yet another Pong clone to get myself familiar with both the language and API, I would mess around a bit with the SdlDotNet.Sprite class. My demo program is pretty much the same as in my other topic. All that's pretty much changed is as follows:
		public void Run()
		{
			Surface background = new Surface("images/bg.bmp");
			Sprite spaceship = new Sprite(new Surface("images/ship.bmp"), new Vector(100, 200));
			spaceship.Surface.TransparentColor = System.Drawing.Color.Magenta;
			spaceship.Surface.Transparent = true;

			while (done == false)
			{
				while(Events.Poll())
				{
				}
				screen.Blit(background, new Rectangle(new Point(0,0), background.Size));
				screen.Blit(spaceship);
				screen.Flip();
			}
		}

The problem is that the spaceship sprite is not being drawn at (100,200) but at (0,0). Before this, I tried manually setting spaceship.X/Y but that was a failure as well.

Share this post


Link to post
Share on other sites
Advertisement
The main problem is that there is a bug with the screen.Blit(sprite) method. I have corrected that. Thanks for pointing out the problem. In the meantime, you can instantiate a SpriteCollection class, add the sprite to it and to a screen.blit(spriteCollection) instead. That works. I will include the bugfix for the blit(sprite) method in the next release.

On the tutorials, I understand the issue with that. A lot of work still needs to be done there. Have you taken a look at the BounceSprite tutorial I included with the last release? It sheds some much needed light on how Sprites and SpriteCollections work. It is in the docs dir and the code is under examples/BounceSprites.

Share this post


Link to post
Share on other sites
Yeah, I looked at the BounceSprites and when I saw that SpriteCollection was working with the blit but not the Sprite, I got a little confused.

And if you're really one of the developers of SdlDotNet, I must say you've done an amazing job.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!