尝试使用textureWithRect inTexture仅使用SKTexture的一部分 [英] Trying to use only a portion of a SKTexture using textureWithRect inTexture

查看:129
本文介绍了尝试使用textureWithRect inTexture仅使用SKTexture的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做的是基于完整图像创建SKTexture

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

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

我想使用fullTexture的整个宽度,但只使用一部分纹理高度,但是,从完整图像的顶部开始。

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)

有人可以给我正确的CGRectMake到float值,从TOP LEFT开始,有完整的witdt,只有一部分(固定的点数/像素)是Y?

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?

谢谢

用我需要的可见示例更新了问题:

Updated the question with visible example of what I need:

推荐答案

尝试 CGRectMake (0,1-percentageY,1,percentageY)而不是 CGRe ctMake(0,0,1,percentageY)

这篇关于尝试使用textureWithRect inTexture仅使用SKTexture的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