本文整理汇总了Python中sprite.Sprite.fadein方法的典型用法代码示例。如果您正苦于以下问题:Python Sprite.fadein方法的具体用法?Python Sprite.fadein怎么用?Python Sprite.fadein使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sprite.Sprite
的用法示例。
在下文中一共展示了Sprite.fadein方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from sprite import Sprite [as 别名]
# 或者: from sprite.Sprite import fadein [as 别名]
class Menu_play_button:
#-------------------------------------------------------------------------------------------------------
def __init__( self ):
self.text = Text( "menu/KGHAPPY.ttf", 80 )
self.sprite = Sprite( "menu/blankbutton.png", 4 )
self.click = pygame.mixer.Sound( "menu/click.wav" )
self.next = 0
self.on = 0
self.mouseup = 0
#-------------------------------------------------------------------------------------------------------
def load( self, width, height ):
self.text.createText( "play", [ 0x82, 0xae, 0x20 ] )
self.text.setX( width/2 - self.text.getWidth()/2 )
self.text.setY( height/2 - self.text.getHeight()/2 -10 +120 )
self.sprite.setX( width/2 - self.sprite.getWidth()/2 )
self.sprite.setY( height/2 - self.sprite.getHeight()/2 +120 )
#-------------------------------------------------------------------------------------------------------
def draw( self, window ):
self.sprite.draw( window )
self.text.draw( window )
#-------------------------------------------------------------------------------------------------------
def fadein( self, i = 1, m = 255 ):
self.sprite.fadein( i, m )
self.text.fadein( i, m )
#-------------------------------------------------------------------------------------------------------
def fadeout( self, i = 1, m = 0 ):
self.sprite.fadeout( i, m )
self.text.fadeout( i, m )
#-------------------------------------------------------------------------------------------------------
def setState( self ):
if self.on == 0:
self.on = 1
else:
self.on = 0
#print self.on
#-------------------------------------------------------------------------------------------------------
def handle( self, event ):
self.focus = False
if event.type == pygame.MOUSEBUTTONDOWN:
self.focus = True
self.mouseup = 1
elif event.type == pygame.MOUSEBUTTONUP:
self.mouseup = 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.next = 1
if self.focus == True or self.mouseup == 1:
self.sprite.setOffset( 2 )
else:
self.sprite.setOffset( 1 )
#-------------------------------------------------------------------------------------------------------
def getAlpha( self ):
return self.sprite.getAlpha()
#-------------------------------------------------------------------------------------------------------
def getState( self ):
return self.next
#-------------------------------------------------------------------------------------------------------
def setNext( self, n ):
self.next = n
#-------------------------------------------------------------------------------------------------------
def getLeft( self ):
return self.sprite.getLeft()
#-------------------------------------------------------------------------------------------------------
#.........这里部分代码省略.........
示例2: __init__
# 需要导入模块: from sprite import Sprite [as 别名]
# 或者: from sprite.Sprite import fadein [as 别名]
class Hero:
#-------------------------------------------------------------------------------------------------------
def __init__( self ):
self.hero = Sprite( "hero/0.png", 8 )
self.hero.setOffset( 4 )
self.move = 8
self.delay = 2
self.startstate = 0
self.stateD = False
self.stateA = False
self.stateSpace = False
self.spacecounter = 0
#-------------------------------------------------------------------------------------------------------
def load( self, width, height ):
self.hero.setX( 0 )
self.hero.setY( height - 130 - self.hero.getHeight() )
self.minX = width/4
self.maxX = width*4/5
#-------------------------------------------------------------------------------------------------------
def draw( self, window ):
if self.hero.getAlpha() == 255:
if self.startstate == 0:
if self.hero.getX() < self.minX:
self.hero.setX( self.hero.getX() + 3 )
else:
self.startstate = 1
else:
if self.stateD and self.hero.getRight() < self.maxX:
self.hero.setX( self.hero.getX() + 7 )
elif self.hero.getRight() >= self.maxX:
self.stateD = False
if self.hero.getX() > self.minX +5:
self.hero.setX( self.hero.getX() - 3 )
if self.stateA and self.hero.getX() > self.minX +5:
self.hero.setX( self.hero.getX() - 4 )
self.move += 1
if self.move >= 4 * self.delay:
self.move = 0
self.hero.setOffset( self.move / self.delay )
self.hero.draw( window )
#-------------------------------------------------------------------------------------------------------
def handle( self, event ):
if self.startstate == 1:
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_d:
self.stateD = True
elif event.key == pygame.K_a:
self.stateA = True
if event.key == pygame.K_SPACE:
self.stateSpace = True
elif event.type == pygame.KEYUP:
if event.key == pygame.K_d:
self.stateD = False
elif event.key == pygame.K_a:
self.stateA = False
if event.key == pygame.K_SPACE:
self.stateSpace = False
#-------------------------------------------------------------------------------------------------------
def fadein( self, i = 1, m = 255 ):
self.hero.fadein( i, m )
#-------------------------------------------------------------------------------------------------------
def fadeout( self, i = 1, m = 0 ):
self.hero.fadeout( i, m )
示例3: __init__
# 需要导入模块: from sprite import Sprite [as 别名]
# 或者: from sprite.Sprite import fadein [as 别名]
class Menu_music_button:
#-------------------------------------------------------------------------------------------------------
def __init__( self, path, on = 0 ):
self.sprite = Sprite( path, 4 )
self.scratch = Texture( "menu/scratch.png" )
self.click = pygame.mixer.Sound( "menu/click.wav" )
self.type = 0
self.state = 0
self.on = on
self.mouseup = 0
#-------------------------------------------------------------------------------------------------------
def load( self, y ):
self.sprite.setX( 10 )
self.sprite.setY( y )
self.scratch.setX( 10 )
self.scratch.setY( y )
#-------------------------------------------------------------------------------------------------------
def getBot( self ):
return self.sprite.getBot()
#-------------------------------------------------------------------------------------------------------
def draw( self, window ):
self.sprite.draw( window )
if self.type == 1:
self.scratch.draw( window )
#-------------------------------------------------------------------------------------------------------
def fadein( self, i = 1, m = 255 ):
self.sprite.fadein( i, m )
self.scratch.fadein( i, m )
#-------------------------------------------------------------------------------------------------------
def fadeout( self, i = 1, m = 0 ):
self.sprite.fadeout( i, m )
self.scratch.fadeout( i, m )
#-------------------------------------------------------------------------------------------------------
def getState( self ):
if self.state != self.type:
self.state = self.type
#print "true!"
return True
return False
#-------------------------------------------------------------------------------------------------------
def setState( self ):
if self.on == 0:
self.on = 1
else:
self.on = 0
# print self.on
#-------------------------------------------------------------------------------------------------------
def handle( self, event ):
self.focus = False
self.sprite.setOffset( 0 )
if event.type == pygame.MOUSEBUTTONDOWN:
self.focus = True
self.mouseup = 1
elif event.type == pygame.MOUSEBUTTONUP:
self.mouseup = 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()
if self.type == 0:
self.type = 1
else:
self.type = 0
if self.focus == True or self.mouseup == 1:
self.sprite.setOffset( 2 )
else:
self.sprite.setOffset( 1 )
示例4: __init__
# 需要导入模块: from sprite import Sprite [as 别名]
# 或者: from sprite.Sprite import fadein [as 别名]
class Menu_link_button:
#-------------------------------------------------------------------------------------------------------
def __init__( self, path, url, locked = False ):
self.sprite = Sprite( path, 4 )
self.url = url
self.locked = locked
if locked == True:
self.sprite.setOffset( 3 )
self.click = pygame.mixer.Sound( "menu/click.wav" )
self.on = 0
#-------------------------------------------------------------------------------------------------------
def load( self, width, y, flag = False ):
if flag:
self.sprite.setX( width )
else:
self.sprite.setX( width - self.sprite.getWidth() -10 )
self.sprite.setY( y )
#-------------------------------------------------------------------------------------------------------
def getBot( self ):
return self.sprite.getBot()
#-------------------------------------------------------------------------------------------------------
def draw( self, window ):
self.sprite.draw( window )
#-------------------------------------------------------------------------------------------------------
def getRight( self ):
return self.sprite.getRight()
#-------------------------------------------------------------------------------------------------------
def setState( self ):
if self.on == 0:
self.on = 1
else:
self.on = 0
# print self.on
#-------------------------------------------------------------------------------------------------------
def fadein( self, i = 1, m = 255 ):
self.sprite.fadein( i, m )
#-------------------------------------------------------------------------------------------------------
def fadeout( self, i = 1, m = 0 ):
self.sprite.fadeout( i, m )
#-------------------------------------------------------------------------------------------------------
def handle( self, event ):
if self.locked == False and self.sprite.getAlpha() == 255:
self.sprite.setOffset( 0 )
self.focus = False
if event.type == pygame.MOUSEBUTTONDOWN:
self.focus = True
self.x, self.y = pygame.mouse.get_pos()
if self.x > self.sprite.getLeft() and self.x < self.sprite.getRight():
if self.y > self.sprite.getTop() and self.y < self.sprite.getBot():
if self.focus == True:
if self.on == 0:
self.click.play()
# print "CLICK!"
self.sprite.setOffset( 2 )
webbrowser.open_new_tab( self.url )
else:
self.sprite.setOffset( 1 )
示例5: __init__
# 需要导入模块: from sprite import Sprite [as 别名]
# 或者: from sprite.Sprite import fadein [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