java - Libgdx - 3 images in a group, best practice - also overdraw -


i trying write card game, have image in middle, coloured border , potentially symbol in top left. using libgdx , stage/scene2d.

the image change depending on suit (these not normal 52 deck type of cards), border colour change match suit, though colour can pre determined user can't pre-save coloured images (though guess pre save 15 diff colours , give user choice of 15) , symbol on cards , not others.

first card second card

as can see 2 images i've added have 2 diff images, border colours , symbols.

my question relating groups , overdraw.

1) presume should set group 3 images in, , i'm hoping having won't slow game down have potentially 30 cards on screen @ once , 30 groups 3 images in each lot draw. right , libgdx able handle fine?

2) how should coloured border? should have entire card coloured rectangle , image drawn on top? draw method trying draw coloured section underneath image , wasting gpu/cpu time? friend of mine said have white image, , set colour using rgb values in code? possible? mean have single jpg better apk size.

3) or should ignore using jpg image , try , draw coloured square using shaperenderer?

thanks, hope these questions aren't many in 1 post.

  1. of course not slow game - 90 (30 groups x 3 textures) sprites on screen nothing (i guess) every framework - libgdx thing also.

    although matter how these graphics stored! please use 1 textureatlas textures instead of many textures in many files - can prepare atlas using texturepacker (for basic usage free version ok).

    the reason of if using many single textures libgdx needs switch graphic in gpu bufor (maybe not perfect term) before rendering each of them - if have 1 big texture (including others) not need switch because nothing changes in buffor.

    to more information using textureatlas take @ manual

  2. yes can "color" actor (like image) using example

    actor.addaction(actions.color(new color(1f,1f,1f, 0.2f), 2f)); 

    another approach have 1px x 1px texture of every color (packed in texture atlas) , change it's size. there no reason keep full size singe-colour textures since great vaste of space , memory.

  3. it not idea use shaperenderer - of course helpful drawing sprites has greater performance.

    you little bit scared performance if want save cpu avoiding shaperenderer seems idea.


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -