xamarin - 如何用背景图像填充 CCLayer?
问题描述
在资源中添加我的图像后,我注意到我的图像仅出现在屏幕的左下角并且尺寸减小了。
如何在我的 CLLayer 上填充图像作为背景?
我尝试将图像添加为子图像并更改其内容的大小但没有成功
CCSprite sprite = new CCSprite("img.png");
AddChild(sprite);
解决方案
您可以设置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
推荐阅读
- amazon-web-services - 是否可以使用 AWS 开发工具包将对象从源 S3 复制到目标 S3 中的特定路径?
- makefile - 发生错误后如何继续中断编译?
- algorithm - 双向链表的分区排序
- php - Ubuntu错误的oci8.so路径
- python - Pandas 为不同的机器给出不同的结果
- symfony - 供应商捆绑控制器自动加载以供使用注释
- r - 你如何从字符串列表中将评估的 ggplots 存储在 R 中?
- javascript - 这个“if 语句”不应该导致反弹吗?
- c++ - Zero Initialize a Type
- r - StMoMo 包和自举函数