简体   繁体   中英

Type Error: Integer is required - Pygame , Python 2.7

I'm following a tutorial online , creating a button for pygame.

textSurf,textRect = smallfont.render(msg,color,size)

I've just started learning pygame yesterday.

I met with an error stating that "Type Error: Integer is require" . What does this mean? Can someone help me out?

The error is located at textSurf,textRect = smallfont.render(msg,color,size)

You're calling

textSurf,textRect = smallfont.render(msg,color,size)

...with a color as second parameter and "Small" as the third parameter, however the second and third parameter to render should be an antialiasing flag and a color in that order.

Since you have a function right above that translates "small" to the correct parameters to render, what you want is most likely;

textSurf,textRect = textObj(msg,color,size)

(although watch out for the casing of "Small" vs. "small")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM