Exemple #1
0
        // ===========================================================
        // Constructors
        // ===========================================================

        public EngineOptions(/* final */ bool pFullscreen, /* final ScreenOrientation */ ScreenOrientationOptions pScreenOrientation, /* final */ IResolutionPolicy pResolutionPolicy, /* final */ Camera pCamera)
        {
            this.mFullscreen        = pFullscreen;
            this.mScreenOrientation = pScreenOrientation;
            this.mResolutionPolicy  = pResolutionPolicy;
            this.mCamera            = pCamera;
        }
        // ===========================================================
        // Constructors
        // ===========================================================

        public EngineOptions(/* final */ bool pFullscreen, /* final ScreenOrientation */ ScreenOrientationOptions pScreenOrientation, /* final */ IResolutionPolicy pResolutionPolicy, /* final */ Camera pCamera)
        {
            this.mFullscreen = pFullscreen;
            this.mScreenOrientation = pScreenOrientation;
            this.mResolutionPolicy = pResolutionPolicy;
            this.mCamera = pCamera;
        }
        // ===========================================================
        // Methods
        // ===========================================================

        public void CenterShapeInCamera(Shape pShape)
        {
            Camera camera = this.mCamera;

            //pShape.setPosition((camera.getWidth() - pShape.getWidth()) * 0.5f, (camera.getHeight() - pShape.getHeight()) * 0.5f);
            pShape.SetPosition((camera.Width - pShape.GetWidth()) * 0.5f, (camera.Height - pShape.GetHeight()) * 0.5f);
        }
        // ===========================================================
        // Methods for/from SuperClass/Interfaces
        // ===========================================================

        public override void OnDraw(GL10 pGL, Camera pCamera)
        {
            if (this.mColorEnabled)
            {
                pGL.GlClearColor(this.mRed, this.mGreen, this.mBlue, this.mAlpha);
                pGL.GlClear(Javax.Microedition.Khronos.Opengles.GL10Consts.GlColorBufferBit);
            }
        }
        protected override void OnManagedDraw(GL10 pGL, Camera pCamera)
        {
            IEntity[] entities    = this.mEntities;
            int       entityCount = this.mEntityCount;

            for (int i = 0; i < entityCount; i++)
            {
                entities[i].OnDraw(pGL, pCamera);
            }
        }
 protected override void OnManagedDraw(GL10 pGL, Camera pCamera)
 {
     //final ArrayList<IEntity> entities = this.mEntities;
     IList<IEntity> entities = mEntities;
     int entityCount = entities.Count;
     for (int i = 0; i < entityCount; i++)
     {
         entities[i].OnDraw(pGL, pCamera);
     }
 }
Exemple #7
0
        protected override void OnManagedDraw(GL10 pGL, Camera pCamera)
        {
            //final ArrayList<IEntity> entities = this.mEntities;
            IList <IEntity> entities    = mEntities;
            int             entityCount = entities.Count;

            for (int i = 0; i < entityCount; i++)
            {
                entities[i].OnDraw(pGL, pCamera);
            }
        }
        protected void Init(Camera pCamera, TextureRegion pTextureRegion, float pDuration, float pScaleFrom, float pScaleTo)
        {
            Sprite loadingScreenSprite = new Sprite(pCamera.GetMinX(), pCamera.GetMinY(), pCamera.GetWidth(), pCamera.GetHeight(), pTextureRegion);

            if (pScaleFrom != 1 || pScaleTo != 1)
            {
                loadingScreenSprite.SetScale(pScaleFrom);
                loadingScreenSprite.AddShapeModifier(new ScaleModifier(pDuration, pScaleFrom, pScaleTo, IEaseFunction.DEFAULT));
            }

            this.GetTopLayer().AddEntity(loadingScreenSprite);
        }
        protected override bool IsCulled(/* final */ Camera pCamera)
        {
            /* final */
            float x = this.mX;
            /* final */
            float y = this.mY;

            return(x > pCamera.GetMaxX() ||
                   y > pCamera.GetMaxY() ||
                   x + this.GetWidth() < pCamera.GetMinX() ||
                   y + this.GetHeight() < pCamera.GetMinY());
        }
Exemple #10
0
        protected override void OnManagedDraw(/* final */ GL10 pGL, /* final */ Camera pCamera)
        {
            if (this.mCullingEnabled == false || this.IsCulled(pCamera) == false)
            {
                this.OnInitDraw(pGL);

                pGL.GlPushMatrix();
                {
                    this.OnApplyVertices(pGL);
                    this.OnApplyTransformations(pGL);
                    this.DrawVertices(pGL, pCamera);
                }
                pGL.GlPopMatrix();
            }
        }
        protected override void ConvertSurfaceToSceneTouchEvent(/* final */ Camera pCamera, /* final */ TouchEvent pSurfaceTouchEvent)
        {
            /* final */
            int surfaceWidthHalf = this.mSurfaceWidth >> 1;

            //if (pCamera == this.getFirstCamera())
            if (pCamera == this.FirstCamera)
            {
                pCamera.ConvertSurfaceToSceneTouchEvent(pSurfaceTouchEvent, surfaceWidthHalf, this.mSurfaceHeight);
            }
            else
            {
                pSurfaceTouchEvent.Offset(-surfaceWidthHalf, 0);
                pCamera.ConvertSurfaceToSceneTouchEvent(pSurfaceTouchEvent, surfaceWidthHalf, this.mSurfaceHeight);
            }
        }
Exemple #12
0
        protected override void OnManagedDraw(GL10 pGL, Camera pCamera)
        {
            if (this.mCamera != null)
            {
                pGL.GlMatrixMode(GL10Consts.GlProjection);
                this.mCamera.OnApplyCameraSceneMatrix(pGL);
                {
                    pGL.GlMatrixMode(GL10Consts.GlModelview);
                    pGL.GlPushMatrix();
                    pGL.GlLoadIdentity();

                    base.OnManagedDraw(pGL, pCamera);

                    pGL.GlPopMatrix();
                }
                pGL.GlMatrixMode(GL10Consts.GlProjection);
            }
        }
        // ===========================================================
        // Methods for/from SuperClass/Interfaces
        // ===========================================================

        protected override void OnDrawScene(/* final */ GL10 pGL)
        {
            /* final */
            //Camera firstCamera = this.GetFirstCamera();
            Camera firstCamera = this.FirstCamera;
            /* final */
            Camera secondCamera = this.SecondCamera;

            /* final */
            int surfaceWidth = this.mSurfaceWidth;
            /* final */
            int surfaceWidthHalf = surfaceWidth >> 1;

            /* final */
            int surfaceHeight = this.mSurfaceHeight;

            //pGL.glEnable(GL10.GL_SCISSOR_TEST); // TODO --> GLHelper
            pGL.GlEnable(GL10Consts.GlScissorTest); // TODO --> GLHelper

            /* First Screen. With first camera, on the left half of the screens width. */
            {
                pGL.GlScissor(0, 0, surfaceWidthHalf, surfaceHeight);
                pGL.GlViewport(0, 0, surfaceWidthHalf, surfaceHeight);

                //super.mScene.onDraw(pGL, firstCamera);
                base.mScene.OnDraw(pGL, firstCamera);
                firstCamera.OnDrawHUD(pGL);
            }

            /* Second Screen. With second camera, on the right half of the screens width. */
            {
                pGL.GlScissor(surfaceWidthHalf, 0, surfaceWidthHalf, surfaceHeight);
                pGL.GlViewport(surfaceWidthHalf, 0, surfaceWidthHalf, surfaceHeight);

                //super.mScene.onDraw(pGL, secondCamera);
                base.mScene.OnDraw(pGL, secondCamera);
                secondCamera.OnDrawHUD(pGL);
            }

            pGL.GlDisable(GL10Consts.GlScissorTest);
        }
