I’m adding a DirectGUI button that will allow me to rotate a model in a certain direction.
It works fine, but as it’s just calling a method when clicked , it requires the user to click over and over to keep the model rotating.
How can I make the method continue to be called while the button is held down?
You could put the model rotation logic in a task, define a command that adds the task to the taskMgr and define another command that removes it. Then you can bind the former command to the DGG.B1PRESS event of the DirectButton and the latter to its DGG.B1RELEASE event, something like this:
button = DirectButton(frameSize=(-2.5,2.5,-0.5,1), pos=(-0.8,0,-0.65),
text="Rotate", scale=.1, rolloverSound=None,
def rotateModel(self, task):
""" This task rotates a model """
# insert code here
Now when you press the button the model should start rotating until you release the button.
Hope this helps .
Thx! I had figured out it was probably a task I needed, but wasn’t clear on the bind steps .
I’ll give it a try!