本文整理汇总了Python中texture.Texture.getLeft方法的典型用法代码示例。如果您正苦于以下问题:Python Texture.getLeft方法的具体用法?Python Texture.getLeft怎么用?Python Texture.getLeft使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类texture.Texture
的用法示例。
在下文中一共展示了Texture.getLeft方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from texture import Texture [as 别名]
# 或者: from texture.Texture import getLeft [as 别名]
class Wall:
#-------------------------------------------------------------------------------------------------------
def __init__( self ):
self.bg_one = Texture( "wall/14.png" )
self.bg_two = Texture( "wall/14.png" )
#-------------------------------------------------------------------------------------------------------
def load( self ):
self.bg_two.setX( self.bg_two.getWidth() )
#-------------------------------------------------------------------------------------------------------
def draw( self, window, move = True, vel = 2 ):
if self.bg_one.getAlpha() == 255 and move:
self.bg_one.setX( self.bg_one.getLeft() - vel )
self.bg_two.setX( self.bg_two.getLeft() - vel )
if self.bg_one.getLeft() <= -self.bg_one.getWidth():
self.bg_one.setX( self.bg_one.getWidth() )
elif self.bg_two.getLeft() <= -self.bg_two.getWidth():
self.bg_two.setX( self.bg_two.getWidth() )
self.bg_one.draw( window )
self.bg_two.draw( window )
#-------------------------------------------------------------------------------------------------------
def getAlpha( self ):
return self.bg_two.getAlpha()
#-------------------------------------------------------------------------------------------------------
def fadein( self, i = 1, m = 255 ):
self.bg_one.fadein( i, m )
self.bg_two.fadein( i, m )
#-------------------------------------------------------------------------------------------------------
def fadeout( self, i = 1, m = 0 ):
self.bg_one.fadeout( i, m )
self.bg_two.fadeout( i, m )
示例2: __init__
# 需要导入模块: from texture import Texture [as 别名]
# 或者: from texture.Texture import getLeft [as 别名]
class Menu_score_log:
#-------------------------------------------------------------------------------------------------------
def __init__( self ):
self.sprite = Sprite( "menu/position.png", 4 )
self.window = Texture( "menu/window.png" )
self.click = pygame.mixer.Sound( "menu/click.wav" )
self.on = 0
self.type = 0
self.text = Text( "menu/KGHAPPY.ttf", 30 )
#-------------------------------------------------------------------------------------------------------
def load( self, x, width, titlebot, bot ):
self.sprite.setX( x )
self.sprite.setY( bot +10 )
self.window.setX( width/2 - self.window.getWidth()/2 )
self.window.setY( titlebot -20 )
self.text.createText( "SCORES", [ 0xd5, 0xad, 0x51 ] )
self.text.setX( self.window.getLeft() + self.window.getWidth()/2 - self.text.getWidth()/2 )
self.text.setY( self.window.getTop() +50 )
#-------------------------------------------------------------------------------------------------------
def draw( self, screen ):
if self.type == 1:
self.window.draw( screen )
self.text.draw( screen )
else:
self.sprite.draw( screen )
#-------------------------------------------------------------------------------------------------------
def fadein( self, i = 1, m = 255 ):
self.sprite.fadein( i, m )
self.window.fadein( i, m )
self.text.fadein( i, m )
#-------------------------------------------------------------------------------------------------------
def fadeout( self, i = 1, m = 0 ):
self.sprite.fadeout( i, m )
self.window.fadeout( i, m )
self.text.fadeout( i, m )
#-------------------------------------------------------------------------------------------------------
def getState( self ):
return self.type
#-------------------------------------------------------------------------------------------------------
def getRight( self ):
return self.sprite.getRight()
#-------------------------------------------------------------------------------------------------------
def setState( self ):
if self.on == 0:
self.on = 1
else:
self.on = 0
#-------------------------------------------------------------------------------------------------------
def handle( self, event ):
self.focus = False
if event.type == pygame.MOUSEBUTTONDOWN:
self.focus = True
if self.type == 0:
self.sprite.setOffset( 0 )
self.x, self.y = pygame.mouse.get_pos()
if self.x > self.sprite.getLeft() and self.x < self.sprite.getRight() and self.sprite.getAlpha() == 255:
if self.y > self.sprite.getTop() and self.y < self.sprite.getBot():
if self.focus == True:
if self.on == 0:
self.click.play()
self.sprite.setOffset( 2 )
if self.type == 0:
self.type = 1
else:
self.sprite.setOffset( 1 )
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE or event.key == pygame.K_SPACE:
if self.type == 1:
if self.on == 0:
self.click.play()
self.type = 0