コード例 #1
0
        private void onTouch(AsTouchEvent _event)
        {
            AsMouse.setCursor(mUseHandCursor && mEnabled && _event.interactsWith(this) ? AsMouseCursor.BUTTON : AsMouseCursor.AUTO);
            AsTouch touch = _event.getTouch(this);

            if (!mEnabled || touch == null)
            {
                return;
            }
            if (touch.getPhase() == AsTouchPhase.BEGAN && !mIsDown)
            {
                mBackground.setTexture(mDownState);
                mContents.setScaleX(mContents.setScaleY(mScaleWhenDown));
                mContents.setX((1.0f - mScaleWhenDown) / 2.0f * mBackground.getWidth());
                mContents.setY((1.0f - mScaleWhenDown) / 2.0f * mBackground.getHeight());
                mIsDown = true;
            }
            else
            {
                if (touch.getPhase() == AsTouchPhase.MOVED && mIsDown)
                {
                    AsRectangle buttonRect = getBounds(getStage());
                    if (touch.getGlobalX() < buttonRect.x - MAX_DRAG_DIST || touch.getGlobalY() < buttonRect.y - MAX_DRAG_DIST || touch.getGlobalX() > buttonRect.x + buttonRect.width + MAX_DRAG_DIST || touch.getGlobalY() > buttonRect.y + buttonRect.height + MAX_DRAG_DIST)
                    {
                        resetContents();
                    }
                }
                else
                {
                    if (touch.getPhase() == AsTouchPhase.ENDED && mIsDown)
                    {
                        resetContents();
                        dispatchEventWith(AsEvent.TRIGGERED, true);
                    }
                }
            }
        }
コード例 #2
0
 private void onTouch(AsTouchEvent _event)
 {
     AsMouse.setCursor(_event.interactsWith(this) ? AsMouseCursor.BUTTON : AsMouseCursor.AUTO);
 }
コード例 #3
0
 private AsArray getTouchEventTypes()
 {
     return(AsMouse.getSupportsCursor() || !getMultitouchEnabled() ? new AsArray(AsMouseEvent.MOUSE_DOWN, AsMouseEvent.MOUSE_MOVE, AsMouseEvent.MOUSE_UP) : new AsArray(AsTouchEvent.TOUCH_BEGIN, AsTouchEvent.TOUCH_MOVE, AsTouchEvent.TOUCH_END));
 }