Wild Card/ syntax for loading multiple images
Monkey Forums/Monkey Beginners/Wild Card/ syntax for loading multiple images
| ||
I am trying to load multiple images but i am unsure as to which wild cards or syntax I can use with the loadimage command I have many monster .pngs for the player to choose as their character so I want to load the images and give the player the ability to cycle through them to choose the one they want. EX p = New player p.image = LoadImage("player.png", 1, Image.MidHandle) So I plan to use a for next loop and increment p. now if I named my images 1.png 2.png psuedo code for t 1 to 10 Could I use t.image = LoadImage(t".png",1,Image.MidHandle) or t.image = LoadImage(t + "png"1,Image.MidHandle) next |
| ||
got it sorted here is the code for reference if any one needs it. It will allow a player to cycle through multiply png images named 1.png 2.png etc..Import mojo Class Game Extends App Field playerImage:Image Field created:Int = 0 Field mx:Float Field my:Float Field p:player Field aload:Int =1 Method OnCreate () HideMouse () SetUpdateRate 60 p = New player p.image = LoadImage(aload + ".png", 1, Image.MidHandle) End Method OnRender () Cls 0, 0, 0 ' Clear screen p.OnRender() End Method OnUpdate () p.OnUpdate() If MouseHit(MOUSE_LEFT) Then If aload < 40 aload = aload + 1 p.image = LoadImage(aload + ".png", 1, Image.MidHandle) Else aload =1 end End If End End Class player Field x:Float = MouseX() Field y:Float = MouseY() Field image:Image Method OnRender() DrawImage image, x,y, 1, 3, 3 End Method OnUpdate() x = MouseX() y= MouseY() end End |
| ||
If you look at gerryq/picpuzzle in bananas, you will see how it looks for as many images as it can find named pic001.png, pic002.png etc. (it's at start of OnCreate()). |