【发布时间】:2019-06-13 02:07:58
【问题描述】:
将我的图片添加到资源中后,我注意到我的图片只出现在屏幕的左下角并且尺寸缩小了。
如何在我的 CLLayer 上填充图像作为背景?
我尝试将图像添加为子图像并更改其内容的大小但没有成功
CCSprite sprite = new CCSprite("img.png");
AddChild(sprite);
【问题讨论】:
标签: xamarin cocossharp
将我的图片添加到资源中后,我注意到我的图片只出现在屏幕的左下角并且尺寸缩小了。
如何在我的 CLLayer 上填充图像作为背景?
我尝试将图像添加为子图像并更改其内容的大小但没有成功
CCSprite sprite = new CCSprite("img.png");
AddChild(sprite);
【问题讨论】:
标签: xamarin cocossharp
您可以将AnchorPoint设置为AnchorMiddle,则图像可以在CCLayer的中心:
CCSprite sprite = new CCSprite ("ship.png");
sprite.AnchorPoint = CCPoint.AnchorMiddle;
AddChild(sprite);
如果想要图像填充CCLayer,似乎没有办法改变精灵的大小。所以可能需要将图像的大小更改为更大。
https://docs.microsoft.com/en-us/xamarin/graphics-games/cocossharp/entities#creating-the-ship-entity
【讨论】: