Codesnippets > 2D-snippets

Mirroring a Sprite

(1/4) > >>

Albert:
Hi!
I have a number of sprites, loaded by LOADANIM
how can I draw a mirrored sprite?
I tried STRETCHANIM with -1, 1 but it seems that stretch values less than 0 -> no sprite visible :(

Please, I need very fast ansver! Or I have to draw all the mirrored sprites :)

Kitty Hello:
try scale = -1 in Rotozoomanim.
No, Flips upside down. It's not possible. Try creating the image again with tiles flipped.

Albert:
Bad news.
Ok. meanwhile i created the mirrored tiles.

MEGAMANFAN:
try tomirrorimage it on paint or gimp or photoshop,etc.etc.etc!

Hemlos:
Polyvectors are great for manipulating texture coordinates.

To understand these functions, just use them exactly as if they were "DRAWSPRITE" commands.
These 3 function will mirror, vertical, horizontal, and both.

ID=0
LOADSPRITE "image.png",ID
SpriteMirrorH(ID,x,y)
 

FUNCTION SpriteMirrorH: num, x, y
LOCAL sW,sH,color=RGB(255,255,255)
GETSPRITESIZE num, sW,sH
STARTPOLY num , FALSE
POLYVECTOR x,y,sW,0, color
POLYVECTOR x,y+sH,sW,sH, color
POLYVECTOR x+sW,y+sH,0,sH, color
POLYVECTOR x+sW,y,0,0, color
ENDPOLY
ENDFUNCTION
 

FUNCTION SpriteMirrorV: num, x, y
LOCAL sW,sH,color=RGB(255,255,255)
GETSPRITESIZE num, sW,sH
STARTPOLY num , FALSE
POLYVECTOR x,y,0,sH, color
POLYVECTOR x,y+sH,0,0, color
POLYVECTOR x+sW,y+sH,sW,0, color
POLYVECTOR x+sW,y,sW,sH, color
ENDPOLY
ENDFUNCTION

FUNCTION SpriteMirrorVH: num, x, y
LOCAL sW,sH,color=RGB(255,255,255)
GETSPRITESIZE num, sW,sH
STARTPOLY num , FALSE
POLYVECTOR x,y,sW,sH, color
POLYVECTOR x,y+sH,sW,0, color
POLYVECTOR x+sW,y+sH,0,0, color
POLYVECTOR x+sW,y,0,sH, color
ENDPOLY
ENDFUNCTION
 

Navigation

[0] Message Index

[#] Next page

Go to full version