public Scene(CocosNode singleChild) : this() { if (singleChild == null) { throw new ArgumentNullException("singleChild"); } AddChild(singleChild); }
public CocosNode AddChild(CocosNode child, int z, PointF parallaxRatio, PointF positionOffset) { if (child == null) { throw new ArgumentNullException("child"); } NodeBox box = new NodeBox(parallaxRatio, positionOffset, child); _parallaxNodes.Add(box); float x = Position.X * parallaxRatio.X + positionOffset.X; float y = Position.Y * parallaxRatio.Y + positionOffset.Y; child.SetPosition(x, y); return base.AddChild(child, z, child.Tag); }
public void AddAction(Action action, CocosNode target) { if (action == null) { throw new ArgumentNullException("action"); } if (target == null) { throw new ArgumentNullException("target"); } HashElement element = null; if (_hash.ContainsKey(target)) { element = _hash[target]; } else { element = new HashElement(); element.Target = target; _hash.Add(target, element); } element.Actions.Add(action); action.Target = target; action.Start(); }
private void InsertChild(CocosNode child, int z) { int i = 0; bool added = false; foreach (CocosNode node in _children) { if (node.ZOrder > z) { added = true; _children.Insert(i, child); break; } ++i; } if (!added) { _children.Add(child); } child._zorder = z; }
private void DetachChild(CocosNode child, bool cleanup) { if (IsRunning) { child.OnExit(); } if (cleanup) { child.CleanUp(); } child.Parent = null; _children.Remove(child); }
// private void ReorderChild(CocosNode child, int z) { // if (child == null) { // throw new ArgumentNullException("child"); // } // // _children.Remove(child); // InsertChild(child, z); // } public virtual void RemoveChild(CocosNode child, bool cleanup) { if (child != null) { if (Children.Contains(child)) { DetachChild(child, cleanup); } } }
public virtual CocosNode AddChild(CocosNode child, int z, int tag) { if (child == null) { throw new ArgumentNullException("child"); } if (child.Parent != null) { throw new ArgumentException("Child already has a parent", "child"); } child.Tag = tag; InsertChild(child, z); child.Parent = this; if (IsRunning) { child.OnEnter(); } return this; }
public CocosNode AddChild(CocosNode child, int zOrder) { return AddChild(child, zOrder, child.Tag); }
public CocosNode AddChild(CocosNode child) { return AddChild(child, child.ZOrder, child.Tag); }
public override CocosNode AddChild(CocosNode child, int z, int tag) { if (!(child is MenuItem)) { throw new ArgumentException("Can only add menu items to a menu", "child"); } return base.AddChild(child, z, tag); }
public void RemoveAllActionsForTarget(CocosNode target) { if (target != null && _hash.ContainsKey(target)) { _hash.Remove(target); } }
public NodeBox(PointF ratio, PointF offset, CocosNode child) { if (child == null) { throw new ArgumentNullException("child"); } Ratio = ratio; Offset = offset; Child = child; }
public override CocosNode AddChild(CocosNode child, int z, int tag) { throw new Exception("Use AddChild(CocosNode node, int z, PointF parallaxRatio, PointF positionOffset) instead"); }
private void Callback3(CocosNode sender, object data) { Console.WriteLine("callback 3 called from:{0} with data:{1}", sender, data); SizeF s = Director.Instance.WinSize; Label label = new Label("callback 3 called", "Marker Felt", 16); label.SetPosition(s.Width / 4 * 3, s.Height / 2); AddChild(label, 4); }
private void Callback2(CocosNode sender) { Console.WriteLine("callback 2 called from: " + sender.ToString()); SizeF s = Director.Instance.WinSize; Label label = new Label("callback 2 called", "Marker Felt", 16); label.SetPosition(s.Width / 4 * 2, s.Height / 2); AddChild(label, 4); }