خرید بک لینک

Vote count: 0

I am making a game in wpf. I am using Image Controls to display the sprites. Below is an example of the animation scripts I am using. It works fine but, if I get more then 35-40 images moving on screen, I have frame rate drop. Looking for any suggestions on more efficient animation.

                    while (GTC_isGamePlaying)
                    {
                        Thread.Sleep(GTC_PlayerPrimaryWeapon.GetSpeed());
                        if (!GTC_isGamePaused)
                        {
                            //CheckForCollision();


                            xCord += GTC_PlayerPrimaryWeapon.GetDistance();
                            yCord += slope * GTC_PlayerPrimaryWeapon.GetDistance();
                            SetImagePosition(item.Key, xCord, yCord);

                            if (xCord > 1280)
                            {
                                SetImagePosition(item.Key, 2000, 2000);
                                break;
                            }
                        }
                    }
                    SetWeaponControlToUsed(item.Key, false);
                    break;


        public void SetImagePosition(ImageControls imageControl, double xCord, double yCord)
    {
        Dispatcher.BeginInvoke(new Action(() =>
        {
            ImageControlDirectory[imageControl].Margin = new Thickness(xCord, yCord, 0, 0);
        }));
    }

ImageControls is an enum I am using as the key in a Dictionary. The dictionary contains the BitmapImage.

asked 46 secs ago

برچسب: نویسنده: استخدام کار تاريخ: جمعه 19 شهريور 1395 ساعت: 21:50

صفحه بندی