示例#1
0
 public Block(BlockJson origin)
 {
     this.X = origin.X;
     this.Y = origin.Y;
     this.Type = origin.Type;
 }
        /// <summary>
        /// Permite que la página ejecute la lógica para, por ejemplo, actualizar el entorno,
        /// comprobar colisiones, recopilar datos de entrada y reproducir audio.
        /// </summary>
        private void OnUpdate(object sender, GameTimerEventArgs e)
        {
            var touches = TouchPanel.GetState();

            if (touches.Count == 1)
            {
                var touch = touches[0];

                if (touch.State != TouchLocationState.Invalid)
                {
                    var block = new BlockJson();
                    block.Type = SelectedType;
                    block.X = (long)(touch.Position.X / blockSize);
                    block.Y = (long)((480 - touch.Position.Y) / blockSize);

                    Definition.Blocks.Add(block);
                    Blocks.Add(new Block(block));
                }
            }
        }