【问题标题】:How to fill the CCLayer with a background image?如何用背景图像填充 CCLayer?
【发布时间】:2019-06-13 02:07:58
【问题描述】:

将我的图片添加到资源中后,我注意到我的图片只出现在屏幕的左下角并且尺寸缩小了。

如何在我的 CLLayer 上填充图像作为背景?

我尝试将图像添加为子图像并更改其内容的大小但没有成功

  CCSprite sprite = new CCSprite("img.png");
  AddChild(sprite);

【问题讨论】:

    标签: xamarin cocossharp


    【解决方案1】:

    您可以将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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-02-12
      • 2019-01-28
      • 2011-12-26
      • 2018-10-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-28
      相关资源
      最近更新 更多