本文整理汇总了Python中scene.Scene.sprites方法的典型用法代码示例。如果您正苦于以下问题:Python Scene.sprites方法的具体用法?Python Scene.sprites怎么用?Python Scene.sprites使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scene.Scene
的用法示例。
在下文中一共展示了Scene.sprites方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from scene import Scene [as 别名]
# 或者: from scene.Scene import sprites [as 别名]
def main():
import scene
from scene import Scene
game = Scene()
grassBackground = Grass()
game.sprites = [grassBackground]
game.start()
示例2: __animateUp
# 需要导入模块: from scene import Scene [as 别名]
# 或者: from scene.Scene import sprites [as 别名]
def __animateUp(self):
#print("ANIMATING UP")
print("CurrentIndex: ", self.currentFrameIndex, " TotalFrames: ", len( self.frames ) )
if (self.currentFrameIndex < len( self.frames ) - 1 ):
self.currentFrameIndex += 1
print("New Index", self.currentFrameIndex)
def __animateDown(self):
#print("ANIMATING DOwn")
if (self.currentFrameIndex > 0 ):
self.currentFrameIndex -=1
def __updateAnimationState(self):
#print("UPDATE ANIMATION STATE")
if( self.currentFrameIndex == 0 ):
self.status = self.INACTIVE
elif( self.currentFrameIndex >= len( self.frames )-1 ):
self.status = self.GOING_DOWN
if __name__ == "__main__":
import scene
from scene import Scene
from Girl import Girl
game = Scene()
buford = Buford()
buford.setImage("buford.gif")
girl = Girl()
girl.setImage("girl.png");
game.sprites = [buford, girl]
game.start()
示例3: print
# 需要导入模块: from scene import Scene [as 别名]
# 或者: from scene.Scene import sprites [as 别名]
""" boolean function. Returns True if the mouse is
clicked over the sprite, False otherwise
"""
self.pressed = False
if pygame.mouse.get_pressed() == (1, 0, 0):
if self.rect.collidepoint(pygame.mouse.get_pos()):
print("MOUSE DOWN")
self.pressed = True
return self.pressed
def clicked(self):
""" Boolean function. Returns True only if mouse
is pressed and released over sprite
"""
released = False
if self.pressed:
if pygame.mouse.get_pressed() == (0, 0, 0):
if self.rect.collidepoint(pygame.mouse.get_pos()):
print("CLICKED!")
released = True
return released
if __name__ == "__main__":
import scene
from scene import Scene
game = Scene()
girl = Girl()
game.sprites = [girl]
girl.setImage("girl.png")
game.start()
示例4: __updateAnimationState
# 需要导入模块: from scene import Scene [as 别名]
# 或者: from scene.Scene import sprites [as 别名]
def __updateAnimationState(self):
#print("UPDATE ANIMATION STATE")
if( self.currentFrameIndex == 0 ):
self.status = self.INACTIVE
elif( self.currentFrameIndex >= len( self.frames )-1 ):
self.status = self.GOING_DOWN
def popUp(self):
print ("POP UP")
self.status = self.GOING_UP
def popDown(self):
print ("POP DOWN")
self.status = self.GOING_DOWN
if __name__ == "__main__":
import scene
from scene import Scene
from Girl import Girl
from Buford import Buford
game = Scene()
buford = Buford()
buford.setImage("buford.gif")
girl = Girl()
girl.setImage("girl.png")
chasingNeeb = ChasingNeeb()
chasingNeeb.setImage("neeb_still.gif")
game.sprites = [buford, girl, chasingNeeb]
game.start()
示例5: print
# 需要导入模块: from scene import Scene [as 别名]
# 或者: from scene.Scene import sprites [as 别名]
self.neebSprites_[x].x = 0 + change
self.neebSprites_[x].y = 0
change += 10
self.neebGroup_ = pygame.sprite.Group( self.neebSprites_ )
print("DONE")
def checkCollision(self):
print("COLLIISION")
print("AGAIN")
for neeb in self.neebSprites_:
collidedNeeb = pygame.sprite.spritecollideany(neeb, self.neebGroup_)
if collidedNeeb is not None:
neeb.x += collidedNeeb.width
neeb.y += collidedNeeb.height
print("New Neeb Location (", neeb.x,",", neeb.y,")" )
if __name__ == "__main__":
import scene
from scene import Scene
game = Scene()
neebs = NeebDepot()
neebs.generateSprites(5)
game.sprites = [ neebs.neebSprites() ]
for x in range(5):
neebs.checkCollision()
game.start()