Scaling a sprite with Diddy

Monkey Forums/Monkey Programming/Scaling a sprite with Diddy

hobo(Posted 2012) [#1]
Currently have a sprite that scales up and then disappears. However I am struggling to keep the sprite centered as it scales.

It seems to default to scale from the top left axis.

I looked in the code/definition and couldn't see an obvious way to specify alignment of the sprite.

Should I calculate this manually or is there a setting I am missing?

Thanks.

I'm basically just doing this:

Method New()
   Sprite = New Sprite(spriteGraphic, SCREEN_WIDTH2, SCREEN_HEIGHT2)
End

Method Render()
   Sprite.SetScaleXY(scalex, scaley)
   Sprite.Draw()
End

Method Update()
   scalex += 0.1
   scaley += 0.1
End


Thanks for any help.


therevills(Posted 2012) [#2]
How you loading the loading the spriteGraphic?

If you check out the images.Load method you will see the following parameters:
* name:String
* nameoverride:String = ""
* midhandle:Bool=True
* ignoreCache:Bool=False

Normally you would load an image like:
images.Load("Ship1.png")


And because midhandle defaults to true, it will set the handle of the image to the middle.

If you want to change it later you can do this:
images.Load("Ship1.png")
Local gi:GameImage = images.Find("Ship1")
gi.image.SetHandle(10, 10)



hobo(Posted 2012) [#3]
That was it - midhandle when I load the image was set to false.

Thanks therevills, appreciate your time.