Trying to use only a portion of a SKTexture using textureWithRect inTexture

自闭症网瘾萝莉.ら 提交于 2019-12-10 23:55:13

问题


What I'm doing is create a SKTexture based on the full image

SKTexture *fullTexture = [SKTexture textureWithImageNamed:@"fullImage"];

I want to use the full width of the fullTexture, but only a portion of height of the texture, BUT, starting from the TOP of the full image.

After figuring out that the width seems to be in percentage, I used the following code:

SKTexture *croppedTexture = [SKTexture textureWithRect: CGRectMake(0,0,1,percentageY)

can somebody give me the correct float values for CGRectMake to CROP, beginning from the TOP LEFT, with full witdt and only a portion (fixed number of points/pixels) from the Y ?

OR another way to achieve what I am trying to do?

Thanks

Updated the question with visible example of what I need:


回答1:


Try CGRectMake(0,1-percentageY,1,percentageY) instead of CGRectMake(0,0,1,percentageY)



来源:https://stackoverflow.com/questions/21874822/trying-to-use-only-a-portion-of-a-sktexture-using-texturewithrect-intexture

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!