Trying to createSprite within a function
-
My working code now:
Image19=loadImage(“The Oliver Twins/Dizzy_Characters”,false) Kscale=3 array reaper[1] reaper[0]=createSprite() setSpriteImage(reaper[0],image19) setSpriteAnimation(reaper[0],2,4,1) setSpriteScale(reaper[0], {kscale/6.25,kscale/6.25}) setSpriteVisibility(reaper[0],false) “” I have almost identical sprite sections that I want in a function. “ Function SpritesArray(ArraySize,ImageName,TileStart,TileEnd,AnimSpeed,ScaleX,ScaleY) For I=0 to ArraySize loop SpritesName[i]=createSprite() SetSpriteImage(SpritesName[i],ImageName) SetSpriteAnimation(SpritesName[i],TileStart,TileEnd,AnimSpeed) SetSpriteScale(SpritesName[i],{ScaleX,ScaleY}) SetSpriteVisibility(SpritesName[i],false) repeat Return SpritesName
Image19=loadImage(“The Oliver Twins/Dizzy_Characters”,false)
Kscale=3
array reaper[1]
reaper[0]=createSprite()
setSpriteImage(reaper[0],image19)
setSpriteAnimation(reaper[0],2,4,1)
setSpriteScale(reaper[0], {kscale/6.25,kscale/6.25})
setSpriteVisibility(reaper[0],false)
“I have almost identical sprite sections that I want in a function.
“
Function SpritesArray(ArraySize,ImageName,TileStart,TileEnd,AnimSpeed,ScaleX,ScaleY)
For I=0 to ArraySize loop
SpritesName[i]=createSprite()
SetSpriteImage(SpritesName[i],ImageName)
SetSpriteAnimation(SpritesName[i],TileStart,TileEnd,AnimSpeed)
SetSpriteScale(SpritesName[i],{ScaleX,ScaleY})
SetSpriteVisibility(SpritesName[i],false)
repeat
Return SpritesName
“Call it with:
SpritesArray(1,image19,2,4,1,kscale/6.25,kscale/6.25)
Reaper=SpritesArray()I’m getting an “Incorrect number of parameters for function” on the SpritesArray called line.
Ideas? I have tried a few variations and don’t see anything wrong.
-
It needs to be just one line, like this:
reaper = SpritesArray(1,image19,2,4,1,kscale/6.25,kscale/6.25)
-
@Martin wonderful that worked! So simple and I missed the obvious. Thank you!