Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / Image not Appearing

Author
Message
tomshep98
6
Years of Service
User Offline
Joined: 24th Dec 2017
Location:
Posted: 26th Dec 2017 02:34
Hi I have images that are not loading into my program even though they are in the media folder.
can someone please help.
here is my code
MainMenu:
LoadImage(2,"Char1.jpg")
CreateSprite(2)
SetSpritePosition(2,512,10)
SetSpriteScale(2,60,60)

LoadImage(3,"Char2")
CreateSprite(3)
SetSpritePosition(3,512,60)
LoadImage(1,"MainMenu.png")
CreateSprite(1)


CreateText(1,"Click To Play")
SetTextSize(1,60)
SetTextPosition(1,(512-GetTextTotalWidth(2))/2,180)




do
//If GetPointerPressed()=1
//GoSub level
//endif
sync()
Loop
Return
Conjured Entertainment
AGK Developer
18
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 26th Dec 2017 13:31
Quote: "Definition

integer CreateSprite( iImageIndex )

CreateSprite( iSpriteIndex, iImageIndex )
Parameters

iImageIndex - The ID of the image to use when drawing this sprite
iSpriteIndex - The sprite ID to use to reference this sprite later (separate from image IDs, so there can be both a sprite 1 and an image 1)"


LoadImage(2,"Char1.jpg")
CreateSprite(2,2)
SetSpritePosition(2,512,10)
SetSpriteScale(2,60,60)


You forgot to assign the image to the sprite when creating the sprite.

Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1
Supertino
6
Years of Service
User Offline
Joined: 22nd Jun 2017
Location: Behind you!
Posted: 28th Dec 2017 09:02 Edited at: 28th Dec 2017 09:02
Also your SetSpriteScale(2,60,60) is wrong (assuming you dont want to draw the sprite 60 times as big as the original image?), scale factor is 0.0 to 1.0, so half size would be SetSpriteScale(2,0.5,0.5) or double size would be SetSpriteScale(2,2.0,2.0) for example.

Login to post a reply

Server time is: 2024-04-19 09:12:32
Your offset time is: 2024-04-19 09:12:32