栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何从Python的Sprite工作表中选择Sprite图片?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何从Python的Sprite工作表中选择Sprite图片?

我做了这个,您可能会感兴趣:

import pygame, sysfrom pygame.locals import *SCREEN_X=400SCREEN_Y=400#Screen sizeSPRT_RECT_X=0  SPRT_RECT_Y=0#This is where the sprite is found on the sheetLEN_SPRT_X=100LEN_SPRT_Y=100#This is the length of the spritescreen = pygame.display.set_mode((SCREEN_X, SCREEN_Y)) #Create the screensheet = pygame.image.load('C:YOURFILE') #Load the sheetsheet.set_clip(pygame.Rect(SPRT_RECT_X, SPRT_RECT_Y, LEN_SPRT_X, LEN_SPRT_Y)) #Locate the sprite you wantdraw_me = sheet.subsurface(sheet.get_clip()) #Extract the sprite you wantbackdrop = pygame.Rect(0, 0, SCREEN_X, SCREEN_Y) #Create the whole screen so you can draw on itscreen.blit(draw_me,backdrop) #'Blit' on the backdroppygame.display.flip()#Draw the sprite on the screen

希望我能帮上忙



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/625179.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号