creating sprite mask - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Game Development (https://python-forum.io/forum-11.html) +--- Thread: creating sprite mask (/thread-18418.html) |
creating sprite mask - pfaber11 - May-16-2019 Hi trying to create a mask for a sprite . this is what I found sprite.mask = pygame.mask.from_surface(sprite.image) My question is what do I put here (sprite.image)? And sprite.mask at the beginning can it be changed to say image3.mask? RE: creating sprite mask - SheeppOSU - May-17-2019 Try testing it out, then come back if you need help RE: creating sprite mask - pfaber11 - May-17-2019 Hi decided to try doing the collision just using rect for now this is my code for it . It runs but does not detect a hit when the two sprites collide . Any help would be much appreciated . Quote:image1=pygame.sprite.Sprite() I have edited this post to include the mask code . If I replace .image with _rect or .mask the code will not run . Help needed please . RE: creating sprite mask - SheeppOSU - May-18-2019 For the colliding - https://www.pygame.org/project-Rect+Collision+Response-1061-.html One more thing - Any errors? RE: creating sprite mask - metulburr - May-20-2019 (May-16-2019, 07:13 PM)pfaber11 Wrote: My question is what do I put here (sprite.image)?replace sprite.image with what is returned by pygame.image.load('image_name.png') it doesnt have to be sprite.mask. You can just do mask. They are just informing that what is returned is a sprite.mask / sprite.image (not that you have to name them anything like that). (May-17-2019, 05:31 PM)pfaber11 Wrote: It runs but does not detect a hit when the two sprites collide .You do not show any code referring to your collision detection, so we could not know. RE: creating sprite mask - pfaber11 - Jun-12-2019 Thanks for all the replies got it sorted now I am new to python but am learning as I go . |