I've tried to do so via the add_marker() method, but I'm not sure if I'm doing something wrong, or if it simply won't take text displayables. I've yet to get it to display images either, and I don't quite know why. Regardless, every attempt has resulted in the card in question either vanishing, or becoming unresponsive to attempts to click and drag.
If add_marker() can't do that, what sort of approach might I be able to take to layer text or images over a card, and have the card still behave correctly? I'm willing to alter the code of the framework and learn some pretty advanced concepts if I need to, but I just don't know where to start, so I'm reaching out here in hopes somebody more experienced can point me in the right direction.
I have a code sample, but the current code of the game simply moves a single card from one stack to another in response to a mouse click, then ends the game. I'll post it anyway on the off chance it helps, though. Please excuse the lack of comments, as I'm changing things pretty rapidly trying to figure out what I can make the Cardgame Framework do:
Code: Select all
label dragondate:
init python:
class dTable(object):
def __init__(self):
LEFT = 100
TOP = 100
COL_SPACING = 200
ROW_SPACING = 200
moved = False
self.table = t = Table(base="card/base.png", back="card/base.png")
self.teststack = t.stack(LEFT, TOP, xoff=0, yoff=0, show=100, click=True, drag=DRAG_TOP, drop=True)
self.card1 = t.card(1, "card/1.png", "card/base.png")
self.card2 = t.card(2, "card/2.png", "card/base.png")
t.set_faceup(1, True)
self.teststack.append(1)
self.stack2 = t.stack(300, TOP, xoff=0, yoff=0, show=100, click=True, drag=DRAG_TOP,drop=True)
self.stack2.append(2)
t.add_marker(1, "images/bottom.png")
t.set_faceup(1, True)
def stackclick(self, evt):
if self.teststack:
#self.teststack.remove(1)
self.stack2.append(1)
moved = False
def interact(self):
evt = ui.interact()
rv = False
# Check the various events, and dispatch them to the methods
# that handle them.
if evt.type == "click":
if evt.stack == self.teststack:
rv = self.stackclick(evt)
state = "win"
def show(self):
self.table.show()
def hide(self):
self.table.hide()
def set_sensitive(self, value):
self.table.set_sensitive(value)