[英]I have a problem with pygame blit image. Image doesn't get my wanted position and direction. How can I solve?
對不起英語不好
by.x 是我的精靈 x position,by.y 是我的精靈 y position
我想圖像獲取我的精靈的 position 並獲取目標位置的方向。 我寫了這段代碼,但它不像我想要的那樣。
main_skill_image.blit(pygame.transform.rotate(main_skill_image,math.atan2(target_pos[1]-by.y,target_pos[0]-by.x)/math.pi*180 + 180),(by.x,by.y))
看這個問題你可以做這樣的事情:
angle = 360-math.atan2(pos[1]-by.x,pos[0]-by.y)*180/math.pi
mai_skill_image= pygame.transform.rotate(main_skill_image,angle)
沒測試過,如果不行,就測試一下,修復一下。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.