;Duh… the randoming of your cards is at poor design coz its possible to draw identical cards more than twice… instead make a condition that the
card will random
compare the cards from previous random numbers
if it is identical random new number then compare again…actually place it to do…while statement that while there are identical cards random again… ihope im makin sense here.
about the sprite problem… i presume this is your class
c2[i] = createCard("/LONGMinicardfull2.png");
the canvas displays your 13 cards but the thing is in your code they are overlapping that’s why you cannot see the other cards
i suggest you to use
c2[i].setRefPixelPosition(Xaxis+ increment, Yaxis);
if you want to place yor cards horizontally and place them on your designated position.
then layer.append(c2[i]); to place it on layermnger…
and another this is… your image in the sprite contains 51 concatenated images right?
i think you should use this code…
modify your initialisation to this
for(i=0;i<51;i++){
c2[i] = createCard("/LONGMinicardfull2.png",i);
}
you will pass the “i” value to your createCard class. to your createCard class… modify your constructor like this…
but add this b4 your constructor
private int[] FRAME_SEQUENCE; //this must be array because framesequence class accepts only arrays
private createCard(Image img, int SEQUENCE){
super(img, 15, 20); //if the res of the single card is 15x20
FRAME_SEQUENCE = SEQUENCE;
setFrameSequence(FRAME_SEQUENCE);
}
because if your PNG image consists of 51 images the class will automatically cut it to 51 pieces based on the parameters of super(img, frameWidth, frameHeight). frameWidth and frameHeight is the basis on how many pieces the PNG will be cut into . be sure to put the exact pixel width and height or your card(not the whole PNG but the small card in it)
to wrap this up. this must be the pseudocode of your program
- initialise/make the 51 cards ( see the for loop with i<51)
2.create 13 random numbers which makes sure that every number is unique (see the first part of this message)
3.place/append the cards on the layer and make sure to set each card to its referencePixelPosition
- PAINT! :