bool OnTouchBegan(CCTouch touch, CCEvent touchEvent) { CCSprite caller = touchEvent.CurrentTarget as CCSprite; if (caller.Tag == SpriteTypes.IconTag) { ReorderChild(caller, 999); } CurrentSpriteTouched = null; touchType = Tags.Tag.None; startTime = DateTime.Now; if (windowFrame != null) { if (windowFrame.BoundingBoxTransformedToWorld.ContainsPoint(touch.Location)) { if (closeButton.BoundingBoxTransformedToWorld.ContainsPoint(touch.Location)) { isModal = false; var scaleAction = new CCScaleTo(0.2f, 0.05f); var functionAction = new CCCallFunc(ClearWindow); windowFrame.AddActions(false, scaleAction, functionAction); return(true); } var mIcons = windowFrame.Children; foreach (var mIcon in mIcons) { if (mIcon.Tag == SpriteTypes.IconTag && mIcon.BoundingBoxTransformedToWorld.ContainsPoint(touch.Location)) { touchType = Tags.Tag.TransitionIcon; var mContent = mIcon.GetChildByTag(SpriteTypes.ContentTag) as CCLabel; if (mContent != null) { StoredIconReference mStoredRef = null; foreach (StoredIconReference storedRef in storedList) { var mLoopSprite = storedRef.Sprite; var mLoopContent = mLoopSprite.GetChildByTag(SpriteTypes.ContentTag) as CCLabel; if (mLoopContent != null && mLoopContent.Text == mContent.Text) { var xMin = (spriteModelFactory.DynamicHeight * 0.1f) / 2; var yLocation = mRandom.Next((int)(spriteModelFactory.DynamicHeight * 0.3f), (int)(spriteModelFactory.DynamicHeight - (spriteModelFactory.DynamicHeight * 0.3f))); var xLocation = mRandom.Next((int)(spriteModelFactory.DynamicWidth * 0.3f), (int)(spriteModelFactory.DynamicWidth - (spriteModelFactory.DynamicWidth * 0.3f))); var newIcon = spriteModelFactory.MakeIconBase64(storedRef.Base64, mLoopContent.Text, xLocation, yLocation, storedRef.Scale, storedRef.TextScale, storedRef.TextVisible); var mIconRef = new IconReference(newIcon, storedRef.Base64, 1f, true); AddEventListener(mListener.Copy(), mIconRef.Sprite); iconList2.Add(mIconRef); AddChild(mIconRef.Sprite); mStoredRef = storedRef; } } if (mStoredRef != null) { storedList.Remove(mStoredRef); } } isModal = false; iconList2.Remove(tempWindow); windowFrame.RemoveChild(closeButton); RemoveChild(windowFrame); windowFrame = closeButton = null; tempWindow = null; return(true); } } return(false); } } #region ButtonSpecific Listeners if (caller.GetHashCode() == speakerFrame.GetHashCode()) { foreach (IconReference iconRef in iconList2) { var rect = iconRef.Sprite.BoundingBoxTransformedToWorld; if (speakerFrame.BoundingBoxTransformedToParent.IntersectsRect(rect)) { return(false); } } if (speakerFrame.BoundingBoxTransformedToWorld.ContainsPoint(touch.Location)) { touchType = Tags.Tag.Speak; CurrentSpriteTouched = speakerFrame; caller.Opacity = 155; return(true); } else { return(false); } } else if (caller.GetHashCode() == addFrame.GetHashCode()) { foreach (IconReference iconRef in iconList2) { var rect = iconRef.Sprite.BoundingBoxTransformedToWorld; if (addFrame.BoundingBoxTransformedToParent.IntersectsRect(rect)) { return(false); } } if (addFrame.BoundingBoxTransformedToWorld.ContainsPoint(touch.Location)) { touchType = Tags.Tag.Add; CurrentSpriteTouched = addFrame; caller.Opacity = 155; return(true); } else { return(false); } } else if (caller.GetHashCode() == takePhotoFrame.GetHashCode()) { foreach (IconReference iconRef in iconList2) { var rect = iconRef.Sprite.BoundingBoxTransformedToWorld; if (takePhotoFrame.BoundingBoxTransformedToParent.IntersectsRect(rect)) { return(false); } } if (takePhotoFrame.BoundingBoxTransformedToWorld.ContainsPoint(touch.Location)) { touchType = Tags.Tag.TakePhoto; CurrentSpriteTouched = takePhotoFrame; caller.Opacity = 155; return(true); } else { return(false); } } else if (caller.GetHashCode() == addFolderFrame.GetHashCode()) { foreach (IconReference iconRef in iconList2) { var rect = iconRef.Sprite.BoundingBoxTransformedToWorld; if (addFolderFrame.BoundingBoxTransformedToParent.IntersectsRect(rect)) { return(false); } } if (addFolderFrame.BoundingBoxTransformedToWorld.ContainsPoint(touch.Location)) { touchType = Tags.Tag.Folder; CurrentSpriteTouched = addFolderFrame; caller.Opacity = 155; return(true); } else { return(false); } } else if (caller.GetHashCode() == singleFrame.GetHashCode()) { foreach (IconReference iconRef in iconList2) { var rect = iconRef.Sprite.BoundingBoxTransformedToWorld; if (singleFrame.BoundingBoxTransformedToParent.IntersectsRect(rect)) { return(false); } } if (singleFrame.BoundingBoxTransformedToWorld.ContainsPoint(touch.Location)) { touchType = Tags.Tag.SingleMode; CurrentSpriteTouched = singleFrame; caller.Opacity = 155; return(true); } else { return(false); } } else if (caller.GetHashCode() == multiFrame.GetHashCode()) { foreach (IconReference iconRef in iconList2) { var rect = iconRef.Sprite.BoundingBoxTransformedToWorld; if (multiFrame.BoundingBoxTransformedToParent.IntersectsRect(rect)) { return(false); } } if (multiFrame.BoundingBoxTransformedToWorld.ContainsPoint(touch.Location)) { touchType = Tags.Tag.MultiMode; CurrentSpriteTouched = multiFrame; caller.Opacity = 155; return(true); } else { return(false); } } #endregion foreach (IconReference iconRef in iconList2) { if (iconRef.Sprite.Tag == SpriteTypes.IconTag) { if (inSingleMode) { if (caller.GetHashCode() == iconRef.Sprite.GetHashCode()) { if (iconRef.Sprite.BoundingBoxTransformedToWorld.ContainsPoint(touch.Location)) { touchType = Tags.Tag.Icon; CurrentSpriteTouched = iconRef.Sprite; caller.Opacity = 155; DeSelectIcons(); caller.Color = Green; return(true); } else { return(false); } } } else { if (caller.GetHashCode() == iconRef.Sprite.GetHashCode()) { if (iconRef.Sprite.BoundingBoxTransformedToWorld.ContainsPoint(touch.Location)) { touchType = Tags.Tag.Icon; CurrentSpriteTouched = iconRef.Sprite; caller.Opacity = 155; if (!sentenceFrame.Visible) { caller.Color = Green; } return(true); } else { return(false); } } } } else if (iconRef.Sprite.Tag == SpriteTypes.FolderTag) { if (caller.GetHashCode() == iconRef.Sprite.GetHashCode()) { if (iconRef.Sprite.BoundingBoxTransformedToWorld.ContainsPoint(touch.Location)) { touchType = Tags.Tag.FolderIcon; CurrentSpriteTouched = iconRef.Sprite; caller.Opacity = 155; return(true); } else { return(false); } } } } return(false); }