本文整理汇总了C#中CocosSharp.CCSprite.RemoveFromParent方法的典型用法代码示例。如果您正苦于以下问题:C# CCSprite.RemoveFromParent方法的具体用法?C# CCSprite.RemoveFromParent怎么用?C# CCSprite.RemoveFromParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CocosSharp.CCSprite
的用法示例。
在下文中一共展示了CCSprite.RemoveFromParent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnEnter
public override void OnEnter ()
{
spriteSaved = false;
base.OnEnter ();
var origin = Layer.VisibleBoundsWorldspace.Origin;
var size = Layer.VisibleBoundsWorldspace.Size;
//MenuItemFont::setFontSize(20);
var sprite = new CCSprite("Images/CyanSquare.png");
sprite.Position = origin + size.Center;
AddChild(sprite, 10);
// Make sprite1 touchable
var listener1 = new CCEventListenerTouchOneByOne ();
listener1.IsSwallowTouches = true;
listener1.OnTouchBegan = (touch, touchEvent) =>
{
var target = (CCSprite) touchEvent.CurrentTarget;
var locationInNode = target.Layer.ScreenToWorldspace(touch.LocationOnScreen);
var s = target.ContentSize;
var rect = new CCRect(0, 0, s.Width, s.Height);
if (rect.ContainsPoint(locationInNode))
{
CCLog.Log("sprite began... x = {0}, y = {1}", locationInNode.X, locationInNode.Y);
target.Opacity = 180;
return true;
}
return false;
};
listener1.OnTouchMoved = (touch, touchEvent) =>
{
var target = (CCSprite) touchEvent.CurrentTarget;
target.Position += touch.Delta;
};
listener1.OnTouchEnded = (touch, touchEvent) =>
{
var target = (CCSprite) touchEvent.CurrentTarget;
CCLog.Log("sprite onTouchesEnded.. ");
target.Opacity = 255;
};
sprite.AddEventListener(listener1);
RunActions(new CCDelayTime(5.0f),
new CCCallFunc(() =>
{
spriteSaved = true;
sprite.RemoveFromParent();
}),
new CCDelayTime(5.0f),
new CCCallFunc(() =>
{
spriteSaved = false;
AddChild(sprite);
})
);
}