示例#1
0
        /* Add to list */
        public FX addFX(double x, double y, BlitRect blit, Point dir = null, int delay = 0, Boolean push = true, Boolean looped = false, Boolean killOffScreen = true, Boolean room = false)
        {
            var item = new FX(x, y, blit, bitmapData, canvasPoint, dir, delay, looped, killOffScreen);

            if (room)
            {
                if (push)
                {
                    roomFx.push(item);
                }
                else
                {
                    roomFx.unshift(item);
                }
            }
            else
            {
                if (push)
                {
                    fx.push(item);
                }
                else
                {
                    fx.unshift(item);
                }
            }
            return(item);
        }
示例#2
0
 public void update(double mouseX, double mouseY, Boolean mousePressed, Boolean mouseClick, Boolean mouseReleased = false)
 {
     buttonsOver.length = 0;
     if (!mousePressed)
     {
         mouseLock = false;
         ignore    = false;
     }
     else
     {
         if (ignore)
         {
             return;
         }
     }
     mouseOver = false;
     button    = buttons[0];
     for (i = buttons.length - 1; i > -1; i--)
     {
         button = buttons[i];
         if (
             button.visible &&
             mouseX >= button.x + button.area.x &&
             mouseY >= button.y + button.area.y &&
             mouseX < button.x + button.area.x + button.area.width &&
             mouseY < button.y + button.area.y + button.area.height
             )
         {
             button.over = Game.MOBILE ? (mousePressed || mouseReleased) : true;
             if (button.over)
             {
                 mouseOver = true;
                 if (button == lastButton)
                 {
                     buttonsOver.unshift(button);
                 }
                 else
                 {
                     buttonsOver.push(button);
                 }
             }
             if (mouseClick)
             {
                 lastButton = button;
                 if (button.callback != null)
                 {
                     if (button.feedCallbackToEvent)
                     {
                         mousePressedCallback = button.callback;
                     }
                     else
                     {
                         button.callback();
                         if ((selectSoundCallback != null) && !button.silent)
                         {
                             selectSoundCallback();
                         }
                     }
                 }
                 mouseLock        = true;
                 button.heldCount = BlitButton.HELD_DELAY;
                 break;
             }
             else if (mousePressed)
             {
                 if (button == lastButton)
                 {
                     if (button.heldCount > 0)
                     {
                         button.heldCount--;
                     }
                     else
                     {
                         button.held = true;
                         if (button.heldCallback != null)
                         {
                             button.heldCount = BlitButton.HELD_DELAY;
                             button.heldCallback();
                         }
                     }
                 }
                 else
                 {
                     if (!button.focusLock)
                     {
                         lastButton = button;
                         if (button.callback != null)
                         {
                             button.callback();
                             if (selectSoundCallback != null && !button.silent)
                             {
                                 selectSoundCallback();
                             }
                         }
                     }
                 }
             }
         }
         else
         {
             if (button.over)
             {
                 button.over = false;
                 button.held = false;
             }
         }
     }
     if (mouseReleased)
     {
         if (lastButton != null && lastButton.over && lastButton.releaseCallback != null)
         {
             lastButton.releaseCallback();
             lastButton.over = false;
         }
     }
     if (mouseClick && !mouseOver)
     {
         ignore = true;
     }
 }