ContentCache error when creating a sprite with an image that has already been loaded

Apr 26, 2010 at 1:10 PM

Hi There,

When running the following code in LoadContent (Excuse the VB):

            Dim sprite1 As Balder.Core.Objects.Flat.Sprite = ContentManager.Load(Of Sprite)("image.png")
            sprite1.Position = New Balder.Core.Math.Coordinate(0, 0, 0)
            Scene.AddNode(sprite1)

            Dim sprite2 As Balder.Core.Objects.Flat.Sprite = ContentManager.Load(Of Sprite)("image.png")
            sprite2.Position = New Balder.Core.Math.Coordinate(50, 0, 0)
            Scene.AddNode(sprite2)


only the first sprite added to the Scene is displayed. Upon debugging, I believe this is because there is an error in the LoadInto<T> method of ContentManager, as when recreating the IAssetPart list, the image has a width and height of 0, whereas the dimensions are properly populated on the initial load.

Am I doing somethign wrong here, or is this indeed a bug?

Thanks

Apr 26, 2010 at 2:28 PM

Nevermind, I have solved my own problem by loading the graphic first as an image, then using GetAssetParts on the image and SetAssetParts on a new instance of sprite.

Coordinator
Apr 26, 2010 at 11:32 PM

This was a problem with the first push of the ContentCache - have you refreshed your source? 

I'll dig into it to make sure there aren't any problems related to this.

Ps: No need to excuse the VB - in fact I quite like a lot of the VB syntax. :)

Coordinator
Apr 27, 2010 at 12:12 AM

I fixed this problem now. I did in fact fix it specifically if one were to load Images directly and not Sprites. The problem has to do with an Image being both an Asset and an AssetPart, so it gets into a confused scenario I didn't think of. 

Anyways, I've just pushed an update to this problem.

 

Thanks for pointing this one out.