Problems Using the API

Dec 29, 2011 at 10:36 PM

If you are having trouble using or understanding some portion of the API, please post those questions here.  Please avoid asking usage questions in the comments of the help documentation.

Jul 31, 2013 at 12:40 AM
Hi, I don't know if I will get a reply here but I am having trouble getting a Sprite to show on the render canvas. I used the same code as you used during the chopper game example however I don't want the sprite to be animated so I changed it to a Sprite instead of an animated spite. So the the program would look for the Sprite in the right location I just replaced the "AirVehicles" image with my smaller sprite image. I thought it would just draw my sprite to the screen instead of the helicopter but instead it draws nothing ot the screen. I also deleted the Lines of code that have to do with the Sprite been animated, the code looks like this:

Protected Overrides Sub OnLoad(e As GdiGaming.GameEngineEventArgs)
    Dim chopperSprite As New Sprite
    chopperSprite.SpriteSheetName = "AirVehicles"
    chopperSprite.Name = "Chopper"
End Sub
Also the Code in ExampleScene looks like this:

Protected _Player As PlayerChopper
Public ReadOnly Property Player As PlayerChopper
        Return _Player
    End Get
End Property

Protected Overrides Sub OnLoad(ByVal e As GdiGaming.GameEngineEventArgs)

    _Player = New PlayerChopper
    _Player.Position = New Vector2(320, 400)

    Dim mainHud As New HudLayer

    _LevelManager = New LevelManager(Me)

End Sub
Aug 16, 2013 at 11:27 AM
Okay I have a new issue now with sound. Whenever I try to use


It gives me an exception "The calling thread cannot access this object because a different thread owns it"

May 13, 2014 at 5:09 PM
Wow, sorry this is from a year ago... I guess I wasn't getting notifications from this page.

The key point is that you forgot to call SetFrameBounds on the Sprite instance... however:

When you replaced the air vehicles image, you should have drawn over the first frame of the chopper instead of replacing the entire image. That image is a sprite sheet providing the images for all of the vehicles. In your case you were only interested in having one frame for the player vehicle. So creating a regular Sprite was the right thing to do, you just should have edited the source image instead of replacing it, and you need to call SetFrameBounds to tell the sprite where on the sprite sheet to find the image.