gpt4 book ai didi

android - Cocos2d-Android - Sprite.getcontentsize , Sprite.getscale , Sprite.gettexture 有什么区别

转载 作者:行者123 更新时间:2023-11-29 21:14:32 25 4
gpt4 key购买 nike

标题说明了一切。我想知道 Sprite.getcontentsize、Sprite.gettexture、Sprite.getscale 之间有什么区别。以及它们是如何使用的。在这个问题之后我找不到任何资源。

最佳答案

例如,我们有一张名为“test.png”、宽度为 100 像素、高度为 200 像素的图像。然后:

CCSprite testImage = CCSprite.sprite("test.png");

// print original image size
System.out.println("" + testImage.getContentSize().width + ", " + testImage.getContentSize().height); // print: 100, 200

// print actual image size
System.out.println("" + testImage.getBoundingBox().size.width + ", " + testImage.getBoundingBox().size.height); // print: 100, 200

// this will change resolution of image to half, so it will be drawn 2x smaller then original size
testImage.setScale(0.5f);

// print how many is image scaled
System.out.println("" + testImage.getScale()); // print: O.5

// print original image size
System.out.println("" + testImage.getContentSize().width + ", " + testImage.getContentSize().height); // print: 100, 200
// print actual image size
System.out.println("" + testImage.getBoundingBox().size.width + ", " + testImage.getBoundingBox().size.height); // print: 50, 100

testImage.gettexture() 可能会返回加载的纹理/图像,但我不知道,我从来不需要使用这个函数。

关于android - Cocos2d-Android - Sprite.getcontentsize , Sprite.getscale , Sprite.gettexture 有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21793870/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com