コード例 #1
0
        private async void MoveRight()
        {
            int distance = (int)(New_Position_X - (CurrentPet.X + (CurrentPet.Width / 2)));

            if (CurrentPet.X + CurrentPet.Width / 2 < BoxWidth)  //Check if image does not exceed right edge
            {
                if (New_Position_X > BoxWidth - CurrentPet.Width / 2)
                {
                    await CurrentPet.TranslateTo(distance - CurrentPet.Width / 2, 0, 500, Easing.Linear);
                }
                else
                {
                    await CurrentPet.TranslateTo(distance, 0, 500, Easing.Linear);
                }
            }
        }
コード例 #2
0
        private async void MoveLeft()
        {
            int distance = (int)-(CurrentPet.X + CurrentPet.Width / 2) + New_Position_X;

            if (CurrentPet.X + CurrentPet.Width / 2 > 0)  //Check if image does not exceed left edge
            {
                if (New_Position_X < CurrentPet.Width / 2)
                {
                    await CurrentPet.TranslateTo(distance + CurrentPet.Width / 2, 0, 500, Easing.Linear);
                }
                else
                {
                    await CurrentPet.TranslateTo(distance, 0, 500, Easing.Linear);
                }
            }
        }