コード例 #1
0
        public virtual AsVector <AsTexture> getTextures(String prefix)
        {
            AsVector <AsTexture> textures = new AsVector <AsTexture>();
            AsVector <String>    names    = new AsVector <String>();
            AsDictionary         __names_ = mTextureRegions;

            if (__names_ != null)
            {
                foreach (String name in __names_)
                {
                    if (AsString.indexOf(name, prefix) == 0)
                    {
                        names.push(name);
                    }
                }
            }
            names.sort(AsArray.CASEINSENSITIVE);
            AsVector <String> __names_ = names;

            if (__names_ != null)
            {
                foreach (String name in __names_)
                {
                    textures.push(getTexture(name));
                }
            }
            return(textures);
        }
コード例 #2
0
        private void processTap(AsTouch touch)
        {
            AsTouch            nearbyTap = null;
            float              minSqDist = MULTITAP_DISTANCE * MULTITAP_DISTANCE;
            AsVector <AsTouch> __taps_   = mLastTaps;

            if (__taps_ != null)
            {
                foreach (AsTouch tap in __taps_)
                {
                    float sqDist = AsMath.pow(tap.getGlobalX() - touch.getGlobalX(), 2) + AsMath.pow(tap.getGlobalY() - touch.getGlobalY(), 2);
                    if (sqDist <= minSqDist)
                    {
                        nearbyTap = tap;
                        break;
                    }
                }
            }
            if (nearbyTap != null)
            {
                touch.setTapCount(nearbyTap.getTapCount() + 1);
                mLastTaps.splice(mLastTaps.indexOf(nearbyTap), (uint)(1));
            }
            else
            {
                touch.setTapCount(1);
            }
            mLastTaps.push(touch.clone());
        }
コード例 #3
0
 public AsFragmentFilter(int numPasses, float resolution)
 {
     if (AsCapabilities.getIsDebugger() && AsGlobal.getQualifiedClassName(this) == "starling.filters::FragmentFilter")
     {
         throw new AsAbstractClassError();
     }
     if (numPasses < 1)
     {
         throw new AsArgumentError("At least one pass is required.");
     }
     mNumPasses  = numPasses;
     mMarginX    = mMarginY = 0.0f;
     mOffsetX    = mOffsetY = 0;
     mResolution = resolution;
     mMode       = AsFragmentFilterMode.REPLACE;
     mVertexData = new AsVertexData(4);
     mVertexData.setTexCoords(0, 0, 0);
     mVertexData.setTexCoords(1, 1, 0);
     mVertexData.setTexCoords(2, 0, 1);
     mVertexData.setTexCoords(3, 1, 1);
     mIndexData = new AsVector <uint>();
     mIndexData.setOwnProperty("_fixed", true);
     createPrograms();
     AsStarling.getCurrent().getStage3D().addEventListener(AsEvent.CONTEXT3D_CREATE, onContextCreated, false, 0, true);
 }
コード例 #4
0
 public virtual void removeEventListener(String type, AsEventListenerCallback listener, bool useCapture)
 {
     if (mEventListeners != null)
     {
         AsVector <AsEventListenerCallback> listeners = (AsVector <AsEventListenerCallback>)(mEventListeners[type]);
         if (listeners != null)
         {
             AsVector <AsEventListenerCallback> remainListeners   = new AsVector <AsEventListenerCallback>();
             AsVector <AsEventListenerCallback> __eventListeners_ = listeners;
             if (__eventListeners_ != null)
             {
                 foreach (AsEventListenerCallback eventListener in __eventListeners_)
                 {
                     if (eventListener != listener)
                     {
                         remainListeners.push(eventListener);
                     }
                 }
             }
             if (remainListeners.getLength() > 0)
             {
                 mEventListeners[type] = remainListeners;
             }
             else
             {
                 mEventListeners.remove(type);
             }
         }
     }
 }
コード例 #5
0
        private void updatePassTextures(int width, int height, float scale)
        {
            int  numPassTextures = mNumPasses > 1 ? 2 : 1;
            bool needsUpdate     = mPassTextures == null || mPassTextures.getLength() != numPassTextures || mPassTextures[0].getWidth() != width || mPassTextures[0].getHeight() != height;

            if (needsUpdate)
            {
                if (mPassTextures != null)
                {
                    AsVector <AsTexture> __textures_ = mPassTextures;
                    if (__textures_ != null)
                    {
                        foreach (AsTexture texture in __textures_)
                        {
                            texture.dispose();
                        }
                    }
                    mPassTextures.setLength(numPassTextures);
                }
                else
                {
                    mPassTextures = new AsVector <AsTexture>(numPassTextures);
                }
                int i = 0;
                for (; i < numPassTextures; ++i)
                {
                    mPassTextures[i] = AsTexture.empty(width, height, PMA, true, scale);
                }
            }
        }
コード例 #6
0
 public virtual void bubbleEvent(AsEvent _event)
 {
     AsVector<AsEventDispatcher> chain = null;
     AsDisplayObject element = this as AsDisplayObject;
     int length = 1;
     if(sBubbleChains.getLength() > 0)
     {
         chain = (AsVector<AsEventDispatcher>)(sBubbleChains.pop());
         chain[0] = element;
     }
     else
     {
         chain = new AsVector<AsEventDispatcher>();
     }
     while((element = element.getParent()) != null)
     {
         chain[length++] = element;
     }
     int i = 0;
     for (; i < length; ++i)
     {
         bool stopPropagation = chain[i].invokeEvent(_event);
         if(stopPropagation)
         {
             break;
         }
     }
     chain.setLength(0);
     sBubbleChains.push(chain);
 }
コード例 #7
0
 public override void render(AsRenderSupport support, float parentAlpha)
 {
     if (mFlattenedContents != null || mFlattenRequested)
     {
         if (mFlattenedContents == null)
         {
             mFlattenedContents = new AsVector <AsQuadBatch>();
         }
         if (mFlattenRequested)
         {
             AsQuadBatch.compile(this, mFlattenedContents);
             mFlattenRequested = false;
         }
         float    alpha      = parentAlpha * this.getAlpha();
         int      numBatches = (int)(mFlattenedContents.getLength());
         AsMatrix mvpMatrix  = support.getMvpMatrix();
         support.finishQuadBatch();
         support.raiseDrawCount((uint)(numBatches));
         int i = 0;
         for (; i < numBatches; ++i)
         {
             AsQuadBatch quadBatch = mFlattenedContents[i];
             String      blendMode = quadBatch.getBlendMode() == AsBlendMode.AUTO ? support.getBlendMode() : quadBatch.getBlendMode();
             quadBatch.renderCustom(mvpMatrix, alpha, blendMode);
         }
     }
     else
     {
         base.render(support, parentAlpha);
     }
 }
コード例 #8
0
        public virtual void testVectorQaulifiedTernaryCast()
        {
            Object obj = new AsVector <bc.test.vectors.AsVectorsTest>();
            AsVector <bc.test.vectors.AsVectorsTest> vector = obj != null ? (AsVector <bc.test.vectors.AsVectorsTest>)obj : null;

            vector = obj == null ? null : (AsVector <bc.test.vectors.AsVectorsTest>)obj;
        }
コード例 #9
0
 public virtual AsVector<AsTexture> getTextures(String prefix)
 {
     AsVector<AsTexture> textures = new AsVector<AsTexture>();
     AsVector<String> names = new AsVector<String>();
     AsDictionary __names_ = mTextureRegions;
     if (__names_ != null)
     {
         foreach (String name in __names_)
         {
             if(AsString.indexOf(name, prefix) == 0)
             {
                 names.push(name);
             }
         }
     }
     names.sort(AsArray.CASEINSENSITIVE);
     AsVector<String> __names_ = names;
     if (__names_ != null)
     {
         foreach (String name in __names_)
         {
             textures.push(getTexture(name));
         }
     }
     return textures;
 }
コード例 #10
0
        public virtual void testVectorIndexer()
        {
            AsVector <String> v = new AsVector <String>();

            v[0] = "a";
            String val = v[0];
        }
コード例 #11
0
 public AsFragmentFilter(int numPasses, float resolution)
 {
     if(AsCapabilities.getIsDebugger() && AsGlobal.getQualifiedClassName(this) == "starling.filters::FragmentFilter")
     {
         throw new AsAbstractClassError();
     }
     if(numPasses < 1)
     {
         throw new AsArgumentError("At least one pass is required.");
     }
     mNumPasses = numPasses;
     mMarginX = mMarginY = 0.0f;
     mOffsetX = mOffsetY = 0;
     mResolution = resolution;
     mMode = AsFragmentFilterMode.REPLACE;
     mVertexData = new AsVertexData(4);
     mVertexData.setTexCoords(0, 0, 0);
     mVertexData.setTexCoords(1, 1, 0);
     mVertexData.setTexCoords(2, 0, 1);
     mVertexData.setTexCoords(3, 1, 1);
     mIndexData = new AsVector<uint>();
     mIndexData.setOwnProperty("_fixed", true);
     createPrograms();
     AsStarling.getCurrent().getStage3D().addEventListener(AsEvent.CONTEXT3D_CREATE, onContextCreated, false, 0, true);
 }
コード例 #12
0
 public AsColorMatrixFilter(AsVector<float> matrix)
 {
     mUserMatrix = new AsVector<float>();
     mShaderMatrix = new AsVector<float>();
     mUserMatrix(IDENTITY);
     updateShaderMatrix();
 }
コード例 #13
0
 public AsColorMatrixFilter(AsVector <float> matrix)
 {
     mUserMatrix   = new AsVector <float>();
     mShaderMatrix = new AsVector <float>();
     mUserMatrix(IDENTITY);
     updateShaderMatrix();
 }
コード例 #14
0
 private void onContextCreated(Object _event)
 {
     mVertexBuffer = null;
     mIndexBuffer  = null;
     mPassTextures = null;
     createPrograms();
 }
コード例 #15
0
        private void onInterruption(Object _event)
        {
            AsTouch            touch     = null;
            String             phase     = null;
            AsVector <AsTouch> __touchs_ = mCurrentTouches;

            if (__touchs_ != null)
            {
                foreach (AsTouch touch in __touchs_)
                {
                    if (touch.getPhase() == AsTouchPhase.BEGAN || touch.getPhase() == AsTouchPhase.MOVED || touch.getPhase() == AsTouchPhase.STATIONARY)
                    {
                        touch.setPhase(AsTouchPhase.ENDED);
                    }
                }
            }
            AsTouchEvent       touchEvent = new AsTouchEvent(AsTouchEvent.TOUCH, mCurrentTouches, mShiftDown, mCtrlDown);
            AsVector <AsTouch> __touchs_  = mCurrentTouches;

            if (__touchs_ != null)
            {
                foreach (AsTouch touch in __touchs_)
                {
                    touch.dispatchEvent(touchEvent);
                }
            }
            mCurrentTouches.setLength(0);
        }
コード例 #16
0
 public virtual void testVectorCreation()
 {
     AsVector<String> v = new AsVector<String>();
     v = new AsVector<String>();
     v = new AsVector<String>();
     v = AsVector<String>.create("a", "b", "c");
 }
コード例 #17
0
        public void transformVectors(AsVector <float> vin, AsVector <float> vout)
        {
            int len = (int)(vin.getLength());

            if (((len % 3) != 0))
            {
                throw new AsArgumentError();
            }
            if ((len > vout.getLength()))
            {
                throw new AsArgumentError();
            }
            int i = 0;

            for (; (i < len); i = (i + 3))
            {
                float x = vin[i];
                float y = vin[i + 1];
                float z = vin[i + 2];

                vout[i]     = x * internalMatrix.M11 + y * internalMatrix.M21 + z * internalMatrix.M31 + internalMatrix.M41;
                vout[i + 1] = x * internalMatrix.M12 + y * internalMatrix.M22 + z * internalMatrix.M32 + internalMatrix.M42;
                vout[i + 2] = x * internalMatrix.M13 + y * internalMatrix.M23 + z * internalMatrix.M33 + internalMatrix.M43;
            }
        }
コード例 #18
0
        public virtual void bubbleEvent(AsEvent _event)
        {
            AsVector <AsEventDispatcher> chain = null;
            AsDisplayObject element            = this as AsDisplayObject;
            int             length             = 1;

            if (sBubbleChains.getLength() > 0)
            {
                chain    = (AsVector <AsEventDispatcher>)(sBubbleChains.pop());
                chain[0] = element;
            }
            else
            {
                chain = new AsVector <AsEventDispatcher>();
            }
            while ((element = element.getParent()) != null)
            {
                chain[length++] = element;
            }
            int i = 0;

            for (; i < length; ++i)
            {
                bool stopPropagation = chain[i].invokeEvent(_event);
                if (stopPropagation)
                {
                    break;
                }
            }
            chain.setLength(0);
            sBubbleChains.push(chain);
        }
コード例 #19
0
        private void init(AsVector <AsTexture> textures, float fps)
        {
            if (fps <= 0)
            {
                throw new AsArgumentError("Invalid fps: " + fps);
            }
            int numFrames = (int)(textures.getLength());

            mDefaultFrameDuration = 1.0f / fps;
            mLoop         = true;
            mPlaying      = true;
            mCurrentTime  = 0.0f;
            mCurrentFrame = 0;
            mTotalTime    = mDefaultFrameDuration * numFrames;
            mTextures     = textures.concat();
            mSounds       = new AsVector <AsSound>(numFrames);
            mDurations    = new AsVector <float>(numFrames);
            mStartTimes   = new AsVector <float>(numFrames);
            int i = 0;

            for (; i < numFrames; ++i)
            {
                mDurations[i]  = mDefaultFrameDuration;
                mStartTimes[i] = i * mDefaultFrameDuration;
            }
        }
コード例 #20
0
 public override void render(AsRenderSupport support, float parentAlpha)
 {
     if(mFlattenedContents != null || mFlattenRequested)
     {
         if(mFlattenedContents == null)
         {
             mFlattenedContents = new AsVector<AsQuadBatch>();
         }
         if(mFlattenRequested)
         {
             AsQuadBatch.compile(this, mFlattenedContents);
             mFlattenRequested = false;
         }
         float alpha = parentAlpha * this.getAlpha();
         int numBatches = (int)(mFlattenedContents.getLength());
         AsMatrix mvpMatrix = support.getMvpMatrix();
         support.finishQuadBatch();
         support.raiseDrawCount((uint)(numBatches));
         int i = 0;
         for (; i < numBatches; ++i)
         {
             AsQuadBatch quadBatch = mFlattenedContents[i];
             String blendMode = quadBatch.getBlendMode() == AsBlendMode.AUTO ? support.getBlendMode() : quadBatch.getBlendMode();
             quadBatch.renderCustom(mvpMatrix, alpha, blendMode);
         }
     }
     else
     {
         base.render(support, parentAlpha);
     }
 }
コード例 #21
0
        public virtual void testVectorCreation()
        {
            AsVector <String> v = new AsVector <String>();

            v = new AsVector <String>();
            v = new AsVector <String>();
            v = AsVector <String> .create("a", "b", "c");
        }
コード例 #22
0
 public AsDisplayObjectContainer()
 {
     if(AsCapabilities.getIsDebugger() && AsGlobal.getQualifiedClassName(this) == "starling.display::DisplayObjectContainer")
     {
         throw new AsAbstractClassError();
     }
     mChildren = new AsVector<AsDisplayObject>();
 }
コード例 #23
0
 public virtual void testVectorPush()
 {
     AsVector<String> v = new AsVector<String>();
     v.push();
     v.push("a");
     v.push("a", "b", "c");
     v.push(new AsArray("a", "b", "c"));
 }
コード例 #24
0
 public AsDisplayObjectContainer()
 {
     if (AsCapabilities.getIsDebugger() && AsGlobal.getQualifiedClassName(this) == "starling.display::DisplayObjectContainer")
     {
         throw new AsAbstractClassError();
     }
     mChildren = new AsVector <AsDisplayObject>();
 }
コード例 #25
0
 public AsDisplayObjectContainer()
 {
     if((AsGlobal.getQualifiedClassName(this) == "DisplayObjectContainer"))
     {
         throw new AsAbstractClassError();
     }
     mChildren = new AsVector<AsDisplayObject>();
 }
コード例 #26
0
 public AsQuadBatch()
 {
     mVertexData   = new AsVertexData(0, true);
     mIndexData    = new AsVector <uint>();
     mNumQuads     = 0;
     mTinted       = false;
     mSyncRequired = false;
     AsStarling.getCurrent().getStage3D().addEventListener(AsEvent.CONTEXT3D_CREATE, onContextCreated, false, 0, true);
 }
コード例 #27
0
        public virtual void testVectorPush()
        {
            AsVector <String> v = new AsVector <String>();

            v.push();
            v.push("a");
            v.push("a", "b", "c");
            v.push(new AsArray("a", "b", "c"));
        }
コード例 #28
0
 public AsQuadBatch()
 {
     mVertexData = new AsVertexData(0, true);
     mIndexData = new AsVector<uint>();
     mNumQuads = 0;
     mTinted = false;
     mSyncRequired = false;
     AsStarling.getCurrent().getStage3D().addEventListener(AsEvent.CONTEXT3D_CREATE, onContextCreated, false, 0, true);
 }
コード例 #29
0
        private void copyMatrix(AsVector <float> _from, AsVector <float> to)
        {
            int i = 0;

            for (; i < 20; ++i)
            {
                to[i] = _from[i];
            }
        }
コード例 #30
0
 public virtual void testGeneric()
 {
     AsVector<bc.test.basic.packages.foo.AsPackageClass> v1 = new AsVector<bc.test.basic.packages.foo.AsPackageClass>();
     AsVector<bc.test.basic.packages.bar.AsPackageClass> v2 = new AsVector<bc.test.basic.packages.bar.AsPackageClass>();
     v1.push(foo1);
     v2.push(foo2);
     foo1 = v1[0];
     foo2 = v2[0];
 }
コード例 #31
0
 public AsTouchProcessor(AsStage stage)
 {
     mStage          = stage;
     mElapsedTime    = mOffsetTime = 0.0f;
     mCurrentTouches = new AsVector <AsTouch>();
     mQueue          = new AsVector <AsArray>();
     mLastTaps       = new AsVector <AsTouch>();
     mStage.addEventListener(AsKeyboardEvent.KEY_DOWN, onKey);
     mStage.addEventListener(AsKeyboardEvent.KEY_UP, onKey);
 }
コード例 #32
0
        public virtual void testGeneric()
        {
            AsVector <bc.test.basic.packages.foo.AsPackageClass> v1 = new AsVector <bc.test.basic.packages.foo.AsPackageClass>();
            AsVector <bc.test.basic.packages.bar.AsPackageClass> v2 = new AsVector <bc.test.basic.packages.bar.AsPackageClass>();

            v1.push(foo1);
            v2.push(foo2);
            foo1 = v1[0];
            foo2 = v2[0];
        }
コード例 #33
0
 public AsTouchProcessor(AsStage stage)
 {
     mStage = stage;
     mElapsedTime = mOffsetTime = 0.0f;
     mCurrentTouches = new AsVector<AsTouch>();
     mQueue = new AsVector<AsArray>();
     mLastTaps = new AsVector<AsTouch>();
     mStage.addEventListener(AsKeyboardEvent.KEY_DOWN, onKey);
     mStage.addEventListener(AsKeyboardEvent.KEY_UP, onKey);
 }
コード例 #34
0
 public AsTouch(int id, float globalX, float globalY, String phase, AsDisplayObject target)
 {
     mID = id;
     mGlobalX = mPreviousGlobalX = globalX;
     mGlobalY = mPreviousGlobalY = globalY;
     mTapCount = 0;
     mPhase = phase;
     mTarget = target;
     mPressure = mWidth = mHeight = 1.0f;
     mBubbleChain = new AsVector<AsEventDispatcher>();
 }
コード例 #35
0
 public AsTouch(int id, float globalX, float globalY, String phase, AsDisplayObject target)
 {
     mID          = id;
     mGlobalX     = mPreviousGlobalX = globalX;
     mGlobalY     = mPreviousGlobalY = globalY;
     mTapCount    = 0;
     mPhase       = phase;
     mTarget      = target;
     mPressure    = mWidth = mHeight = 1.0f;
     mBubbleChain = new AsVector <AsEventDispatcher>();
 }
コード例 #36
0
        public virtual void dispose()
        {
            AsVector <AsQuadBatch> __quadBatchs_ = mQuadBatches;

            if (__quadBatchs_ != null)
            {
                foreach (AsQuadBatch quadBatch in __quadBatchs_)
                {
                    quadBatch.dispose();
                }
            }
        }
コード例 #37
0
 public virtual AsTween reset(Object target, float time, Object transition)
 {
     mTarget       = target;
     mCurrentTime  = 0;
     mTotalTime    = AsMath.max(0.0001f, time);
     mDelay        = mRepeatDelay = 0.0f;
     mOnStart      = mOnUpdate = mOnComplete = null;
     mOnStartArgs  = mOnUpdateArgs = mOnCompleteArgs = null;
     mRoundToInt   = mReverse = false;
     mRepeatCount  = 1;
     mCurrentCycle = -1;
     if (transition is String)
     {
         this.setTransition(transition as String);
     }
     else
     {
         if (transition is AsTransitionCallback)
         {
             this.setTransitionFunc(transition as AsTransitionCallback);
         }
         else
         {
             throw new AsArgumentError("Transition must be either a string or a function");
         }
     }
     if (mProperties != null)
     {
         mProperties.setLength(0);
     }
     else
     {
         mProperties = new AsVector <String>();
     }
     if (mStartValues != null)
     {
         mStartValues.setLength(0);
     }
     else
     {
         mStartValues = new AsVector <float>();
     }
     if (mEndValues != null)
     {
         mEndValues.setLength(0);
     }
     else
     {
         mEndValues = new AsVector <float>();
     }
     return(this);
 }
コード例 #38
0
        public virtual AsTouch getTouch(AsDisplayObject target, String phase)
        {
            AsVector <AsTouch> touchesFound = getTouches(target, phase);

            if (touchesFound.getLength() > 0)
            {
                return(touchesFound[0]);
            }
            else
            {
                return(null);
            }
        }
コード例 #39
0
        private AsVector <AsEventDispatcher> getBubbleChain(AsDisplayObject target, AsVector <AsEventDispatcher> result)
        {
            AsDisplayObject element = target;
            int             length  = 1;

            result.setLength(length);
            result[0] = target;
            while ((element = element.getParent()) != null)
            {
                result[length++] = element;
            }
            return(result);
        }
コード例 #40
0
 private void disposeFlattenedContents()
 {
     if (mFlattenedContents != null)
     {
         int i   = 0;
         int max = (int)(mFlattenedContents.getLength());
         for (; i < max; ++i)
         {
             mFlattenedContents[i].dispose();
         }
         mFlattenedContents = null;
     }
 }
コード例 #41
0
        private void disposePassTextures()
        {
            AsVector <AsTexture> __textures_ = mPassTextures;

            if (__textures_ != null)
            {
                foreach (AsTexture texture in __textures_)
                {
                    texture.dispose();
                }
            }
            mPassTextures = null;
        }
コード例 #42
0
 public virtual void addEventListener(String type, AsEventListenerCallback listener, bool useCapture, int priority, bool useWeakReference)
 {
     if((mEventListeners == null))
     {
         mEventListeners = new AsDictionary();
     }
     AsVector<AsEventListenerCallback> listeners = (AsVector<AsEventListenerCallback>)(mEventListeners[type]);
     if((listeners == null))
     {
         listeners = new AsVector<AsEventListenerCallback>();
         mEventListeners[type] = listeners;
     }
     listeners.push(listener);
 }
コード例 #43
0
        public virtual void addEventListener(String type, AsEventListenerCallback listener, bool useCapture, int priority, bool useWeakReference)
        {
            if (mEventListeners == null)
            {
                mEventListeners = new AsDictionary();
            }
            AsVector <AsEventListenerCallback> listeners = (AsVector <AsEventListenerCallback>)(mEventListeners[type]);

            if (listeners == null)
            {
                listeners             = new AsVector <AsEventListenerCallback>();
                mEventListeners[type] = listeners;
            }
            listeners.push(listener);
        }
コード例 #44
0
        public virtual void append(AsVertexData data)
        {
            mRawData.setOwnProperty("_fixed", false);
            int targetIndex          = (int)(mRawData.getLength());
            AsVector <float> rawData = data.mRawData;
            int rawDataLength        = (int)(rawData.getLength());
            int i = 0;

            for (; i < rawDataLength; ++i)
            {
                mRawData[targetIndex++] = rawData[i];
            }
            mNumVertices = mNumVertices + data.getNumVertices();
            mRawData.setOwnProperty("_fixed", true);
        }
コード例 #45
0
 public AsRenderSupport()
 {
     mProjectionMatrix = new AsMatrix();
     mModelViewMatrix = new AsMatrix();
     mMvpMatrix = new AsMatrix();
     mMvpMatrix3D = new AsMatrix3D();
     mMatrixStack = new AsVector<AsMatrix>();
     mMatrixStackSize = 0;
     mDrawCount = 0;
     mRenderTarget = null;
     mBlendMode = AsBlendMode.NORMAL;
     mCurrentQuadBatchID = 0;
     mQuadBatches = new AsVector<AsQuadBatch>();
     loadIdentity();
     setOrthographicProjection(0, 0, 400, 300);
 }
コード例 #46
0
 public virtual void concat(AsVector<float> matrix)
 {
     int i = 0;
     int y = 0;
     for (; y < 4; ++y)
     {
         int x = 0;
         for (; x < 5; ++x)
         {
             sTmpMatrix1[(i + x)] = matrix[i] * mUserMatrix[x] + matrix[(i + 1)] * mUserMatrix[(x + 5)] + matrix[(i + 2)] * mUserMatrix[(x + 10)] + matrix[(i + 3)] * mUserMatrix[(x + 15)] + x == 4 ? matrix[(i + 4)] : 0;
         }
         i = i + 5;
     }
     copyMatrix(sTmpMatrix1, mUserMatrix);
     updateShaderMatrix();
 }
コード例 #47
0
 public AsTouchEvent(String type, AsVector<AsTouch> touches, bool shiftKey, bool ctrlKey, bool bubbles)
     : base(type, bubbles)
 {
     mTouches = ((touches != null) ? (touches) : (new AsVector<AsTouch>()));
     mShiftKey = shiftKey;
     mCtrlKey = ctrlKey;
     mTimestamp = -1.0f;
     int numTouches = (int)(touches.getLength());
     int i = 0;
     for (; (i < numTouches); ++i)
     {
         if((touches[i].getTimestamp() > mTimestamp))
         {
             mTimestamp = touches[i].getTimestamp();
         }
     }
 }
コード例 #48
0
 public AsTouchEvent(String type, AsVector<AsTouch> touches, bool shiftKey, bool ctrlKey, bool bubbles)
     : base(type, bubbles, touches)
 {
     mShiftKey = shiftKey;
     mCtrlKey = ctrlKey;
     mTimestamp = -1.0f;
     mVisitedObjects = new AsVector<AsEventDispatcher>();
     int numTouches = (int)(touches.getLength());
     int i = 0;
     for (; i < numTouches; ++i)
     {
         if(touches[i].getTimestamp() > mTimestamp)
         {
             mTimestamp = touches[i].getTimestamp();
         }
     }
 }
コード例 #49
0
        public void testSort()
        {
            AsVector<int> vector = new AsVector<int>();
            vector.push(3);
            vector.push(1);
            vector.push(4);
            vector.push(0);

            vector.sort(sorter);
            List<int> list = vector.internalList;
            foreach (int i in list)
            {
                Console.WriteLine(i);
            }

            Assert.AreEqual(vector[0] == 0 && vector[1] == 1 && vector[2] == 3 && vector[3] == 4, true);
        }
コード例 #50
0
 public AsBitmapFont(AsTexture texture, AsXML fontXml)
 {
     if(texture == null && fontXml == null)
     {
         texture = AsMiniBitmapFont.getTexture();
         fontXml = AsMiniBitmapFont.getXml();
     }
     mName = "unknown";
     mLineHeight = mSize = mBaseline = 14;
     mTexture = texture;
     mChars = new AsDictionary();
     mHelperImage = new AsImage(texture);
     mCharLocationPool = new AsVector<AsCharLocation>();
     if(fontXml != null)
     {
         parseFontXml(fontXml);
     }
 }
コード例 #51
0
 public virtual void addEventListener(String type, AsEventListenerCallback listener)
 {
     if(mEventListeners == null)
     {
         mEventListeners = new AsDictionary();
     }
     AsVector<AsEventListenerCallback> listeners = mEventListeners[type] as AsVector<AsEventListenerCallback>;
     if(listeners == null)
     {
         mEventListeners[type] = new AsVector<AsEventListenerCallback>();
     }
     else
     {
         if(listeners.indexOf(listener) == -1)
         {
             listeners.push(listener);
         }
     }
 }
コード例 #52
0
 public virtual void addChildAt(AsDisplayObject child, int index)
 {
     if(mChildren == null)
     {
         mChildren = new AsVector<AsDisplayObject>();
     }
     if(index >= 0 && index <= getNumChildren())
     {
         child.removeFromParent();
         mChildren.splice(index, (uint)(0), child);
         child.setParent(this);
         child.dispatchEvent(sAddedEvent);
         if(getStage() != null)
         {
             child.dispatchEventOnChildren(sAddedToStageEvent);
         }
     }
     else
     {
         throw new AsRangeError("Invalid child index");
     }
 }
コード例 #53
0
        public AsMatrix3D(AsVector<float> v)
        {
            internalMatrix.M11 = v[0];
            internalMatrix.M12 = v[1];
            internalMatrix.M13 = v[2];
            internalMatrix.M14 = 0;

            internalMatrix.M21 = v[4];
            internalMatrix.M22 = v[5];
            internalMatrix.M23 = v[6];
            internalMatrix.M24 = 0;

            internalMatrix.M31 = v[8];
            internalMatrix.M32 = v[9];
            internalMatrix.M33 = v[10];
            internalMatrix.M34 = 0;

            internalMatrix.M41 = v[12];
            internalMatrix.M42 = v[13];
            internalMatrix.M43 = v[14];
            internalMatrix.M44 = 1;
        }
コード例 #54
0
 public virtual void dispatch(AsVector<AsEventDispatcher> chain)
 {
     if(chain != null && chain.getLength() != 0)
     {
         int chainLength = (int)(getBubbles() ? chain.getLength() : 1);
         AsEventDispatcher previousTarget = getTarget();
         setTarget(chain[0] as AsEventDispatcher);
         int i = 0;
         for (; i < chainLength; ++i)
         {
             AsEventDispatcher chainElement = chain[i] as AsEventDispatcher;
             if(mVisitedObjects.indexOf(chainElement) == -1)
             {
                 bool stopPropagation = chainElement.invokeEvent(this);
                 mVisitedObjects.push(chainElement);
                 if(stopPropagation)
                 {
                     break;
                 }
             }
         }
         setTarget(previousTarget);
     }
 }
コード例 #55
0
 public virtual void uploadFromVector(AsVector<float> data, int startVertex, int numVertices)
 {
     throw new AsNotImplementedError();
 }
コード例 #56
0
 public static void compile(AsDisplayObject _object, AsVector<AsQuadBatch> quadBatches)
 {
     compileObject(_object, quadBatches, -1, new AsMatrix());
 }
コード例 #57
0
 private static int compileObject(AsDisplayObject _object, AsVector<AsQuadBatch> quadBatches, int quadBatchID, AsMatrix transformationMatrix)
 {
     return compileObject(_object, quadBatches, quadBatchID, transformationMatrix, 1.0f, null, false);
 }
コード例 #58
0
 private static int compileObject(AsDisplayObject _object, AsVector<AsQuadBatch> quadBatches, int quadBatchID, AsMatrix transformationMatrix, float alpha, String blendMode)
 {
     return compileObject(_object, quadBatches, quadBatchID, transformationMatrix, alpha, blendMode, false);
 }
コード例 #59
0
 private static int compileObject(AsDisplayObject _object, AsVector<AsQuadBatch> quadBatches, int quadBatchID, AsMatrix transformationMatrix, float alpha, String blendMode, bool ignoreCurrentFilter)
 {
     int i = 0;
     AsQuadBatch quadBatch = null;
     bool isRootObject = false;
     float objectAlpha = _object.getAlpha();
     AsDisplayObjectContainer container = _object as AsDisplayObjectContainer;
     AsQuad quad = _object as AsQuad;
     AsQuadBatch batch = _object as AsQuadBatch;
     AsFragmentFilter filter = _object.getFilter();
     if(quadBatchID == -1)
     {
         isRootObject = true;
         quadBatchID = 0;
         objectAlpha = 1.0f;
         blendMode = _object.getBlendMode();
         if(quadBatches.getLength() == 0)
         {
             quadBatches.push(new AsQuadBatch());
         }
         else
         {
             quadBatches[0].reset();
         }
     }
     if(filter != null && !ignoreCurrentFilter)
     {
         if(filter.getMode() == AsFragmentFilterMode.ABOVE)
         {
             quadBatchID = compileObject(_object, quadBatches, quadBatchID, transformationMatrix, alpha, blendMode, true);
         }
         quadBatchID = compileObject(filter.compile(_object), quadBatches, quadBatchID, transformationMatrix, alpha, blendMode);
         if(filter.getMode() == AsFragmentFilterMode.BELOW)
         {
             quadBatchID = compileObject(_object, quadBatches, quadBatchID, transformationMatrix, alpha, blendMode, true);
         }
     }
     else
     {
         if(container != null)
         {
             int numChildren = container.getNumChildren();
             AsMatrix childMatrix = new AsMatrix();
             for (i = 0; i < numChildren; ++i)
             {
                 AsDisplayObject child = container.getChildAt(i);
                 bool childVisible = child.getAlpha() != 0.0f && child.getVisible() && child.getScaleX() != 0.0f && child.getScaleY() != 0.0f;
                 if(childVisible)
                 {
                     String childBlendMode = child.getBlendMode() == AsBlendMode.AUTO ? blendMode : child.getBlendMode();
                     childMatrix.copyFrom(transformationMatrix);
                     AsRenderSupport.transformMatrixForObject(childMatrix, child);
                     quadBatchID = compileObject(child, quadBatches, quadBatchID, childMatrix, alpha * objectAlpha, childBlendMode);
                 }
             }
         }
         else
         {
             if(quad != null || batch != null)
             {
                 AsTexture texture = null;
                 String smoothing = null;
                 bool tinted = false;
                 int numQuads = 0;
                 if(quad != null)
                 {
                     AsImage image = quad as AsImage;
                     texture = image != null ? image.getTexture() : null;
                     smoothing = image != null ? image.getSmoothing() : null;
                     tinted = quad.getTinted();
                     numQuads = 1;
                 }
                 else
                 {
                     texture = batch.mTexture;
                     smoothing = batch.mSmoothing;
                     tinted = batch.mTinted;
                     numQuads = batch.mNumQuads;
                 }
                 quadBatch = quadBatches[quadBatchID];
                 if(quadBatch.isStateChange(tinted, alpha * objectAlpha, texture, smoothing, blendMode, numQuads))
                 {
                     quadBatchID++;
                     if(quadBatches.getLength() <= quadBatchID)
                     {
                         quadBatches.push(new AsQuadBatch());
                     }
                     quadBatch = quadBatches[quadBatchID];
                     quadBatch.reset();
                 }
                 if(quad != null)
                 {
                     quadBatch.addQuad(quad, alpha, texture, smoothing, transformationMatrix, blendMode);
                 }
                 else
                 {
                     quadBatch.addQuadBatch(batch, alpha, transformationMatrix, blendMode);
                 }
             }
             else
             {
                 throw new AsError("Unsupported display object: " + AsGlobal.getQualifiedClassName(_object));
             }
         }
     }
     if(isRootObject)
     {
         for (i = (int)(quadBatches.getLength() - 1); i > quadBatchID; --i)
         {
             quadBatches.pop().dispose();
         }
     }
     return quadBatchID;
 }
コード例 #60
0
 private void getChildEventListeners(AsDisplayObject _object, String eventType, AsVector<AsDisplayObject> listeners)
 {
     AsDisplayObjectContainer container = _object as AsDisplayObjectContainer;
     if(_object.hasEventListener(eventType))
     {
         listeners.push(_object);
     }
     if(container != null)
     {
         AsVector<AsDisplayObject> children = container.mChildren;
         int numChildren = (int)(children.getLength());
         int i = 0;
         for (; i < numChildren; ++i)
         {
             getChildEventListeners(children[i], eventType, listeners);
         }
     }
 }