本文整理汇总了C#中CocosSharp.CCTouch类的典型用法代码示例。如果您正苦于以下问题:C# CCTouch类的具体用法?C# CCTouch怎么用?C# CCTouch使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CCTouch类属于CocosSharp命名空间,在下文中一共展示了CCTouch类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: onTouchMoved
void onTouchMoved(CCTouch touch, CCEvent touchEvent)
{
CCPoint touchLocation = touch.LocationOnScreen;
CCPoint nodePosition = Layer.ScreenToWorldspace(touchLocation);
m_test.MouseMove(new b2Vec2(nodePosition.X, nodePosition.Y));
}
示例2: OnTouchEnded
void OnTouchEnded(CCTouch touch, CCEvent touchEvent)
{
bool hits = touchHits(touch);
if (hits && Triggered != null)
Triggered(this, EventArgs.Empty);
scaleButtonTo(1);
}
示例3: onTouchBegan
bool onTouchBegan(CCTouch touch, CCEvent touchEvent)
{
if (m_state != PaddleState.kPaddleStateUngrabbed) return false;
if (!containsTouchLocation(touch)) return false;
m_state = PaddleState.kPaddleStateGrabbed;
return true;
}
示例4: OnTouchBegan
bool OnTouchBegan(CCTouch touch, CCEvent touchEvent)
{
bool hits = touchHits(touch);
if (hits)
scaleButtonTo(0.9f);
return hits;
}
示例5: OnTouchesEnded
public void OnTouchesEnded(List<CCTouch> touches, CCEvent touchEvent)
{
foreach (CCTouch touch in touches) {
if (touch == Touch) {
Touch = null;
return;
}
}
}
示例6: onTouchBegan
bool onTouchBegan(CCTouch touch, CCEvent touchEvent)
{
CCPoint touchLocation = touch.LocationOnScreen;
CCPoint nodePosition = Layer.ScreenToWorldspace(touchLocation);
// NSLog(@"pos: %f,%f -> %f,%f", touchLocation.x, touchLocation.y, nodePosition.x, nodePosition.y);
CCLog.Log("OnTouchBegan: " + nodePosition);
return m_test.MouseDown(new b2Vec2(nodePosition.X, nodePosition.Y));
}
示例7: onTouchBegan
bool onTouchBegan(CCTouch touch, CCEvent touchEvent)
{
CCPoint touchLocation = touch.Location;
CCPoint nodePosition = ConvertToNodeSpace(touchLocation);
// NSLog(@"pos: %f,%f -> %f,%f", touchLocation.x, touchLocation.y, nodePosition.x, nodePosition.y);
m_test.MouseDown(new Vector2(nodePosition.X, nodePosition.Y));
return true;
}
示例8: OnTouchesBegan
public void OnTouchesBegan(List<CCTouch> touches, CCEvent touchEvent)
{
foreach (CCTouch touch in touches) {
if (touch!=null) {
// AirHockey uses layer.ScreenToWorldspace(touch.LocationOnScreen)
if (BoundingBox.ContainsPoint(touch.Location)) {
Touch = touch;
return;
}
}
}
}
示例9: OnTouchEnded
public void OnTouchEnded(CCTouch touch, CCEvent e)
{
if (Enable)
{
foreach (var control in ControlList)
{
var p = control.PositionWorldspace;
var rect = new CCRect(p.X, p.Y, control.ContentSize.Width, control.ContentSize.Height);
if (rect.ContainsPoint(Target.Layer.ScreenToWorldspace(touch.LocationOnScreen)))
{
control.OnTouchEnded(touch, e);
return;
}
}
}
}
示例10: TouchMoved
public virtual void TouchMoved(CCTouch touch, CCEvent touchEvent)
{
if (!Visible)
{
return;
}
if (touches.Contains(touch))
{
if (touches.Count == 1 && Dragging)
{// scrolling
CCPoint moveDistance, newPoint; //, maxInset, minInset;
float newX, newY;
var frame = ViewRect;
newPoint = Layer.ScreenToWorldspace(touches[0].LocationOnScreen);
moveDistance = newPoint - touchPoint;
float dis = 0.0f;
if (Direction == CCScrollViewDirection.Vertical)
{
dis = moveDistance.Y;
}
else if (Direction == CCScrollViewDirection.Horizontal)
{
dis = moveDistance.X;
}
else
{
dis = (float)Math.Sqrt(moveDistance.X * moveDistance.X + moveDistance.Y * moveDistance.Y);
}
if (!IsTouchMoved && Math.Abs(ConvertDistanceFromPointToInch(dis)) < MOVE_INCH)
{
//CCLOG("Invalid movement, distance = [%f, %f], disInch = %f", moveDistance.x, moveDistance.y);
return;
}
if (!IsTouchMoved)
{
moveDistance = CCPoint.Zero;
}
touchPoint = newPoint;
IsTouchMoved = true;
if (frame.ContainsPoint(touchPoint))
{
switch (Direction)
{
case CCScrollViewDirection.Vertical:
moveDistance = new CCPoint(0.0f, moveDistance.Y);
break;
case CCScrollViewDirection.Horizontal:
moveDistance = new CCPoint(moveDistance.X, 0.0f);
break;
default:
break;
}
newX = container.Position.X + moveDistance.X;
newY = container.Position.Y + moveDistance.Y;
scrollDistance = moveDistance;
SetContentOffset(new CCPoint(newX, newY));
}
}
else if (touches.Count == 2 && !Dragging)
{
float len = CCPoint.Distance(Layer.ScreenToWorldspace(touches[0].LocationOnScreen),
Layer.ScreenToWorldspace(touches[1].LocationOnScreen));
ZoomScale = ZoomScale * len / touchLength;
}
}
}
示例11: TouchBegan
/** override functions */
public virtual bool TouchBegan(CCTouch pTouch, CCEvent touchEvent)
{
if (!Visible)
{
return false;
}
var frame = ViewRect;
//dispatcher does not know about clipping. reject touches outside visible bounds.
if (touches.Count > 2 ||
IsTouchMoved ||
!frame.ContainsPoint(container.Layer.ScreenToWorldspace(pTouch.LocationOnScreen)))
{
return false;
}
if (!touches.Contains(pTouch))
{
touches.Add(pTouch);
}
if (touches.Count == 1)
{
// scrolling
touchPoint = Layer.ScreenToWorldspace(pTouch.LocationOnScreen);
IsTouchMoved = false;
Dragging = true; //Dragging started
scrollDistance = CCPoint.Zero;
touchLength = 0.0f;
}
else if (touches.Count == 2)
{
touchPoint = CCPoint.Midpoint(Layer.ScreenToWorldspace(touches[0].LocationOnScreen), Layer.ScreenToWorldspace(touches[1].LocationOnScreen));
touchLength = CCPoint.Distance(container.Layer.ScreenToWorldspace(touches[0].LocationOnScreen), container.Layer.ScreenToWorldspace(touches[1].LocationOnScreen));
Dragging = false;
}
return true;
}
示例12: OnTouchMoved
void OnTouchMoved(CCTouch pTouch, CCEvent touchEvent)
{
CCPoint location = LocationFromTouch(pTouch);
SliderMoved(location);
}
示例13: IsTouchInside
public override bool IsTouchInside(CCTouch touch)
{
CCPoint touchLocation = touch.Location;
CCRect rect = BoundingBoxTransformedToWorld;
rect.Size.Width += ThumbSprite.ContentSize.Width;
rect.Origin.X -= ThumbSprite.ContentSize.Width / 2;
return rect.ContainsPoint(touchLocation);
}
示例14: OnTouchMoved
void OnTouchMoved(CCTouch touch, CCEvent touchEvent)
{
var touchLocation = touch.Location;
float nMoveY = touchLocation.Y - beginTouchPos.Y;
curPos = testListMenu.Position;
CCPoint nextPos = new CCPoint(curPos.X, curPos.Y + nMoveY);
CCRect visibleBounds = Layer.VisibleBoundsWorldspace;
if (nextPos.Y < 0.0f)
{
testListMenu.Position = new CCPoint(0, 0);
return;
}
if (nextPos.Y > (((int)TestCases.TESTS_COUNT + 1) * LINE_SPACE - visibleBounds.Size.Height))
{
testListMenu.Position = (new CCPoint(0, (((int)TestCases.TESTS_COUNT + 1) * LINE_SPACE - visibleBounds.Size.Height)));
return;
}
testListMenu.Position = nextPos;
beginTouchPos = touchLocation;
curPos = nextPos;
}
示例15: OnTouchBegan
private bool OnTouchBegan(CCTouch arg1, CCEvent arg2)
{
return (true);
}