本文整理汇总了C#中CocosSharp.CCEventListenerTouchAllAtOnce.Copy方法的典型用法代码示例。如果您正苦于以下问题:C# CCEventListenerTouchAllAtOnce.Copy方法的具体用法?C# CCEventListenerTouchAllAtOnce.Copy怎么用?C# CCEventListenerTouchAllAtOnce.Copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CocosSharp.CCEventListenerTouchAllAtOnce
的用法示例。
在下文中一共展示了CCEventListenerTouchAllAtOnce.Copy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StopPropagationTest
//.........这里部分代码省略.........
{
target.Opacity = 180;
return true;
}
// Stop propagation, so yellow blocks will not be able to receive event.
touchEvent.StopPropogation();
return false;
};
touchOneByOneListener.OnTouchEnded = (touch, touchEvent) =>
{
var target = (CCSprite)touchEvent.CurrentTarget;
target.Opacity = 255;
};
var touchAllAtOnceListener = new CCEventListenerTouchAllAtOnce();
touchAllAtOnceListener.OnTouchesBegan = (touches, touchEvent) =>
{
// Skip if don't touch top half screen.
if (IsPointInTopHalfAreaOfScreen(touches[0].LocationOnScreen))
return;
var target = (CCSprite)touchEvent.CurrentTarget;
Debug.Assert(target.Tag == TAG_BLUE_SPRITE2, "Yellow blocks shouldn't response event.");
if (IsPointInNode(touches[0].LocationOnScreen, target))
{
target.Opacity = 180;
}
// Stop propagation, so yellow blocks will not be able to receive event.
touchEvent.StopPropogation();
};
touchAllAtOnceListener.OnTouchesEnded = (touches, touchEvent) =>
{
// Skip if don't touch top half screen.
if (IsPointInTopHalfAreaOfScreen(touches[0].LocationOnScreen))
return;
var target = (CCSprite)touchEvent.CurrentTarget;
Debug.Assert(target.Tag == TAG_BLUE_SPRITE2, "Yellow blocks shouldn't response event.");
if (IsPointInNode(touches[0].LocationOnScreen, target))
{
target.Opacity = 255;;
}
// Stop propagation, so yellow blocks will not be able to receive event.
touchEvent.StopPropogation();
};
var keyboardEventListener = new CCEventListenerKeyboard();
keyboardEventListener.OnKeyPressed = (keyboardEvent) =>
{
var target = (CCSprite)keyboardEvent.CurrentTarget;
Debug.Assert(target.Tag == TAG_BLUE_SPRITE || target.Tag == TAG_BLUE_SPRITE2, "Yellow blocks shouldn't response event.");
// Stop propagation, so yellow blocks will not be able to receive event.
keyboardEvent.StopPropogation();
};
const int SPRITE_COUNT = 8;
for (int i = 0; i < SPRITE_COUNT; i++)
{
CCSprite sprite;
CCSprite sprite2;
if(i==4)
{
sprite = new CCSprite("Images/CyanSquare.png");
sprite.Tag = TAG_BLUE_SPRITE;
AddChild(sprite, 100);
sprite2 = new CCSprite("Images/CyanSquare.png");
sprite2.Tag = TAG_BLUE_SPRITE2;
AddChild(sprite2, 100);
}
else
{
sprite = new CCSprite("Images/YellowSquare.png");
AddChild(sprite, 0);
sprite2 = new CCSprite("Images/YellowSquare.png");
AddChild(sprite2, 0);
}
sprite.AddEventListener(touchOneByOneListener.Copy());
sprite.AddEventListener(keyboardEventListener.Copy());
sprite2.AddEventListener(touchAllAtOnceListener.Copy());
sprite2.AddEventListener(keyboardEventListener.Copy());
var visibleBounds = Layer.VisibleBoundsWorldspace;
sprite.Position = new CCPoint( visibleBounds.Origin.X + visibleBounds.Size.Width / (SPRITE_COUNT - 1) * i, visibleBounds.Center.Y + sprite2.ContentSize.Height/2 +10);
sprite2.Position = new CCPoint( visibleBounds.Origin.X + visibleBounds.Size.Width / (SPRITE_COUNT - 1) * i, visibleBounds.Center.Y - sprite2.ContentSize.Height/2-10);
}
}