Skip to content

Instantly share code, notes, and snippets.

@panmari
Created August 14, 2012 12:41
Show Gist options
  • Save panmari/3349009 to your computer and use it in GitHub Desktop.
Save panmari/3349009 to your computer and use it in GitHub Desktop.
Touch is not automatically enabled, when a TouchListener is added
package ch.aplu.cardex12;
import android.graphics.Color;
import ch.aplu.jcardgame.*;
import ch.aplu.android.*;
public class CardEx12 extends CardGame
{
public enum Suit {
KREUZ, HERZ, KARO, PIK
}
public enum Rank {
ASS, KOENIG, DAME, BAUER, ZEHN, NEUN, ACHT, SIEBEN, SECHS
}
private Deck deck;
private Hand talon;
private Hand pile;
public CardEx12()
{
super(Color.rgb(20, 80, 0), Color.WHITE, BoardType.HORZ_SPLIT,
windowZoom(600));
}
public void main()
{
deck = new Deck(Suit.values(), Rank.values(), "cover");
talon = deck.dealingOut(1, 9)[0];
StackLayout talonLayout = new StackLayout(new Location(200, 300));
talon.setView(this, talonLayout);
talon.draw();
pile = new Hand(deck);
StackLayout pileLayout = new StackLayout(new Location(400, 300));
pile.setView(this, pileLayout);
pile.draw();
talon.addCardListener(new CardAdapter() {
public void pressed(Card card) {
card.transferNonBlocking(pile); }
});
talon.setTouchEnabled(true); // why do I need to enable it first?
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment