我编写了一个运行Mario的动画,我从外部模块导入我的动画:
from Tkinter import *
from ObjectMario import Mario1, Mario2, Mario3
from ObjectMarioBlocks import Ground, Platform, Question1, Question2, Coin
import winsound
import os
我想要做的是翻转图像以使他能够向后跑。我想知道是否有某种方法可以通过一些命令实现这一点,我可以翻阅" yaxis"。
每个导入的对象如下所示: 名为ObjectMarioBlocks
来自Tkinter import *
课程地面:
# class attributes
objectName = "MarioGround" # Title for this object
objectNum = 0 # Number of instances created
#######################################################################
# __init__ constructor #
# #
# Initializes all attributes to given parameters. #
# Calcualtes the tag attribute #
# Increments the count class attribute. #
#######################################################################
def __init__ (self, canvas, left=0,top=0,width=100,height=100):
# attributes from parameters
self.c = canvas
self.left = left
self.top = top
self.width = width
# calculated attributes
self.tag = Ground.objectName + str(Ground.objectNum)
Ground.objectNum += 1
self.right = self.left + self.width
self.bottom = self.top + self.width
self.center = (self.left + self.right) / 2.0
self.middle = (self.top + self.bottom) / 2.0
#######################################################################
# draw method #
# #
# Draws the face according to the attributes, including position, #
# size, and colors. #
#######################################################################
def draw(self):
# create X-coordinate grid
xspaces = 30 # number of coordinates in the guide list
gridwidth = 1.0 * self.width / xspaces
x = []
for i in range(xspaces+1):
x.append(self.left + i*gridwidth)
# create Y-coordinate grid
yspaces = 20 # number of coordinates in the guide list
gridheight = 1.0 * self.width / yspaces
y = []
for i in range(yspaces+1):
y.append(self.top + i*gridheight)
# definfleftsquare
leftsquare = ( (x[0],y[0]) , (x[20],y[20]) )
# definetopsquare
topsquare = ( (x[20],y[0]) , (x[30],y[10]) )
# definebottomsquare
bottomsquare = ( (x[20],y[10]) , (x[30],y[20]) )
# draw leftsquare
self.c.create_rectangle(leftsquare, fill="Orangered2", width=5)
# draw topsquare
self.c.create_rectangle(topsquare, fill="Orangered2", width=5)
# draw bottomsquare
self.c.create_rectangle(bottomsquare, fill="Orangered2", width=5)
# update canvas, if running an animation
self.c.update()
动画导入类然后在动画中运行它们