I'll probably make a few threads about this, but now for my first question:
Now I am not quite sure if this is the best way to go about things, but it's the only way I can think of right now.How to activate and de-activate object?
I want a player to be able to place berries into a bowl.
1. Create both a de-active and active graphic and put those within a layeredimage.
2. Put in the drag & drop code that, when dragging an item, changes its variable from False to True (and vise versa)
3. When a draggable is dropped, the variable should go back to False.
The problem: It works for the berries, but the bowl stays active.
![]()
Is there perhaps a 'hover' state that will change the graphic between active and de-active? Am I on the right track? Should I do it completely differently?
I would really appreciate your thoughts!
Code: Select all
### BOOLS ###
default berriesActive = False
default bowlActive = False
### Berries graphic ###
layeredimage berriesGraphic:
if berriesActive == False:
"gui/berries.png"
else:
"gui/berries-hover.png"
### Bowl graphic ###
layeredimage bowlGraphic:
if bowlActive == False:
"gui/bowl.png"
else:
"gui/bowl-hover.png"
init python:
def ac_me(activated): # If graphic is activated
store.berriesActive = True
store.bowlActive = True
return
def drag_placed(drags, drop): # If graphic is dropped
store.bowlActive = False <- ! This does not work !
store.berriesActive = False
if not drop:
return
store.draggable = drags[0].drag_name
return True
### Screen ###
screen drag_sample:
draggroup:
drag:
drag_name "berries"
child "berriesGraphic"
activated ac_me
xpos 300
ypos 300
draggable True
droppable False
dragged drag_placed
drag_raise True
drag:
drag_name "The bowl"
child "bowlGraphic"
activated ac_me
xpos 0.4
ypos 0.35
draggable False
droppable True
### Call screen ###
label dragNDrop:
scene black
call screen drag_sample