我使用了这段代码在CCLayer中添加背景图像,但它不起作用:
public class GameLayer : CCLayerColor
{
private CCSprite background;
public GameLayer() : base(CCColor4B.Transparent)
{
background = new CCSprite("cbg")
{
AnchorPoint = new CCPoint(0, 0),
IsAntialiased = true,
Position = new CCPoint(0, 0),
};
this.AddChild(background);
}
}我的问题是,图像显示而不是屏幕大小作为背景图像,它只是显示在屏幕的左下角。
编辑:
解决了:为了解决这个问题,我将Contnetsize添加到我的图像中,与屏幕大小相同。
发布于 2018-08-08 09:35:13
下面是我用来显示背景的代码:
var sprite = new CCSprite("bg.jpg");
sprite.AnchorPoint = new CCPoint(0, 0);
sprite.IsAntialiased = false;
layer.AddChild(sprite);几乎相同的代码,但CocosSharp有时会有奇怪的行为。
https://stackoverflow.com/questions/51557803
复制相似问题