Hello -
Sorry if this is a dumb question, it’s late and think I’m going nuts trying to understand why this won’t work; I’ve got what seems to be a bitmap and 4 integers but it keeps telling me it’s invalid…?
Your bitmap is only 137 x 205 but you are trying to create a region that starts at 1297,440, way outside the bounds of the bitmap. A region must lie entirely within the bounds of its bitmap.
Thanks Mark.
Now I’m struggling to understand the difference between the sprite and the region from ‘sprite.GetRegion()’; specifically, my sprite has non-zero X and Y values but the region from sprite.GetRegion() does not have those.
sprite = spriteObj.sprite
print "here is the sprite x " + sprite.Getx().ToStr()
print "here is the sprite y " + sprite.GetY().ToStr()
oldRegion = sprite.GetRegion()
print "oldRegion data: " + chr(10) + oldRegion.ifRegion.GetX().ToStr() + chr(10) + oldRegion.ifRegion.GetY().ToStr() + chr(10) + oldRegion.ifRegion.GetWidth().ToStr() + chr(10) + oldRegion.ifRegion.GetHeight().ToStr() +chr(10)
And here is the output from that
here is the sprite x 157
here is the sprite y 440
oldRegion data:
0
0
137
205
Why does the roRegion not get the same X and Y values as the parent sprite? tyvmia
Your question is still related to Joel’s answer. A region is located inside of a bitmap and cannot extend beyond the bounds of its bitmap. So your regions x and y positions would reflect the positions you created the region at. If you offset your region then those coordinates will change inside of the bitmap. Now a sprites x and y are where you locate it on the screen. It has nothing to do with the regions x,y. Like taking a picture of a landscape. The picture is a region or portion of the landscape and the Sprite would be the picture frame that you can hang anywhere on the wall. The pictures x y is where you took the picture in relation to the landscape. The sprites x,y is the location you hung the picture on the wall
“NewManLiving” wrote:
Your question is still related to Joel’s answer. A region is located inside of a bitmap and cannot extend beyond the bounds of its bitmap. So your regions x and y positions would reflect the positions you created the region at. If you offset your region then those coordinates will change inside of the bitmap. Now a sprites x and y are where you locate it on the screen. It has nothing to do with the regions x,y. Like taking a picture of a landscape. The picture is a region or portion of the landscape and the Sprite would be the picture frame that you can hang anywhere on the wall. The pictures x y is where you took the picture in relation to the landscape. The sprites x,y is the location you hung the picture on the wall
Thank you for the explanation. Ultimately I just want to replace a sprite with a new image. Is there a way to do that?
“NewManLiving” wrote:
Yes the sprites SetRegion
Thanks but now I’m going in circles; I was trying to use SetRegion when I could not create a valid region, which is what got me posting originally. Is there any way you could elaborate? How do I set the region if I can’t get a valid region from the sprite’s region?
Update: OK I think I actually have this part and the trouble is that my images are not actually caching the bitmaps; in my bitmap object I see
status : FAILED
bitmap : invalid
Well thanks for your help NML!
Update: I got it working, thanks again Mark and NewManLiving!