My if and else statement works but when i press the button i created for it, i get no results from it and i am not sure if its the cmds.setKeyframe i have set up within the statement thats causing the issue.
class Shells(object):
def __init__(self): #initializing the class ShellsUI
self.Shells = [] #empty list
self.currentX = 0 # this is where the ball is placed
self.space = 4 # spacing of the cups
def createUI(self):
#Test to see if the window exists
if cmds.window('ShellsWin', exists=True):
#delete the window
cmds.deleteUI('ShellsWin')
#create a new window
cmds.window('ShellsWin', title='Shells Game UI')
cmds.columnLayout()
cmds.rowColumnLayout( numberOfColumns=2, columnAttach=(3, 'right', 0), columnWidth=[(1, 100), (2, 250)] )
# Attach commands to pass focus to the next field if the Enter
# key is pressed. Hitting just the Return key will keep focus
# in the current field.
cmds.button( label='start Game',command=partial (self.startGame) ) #not sure if i need a start game button you will see later on if its needed or not.
cmds.rowColumnLayout( numberOfColumns=1, columnAttach=(3, 'right', 0), columnWidth=[(1, 100), (2, 250)] )
cmds.text(label='choose cup', align='center')
cmds.button(label='cup1',command=partial(self.chooseCup))
cmds.button(label='cup2',command=partial(self.chooseCup))
cmds.button(label='cup3',command=partial(self.chooseCup))
cmds.showWindow()
cmds.file(new=True,force=True)
getObj = cmds.file("F:/python/cupz.obj",i=True,type="OBJ",groupName=True)
def startGame(self,args=None): #animate objects with the start of the button
cmds.play( forward=True )
cmds.setKeyframe("cup_1.tx",t=0,v=0)
cmds.setKeyframe("cup_1.tz",t=0,v=0)
#
cmds.setKeyframe("cup_1.tx",t=100,v=0)
cmds.setKeyframe("cup_1.tz",t=100,v=0)
cmds.setKeyframe("cup_2.tx",t=0,v=0)
cmds.setKeyframe("cup_2.tz",t=0,v=0)
#
cmds.setKeyframe("cup_2.tx",t=100,v=0)
cmds.setKeyframe("cup_2.tz",t=100,v=0)
cmds.setKeyframe("cup_3.tx",t=0,v=0)
cmds.setKeyframe("cup_3.tz",t=0,v=0)
#
cmds.setKeyframe("cup_3.tx",t=100,v=0)
cmds.setKeyframe("cup_3.tz",t=100,v=0)
for x in range (0,100):
cmds.setKeyframe('cup_1.tx',t=x,v=m.sin(x)*15)
cmds.setKeyframe('cup_1.tz',t=x,v=m.cos(x)*13)
for x in range (1,100):
cmds.setKeyframe('cup_2.tx',t=x,v=m.cos(x)*18)
cmds.setKeyframe('cup_2.tz',t=x,v=m.sin(x)*12)
for x in range (1,100):
cmds.setKeyframe('cup_3.tx',t=x,v=m.sin(x)*15)
cmds.setKeyframe('cup_3.tz',t=x,v=m.cos(x)*13)
def chooseCup(self,cup):
chooseCup = "cup"
if cup == ('cup_1'):
cmds.setKeyframe("cup_1.ty",t=0,v=0)
cmds.setKeyframe("cup_1.tx",t=0,v=0)
cmds.setKeyframe("cup_1.ty",t=24,v=5)
cmds.setKeyframe("cup_1.rx",t=24,v=-25)
elif chooseCup: None
if cup == ('cup_2'):
cmds.setKeyframe("cup_2.ty",t=0,v=0)
cmds.setKeyframe("cup_2.tx",t=0,v=0)
cmds.setKeyframe("cup_2.ty",t=24,v=5)
cmds.setKeyframe("cup_2.rx",t=24,v=-25)
elif chooseCup: None
if cup == ('cup_3'):
cmds.setKeyframe("cup_3.ty",t=0,v=0)
cmds.setKeyframe("cup_3.tx",t=0,v=0)
cmds.setKeyframe("cup_3.ty",t=24,v=5)
cmds.setKeyframe("cup_3.rx",t=24,v=-25)
elif chooseCup: None
else :
print "out of range"
def hiddenBall(self,ball):
self.ball = cmds.polySphere()[0]
cmds.setKeyframe("ball",t=100,v=r.randiant)
inst = Shells() #creating an instance of a class
inst.createUI()
Aucun commentaire:
Enregistrer un commentaire