How to fill the CCLayer with a background image?

44 Views Asked by At

After adding my image located in the resources I notice that my image appears only at the left bottom of the screen and in a reduced size.

How to fill the image as background on my CLLayer?

I tried adding the image as child and changed the Size of it's content but no success

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

enter image description here

1

There are 1 best solutions below

0
Junior Jiang On

You can set AnchorPoint to AnchorMiddle,then image can be in center of CCLayer:

CCSprite sprite = new CCSprite ("ship.png");
sprite.AnchorPoint = CCPoint.AnchorMiddle;
AddChild(sprite);

If want image fill the CCLayer,it seems like that there is no way to change size of sprite.So maybe need to change size of image to be more large.

https://learn.microsoft.com/en-us/xamarin/graphics-games/cocossharp/entities#creating-the-ship-entity