Exemple #14
0
        public Engine(/* final */ EngineOptions pEngineOptions)
        {
            Engine.Instance = this;

            //TextureRegionFactory.setAssetBasePath("");
            TextureRegionFactory.SetAssetBasePath("");
            //SoundFactory.setAssetBasePath("");
            SoundFactory.SetAssetBasePath("");
            //MusicFactory.setAssetBasePath("");
            MusicFactory.SetAssetBasePath("");
            //FontFactory.setAssetBasePath("");
            FontFactory.setAssetBasePath("");

            //BufferObjectManager.setActiveInstance(this.mBufferObjectManager);
            BufferObjectManager.SetActiveInstance(this.mBufferObjectManager);

            this.mEngineOptions = pEngineOptions;
            //this.SetTouchController(new SingleTouchController());
            this.TouchController = new SingleTouchController();
            //this.mCamera = pEngineOptions.getCamera();
            this.mCamera = pEngineOptions.GetCamera();

            if (this.mEngineOptions.NeedsSound())
            {
                this.mSoundManager = new SoundManager();
            }

            if (this.mEngineOptions.NeedsMusic())
            {
                this.mMusicManager = new MusicManager();
            }

            if (this.mEngineOptions.HasLoadingScreen())
            {
                this.InitLoadingScreen();
            }

            this.mUpdateThread.Start();
        }
        // ===========================================================
        // Constructors
        // ===========================================================

        public SingleSceneSplitScreenEngine(/* final */ EngineOptions pEngineOptions, /* final */ Camera pSecondCamera)
            : base(pEngineOptions)
        {
            //super(pEngineOptions);
            this.mSecondCamera = pSecondCamera;
        }
Exemple #16
0
        // ===========================================================
        // Constructors
        // ===========================================================

        /**
         * {@link CameraScene#setCamera(Camera)} needs to be called manually. Otherwise nothing will be drawn.
         */
        public CameraScene(int pLayerCount)
            : base(pLayerCount)
        {
            this.mCamera = null;
        }
Exemple #17
0
 public CameraScene(int pLayerCount, Camera pCamera)
     : base(pLayerCount)
 {
     this.mCamera = pCamera;
 }
Exemple #18
0
 protected abstract void DrawVertices(/* final */ GL10 pGL, /* final */ Camera pCamera);
Exemple #19
0
 protected abstract void DrawVertices(/* final */ GL10 pGL, /* final */ Camera pCamera);
Exemple #20
0
 public SplashScene(Camera pCamera, TextureRegion pTextureRegion, float pDuration, float pScaleFrom, float pScaleTo)
     : base(1)
 {
     Init(pCamera, pTextureRegion, pDuration, pScaleFrom, pScaleTo);
 }
 protected override void DrawVertices(/* final */ GL10 pGL, /* final */ Camera pCamera)
 {
     pGL.GlDrawArrays(GL10Consts.GlTriangleStrip, 0, 4);
 }
 protected override void DrawVertices(/* final */ GL10 pGL, /* final */ Camera pCamera)
 {
     pGL.GlDrawArrays(GL10Consts.GlTriangleStrip, 0, 4);
 }
 public void SetCamera(Camera pCamera)
 {
     this.mCamera = pCamera;
 }
Exemple #24
0
        // ===========================================================
        // Constants
        // ===========================================================

        // ===========================================================
        // Fields
        // ===========================================================

        // ===========================================================
        // Constructors
        // ===========================================================

        public SplashScene(Camera pCamera, TextureRegion pTextureRegion)
            : base(1)
        {
            Init(pCamera, pTextureRegion, -1, 1, 1);
        }
        // ===========================================================
        // Constructors
        // ===========================================================

        /**
         * {@link CameraScene#setCamera(Camera)} needs to be called manually. Otherwise nothing will be drawn.
         */
        public CameraScene(int pLayerCount)
            : base(pLayerCount)
        {
            this.mCamera = null;
        }
        protected override void OnManagedDraw(GL10 pGL, Camera pCamera)
        {
            if (this.mCamera != null)
            {
                pGL.GlMatrixMode(GL10Consts.GlProjection);
                this.mCamera.OnApplyCameraSceneMatrix(pGL);
                {
                    pGL.GlMatrixMode(GL10Consts.GlModelview);
                    pGL.GlPushMatrix();
                    pGL.GlLoadIdentity();

                    base.OnManagedDraw(pGL, pCamera);

                    pGL.GlPopMatrix();
                }
                pGL.GlMatrixMode(GL10Consts.GlProjection);
            }
        }
Exemple #27
0
        protected override void OnManagedDraw(/* final */ GL10 pGL, /* final */ Camera pCamera)
        {
            if (this.mCullingEnabled == false || this.IsCulled(pCamera) == false)
            {
                this.OnInitDraw(pGL);

                pGL.GlPushMatrix();
                {
                    this.OnApplyVertices(pGL);
                    this.OnApplyTransformations(pGL);
                    this.DrawVertices(pGL, pCamera);
                }
                pGL.GlPopMatrix();
            }
        }
Exemple #28
0
 public void SetCamera(Camera pCamera)
 {
     this.mCamera = pCamera;
 }
 public abstract void OnDraw(GL10 gl10, andengine.engine.camera.Camera camera);
Exemple #30
0
 /**
  * Will only be performed if {@link Shape#isCullingEnabled()} is true.
  * @param pCamera
  * @return <code>true</code> when this object is visible by the {@link Camera}, <code>false</code> otherwise.
  */
 protected abstract bool IsCulled(/* final */ Camera pCamera);
 protected override bool IsCulled(/* final */ Camera pCamera)
 {
     /* final */
     float x = this.mX;
     /* final */
     float y = this.mY;
     return x > pCamera.GetMaxX()
         || y > pCamera.GetMaxY()
         || x + this.GetWidth() < pCamera.GetMinX()
         || y + this.GetHeight() < pCamera.GetMinY();
 }
Exemple #32
0
 /**
  * Will only be performed if {@link Shape#isCullingEnabled()} is true.
  * @param pCamera
  * @return <code>true</code> when this object is visible by the {@link Camera}, <code>false</code> otherwise.
  */
 protected abstract bool IsCulled(/* final */ Camera pCamera);
 public CameraScene(int pLayerCount, Camera pCamera)
     : base(pLayerCount)
 {
     this.mCamera = pCamera;
 }
        // ===========================================================
        // Constructors
        // ===========================================================

        public BaseOnScreenControl(/* final */ int pX, /* final */ int pY, /* final */ Camera pCamera, /* final */ TextureRegion pControlBaseTextureRegion, /* final */ TextureRegion pControlKnobTextureRegion, /* final */ float pTimeBetweenUpdates, /* final */ IOnScreenControlListener pOnScreenControlListener)
        {
            this.SetCamera(pCamera);

            this.mOnScreenControlListener = pOnScreenControlListener;
            /* Create the control base. */

            /*
             * this.mControlBase = new Sprite(pX, pY, pControlBaseTextureRegion) {
             *  public override bool OnAreaTouched(/* final * / TouchEvent pSceneTouchEvent, /* final * / float pTouchAreaLocalX, /* final * / float pTouchAreaLocalY) {
             *      return BaseOnScreenControl.this.OnHandleControlBaseTouched(pSceneTouchEvent, pTouchAreaLocalX, pTouchAreaLocalY);
             *  }
             * };
             */
            this.mControlBase = new BaseOnScreenControlBaseSprite(this, pX, pY, pControlBaseTextureRegion);

            /* Create the control knob. */
            this.mControlKnob = new Sprite(0, 0, pControlKnobTextureRegion);
            this.OnHandleControlKnobReleased();

            /* Register listeners and add objects to this HUD. */
            this.SetOnSceneTouchListener(this);
            this.RegisterTouchArea(this.mControlBase);

            /*
             * this.RegisterUpdateHandler(new TimerHandler(pTimeBetweenUpdates, true, new ITimerCallback() {
             *  public override void OnTimePassed(/* final * / TimerHandler pTimerHandler) {
             *      BaseOnScreenControl.this.mOnScreenControlListener.onControlChange(BaseOnScreenControl.this, BaseOnScreenControl.this.mControlValueX, BaseOnScreenControl.this.mControlValueY);
             *  }
             * }));
             * //*/
            this.RegisterUpdateHandler(new TimerHandler(pTimeBetweenUpdates, true, new BaseOnScreenControlTimerCallback(this)));

            /* final */
            ILayer bottomLayer = this.GetBottomLayer();

            bottomLayer.AddEntity(this.mControlBase);
            bottomLayer.AddEntity(this.mControlKnob);

            this.SetTouchAreaBindingEnabled(true);
        }