Feature request > 2D
GETSPRITESIZE img, width%%, height%%, animframes%%
MrTAToad:
The easiest way to calculate the number of animations is to load the graphic normally (LOADSPRITE), get the width and height from that an then convert to a sprite sheet with SETSPRITEANIM, and then calculate (width/cell width)*(height/cell height)
spacefractal:
The reason is im use a PaintImage() with extra arguments rather than uses draw sprite directly for easier position of that image as well scaling and rotation (I'm not using offbuffer for scaling).
That why its would been nice to calculate frames as well directly without requiring a array or such under loading.
Cold been a new little command or function as well. Howover it's ony idea and low priority completely...
spacefractal:
etc um using this code (a none rotate support throught here):
--- Code: (glbasic) ---FUNCTION PaintImage: Name$, x#, y#, alpha#, zoom#, xspot, yspot, special=0
LOCAL h#, w#, img, hh#, ww#, xx#, yy#, SH, SW, i#, r#
IF Name$=0
img=GetStr$(Name$, "Sprites") // Just a name based sprite FUNCTION rather than number. NOT need FOR test here at all.
ELSE
img=Name$
ENDIF
GETSPRITESIZE img, w, h
IF special<0
LOCAL animw=GetStr$(Name$+".w", "Anim"); animw=w/animw
LOCAL animh=GetStr$(Name$+".h", "Anim"); animh=h/animh
w=w/animw
h=h/animh
ENDIF
// some alpha code in that way I prefer. Not a issue in the real alphamode, its just me :-D
SetAlphaMode(alpha#)
// math placement for hotspots
IF xspot=-1 THEN PX=x#
IF xspot=0 THEN PX=ScreenWidth/2.0-(w#*zoom#/2.0)+x#
IF xspot=1 THEN PX=ScreenWidth-w#*zoom#-x#
IF yspot=-1 THEN PY=y#
IF yspot=0 THEN PY=ScreenHeight/2.0-(h*zoom#/2.0)+y#
IF yspot=1 THEN PY=ScreenHeight-h#*zoom#-y#
PW=w*zoom#
PH=h*zoom#
IF PY-PH>ScreenHeight OR PX-PW>ScreenWidth OR PY<-PH OR PX<-PW THEN RETURN
IF alpha#=0 THEN RETURN
IF special<0
LOCAL www=(PX#-((1-zoom#)*w#)/2)
IF PX#-((1-zoom#)*w#)/2>-PW#
STRETCHANIM img, INTEGER(-special)-1, PX#-((1-zoom#)*w#)/2, PY#-((1-zoom#)*h#)/2, PW#, PH#
ENDIF
ELSEIF special=0 OR special=1
ZOOMSPRITE img, PX#-((1-zoom#)*w#)/2, PY#-((1-zoom#)*h#)/2, PW#/w#, PH#/h#
ELSEIF special=2
ZOOMSPRITE img, PX#-((1-zoom#)*w#)/2, PY#-((1-zoom#)*h#)/2, -PW#/w#, PH#/h#
ENDIF
ENDFUNCTION
--- End code ---
Its works nice (few array based functions missing here, but you got the idea what its happens), the function (which should of course massure both height and width, not just frames). Alternative the command could been GETANIMSIZE img, w, h, and then massure the rest.
Fell free to use the code of course, if you want to use that and modify it to your own needs, and its of couse a completly none priotity "issue".
Kitty Hello:
Is there a command setanim? I think so. You need some getanim to get the applied anim params then. No big deal.
Navigation
[0] Message Index
[*] Previous page
Go to full version