Languages & Coding > AGK

draw an image ?

(1/11) > >>


I am tring AGK for first time and I am lost... i just want to display an image

Download ok :


How to put this image on screen ??? I should create a sprite ?

there is no command like Putimage (picture,0,0) ?


That's basically it.  Load the image, create a sprite from it, position and scale sprite, enter do/sync()/loop cycle.

--- Code: ---picture=LoadImage("landscape.png")
sprite = CreateSprite(picture)

--- End code ---
There is an example in the example folder images/ChooseImage shows how to load and display a background as well as choosing an image from a file requester.

Or if you want more control as to when sprites are drawn and also to be able to position sprites at screen coordinates rather than a percentage based system then ( moves a sprite across the screen ):

--- Code: ---SetVirtualResolution( 1920, 1080 )

myImage = LoadImage( "dude.png" )
mySprite = CreateSprite( myImage )

Local x As Float

   SetSpritePosition( mySprite, x, 0 )
   DrawSprite( mySprite )

   Inc x, 1
   If x > 1920 Then x = -GetSpriteWidth( mySprite )


--- End code ---

Of course the above doesn't take into account the different refresh rates of monitors and so the sprite will move quicker the higher the refresh rate but you get the idea of how to go about loading and moving a sprite :)

that's very strange....

images are sprites ? well... i have never seen that in a basic language  :o

i do not need sprites but need to display lot of little image (about 200) on the same screen... so it seems to me very special

Steve Elliott:
No, you apply an image to a Sprite, the Sprite can then be positioned, alpha values set and so on.

You can also load one image and grab sections of it to form lots of Sprites (which is much more efficient).  Using a Sprite atlas.


[0] Message Index

[#] Next page

Go to full version