java - Flipping horizontally sprites slick2d -


i'm writing arcade multi-level game slick2d , i'm writing code of entities. i'm trying flip horizontally sprite. first time designed 2 images same sprite, first facing right , second facing left.

now i'm trying flip horizontally sprite getflippedcopy() function, cannot rotate entire animation, can rotate frame.

how can solve?

if drawing animation, can best utilize getcurrentframe() method, that's what's displayed anyway.

do this:

animation.getcurrentframe().getflippedcopy(direction, false).draw(x, y); 

with in render method, set orientation of image based on direction face. if facing left, 'direction' true, current animation image draw flipped @ x , y (which want), , if facing right, direction false, in no flipped orientation occur , show player facing right (depending on image; if facing left in original spritesheet, opposite true).

if doing bit more complex orientation changes, such 4 directional movement:

anim.getcurrentframe().setrotation(90*(direction)); anim.getcurrentframe().draw(x, y); 

where 'direction' north/east/south/west representative integer, 0-3. such 0 = north, 1 = east, etc etc.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -