Thanks Mobiius for Guide.
Quote: "1) You use setfolder, but don't return the folder, so every time you shoot a bullet, you're trying to add \media\images\items\ to the current path. (So after 3 bullets, the current virtual working folder will be 'media\images\items\media\images\items\media\images\items\' which is obviously wrong.) At the end of the function, include a SetFolder( "" )"
Ok, I added SetFolder( "" ) at End My Function like below:
Function CreatePlayerBullet()
//Load Image
SetFolder("/media/images/items")
if GetImageExists(BulletImg) = 0 then BulletImg = LoadImage("/bullet.png")
if P_BulletNumber < P_MaxBullet
P_BulletNumber = P_BulletNumber + 1
else
P_BulletNumber = 1
endif
//Create Sprite
if GetSpriteExists(EmptySpr) = 1
if GetSpriteExists(PBullet[P_BulletNumber]) = 0
PBullet[P_BulletNumber] = CloneSprite(EmptySpr)
SetSpriteVisible(PBullet[P_BulletNumber],1)
SetSpriteImage(PBullet[P_BulletNumber],BulletImg)
SetSpriteSize(PBullet[P_BulletNumber],7.734375,-1)
SetSpritePositionByOffset(PBullet[P_BulletNumber],GetSPriteXByOffset(player.spr)+1,GetSpriteYByOffset(player.spr)-2)
endif
endif
SetFolder("")
EndFunction
Quote: "2) You're using '\' when you should be using '/' in SetFolder."
Ok, change Backslash to Slash like below code:
SetFolder("/media/images/items")
Quote: "3) You don't specify if P_BuilletNumber is global, therefore may always be 0.
4) You don't specify if P_MaxBuillet is global, therefore may always be 0.
5) You don't specify if EmptySpr is global, therefore may always be 0."
Why I can't use global for them?
currently I changed to local instead global.
basically when I can't use global variables?
Quote: "6) Missing '/' from start of "bullet.png""
when I sue backslash before bullet.png, it don't show.
BulletImg = LoadImage("/bullet.png")
but when I use "/" in
SetFolder("/media/images/items/") instead of first "bullet.png" , it show Image.