Animated Sprite Class +example

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Because of some hardware limitations you should stick with power of two textures in size. For example 128x128 or 256x64 and so...
Magus_Stragus
Posts: 86
Joined: Wed Aug 29, 2007 10:45 pm

Post by Magus_Stragus »

I wonder, is there a way to draw the animation in a GUI element rather than in the device?
Proud member of the Online Campaign for Real English. If you believe in capital letters, correct spelling and good sentence structure then copy this into your signature.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Probably yes.
Best would be to derive new class from IGUIElement and incorporate all functions in to it.

Perhaps you can even store pointer in to some GUI element in sprite class itself and animate via changing texture.
arnir
Competition winner
Posts: 154
Joined: Sat Jan 20, 2007 4:36 pm
Location: Czech Republic

Post by arnir »

there must be bug in setPosition()...

if I set position to 0,0 everything is OK
Image

but if I set position to 100,100
Image

it's not 100,100, it's 100,150 and I don't know why

EDIT: and texture size is 512x256
programmer is bad designer
designer is bad programmer
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

I looked in to code and checked example but everything seems to be correct. Can you send me your texture and part of code which handle it?

You can also try to replace texture in example I provided with your own and see if problem disappears or not.
arnir
Competition winner
Posts: 154
Joined: Sat Jan 20, 2007 4:36 pm
Location: Czech Republic

Post by arnir »

I found a causer of this error.
I am using TGM blur, and If I remove all setRenderTarget(), Blur, etc stuff, everything is OK... but I don't know why :cry:
but your code is allright :wink:

EDIT: I separate AnimSprite code from blur code and all is OK 8)
programmer is bad designer
designer is bad programmer
blutbeere
Posts: 29
Joined: Sat Nov 19, 2011 10:59 am
Location: Bergisch Gladbach, Germany

Re: Animated Sprite Class +example

Post by blutbeere »

Sorry to push this Thread, but could someone please reup the Files.
Thanks in advance :D <3
Post Reply