public void drawPlaying() { Vector2 cameraLocation = new Vector2(mDeanRunner.mAnimation.getPosition().X, 0.0f); //Vector2 cameraOffset = new Vector2(graphics.PreferredBackBufferWidth / 2, 0.0f); float cameraOffset = graphics.PreferredBackBufferWidth / 2; activeBatch.Begin(SpriteSortMode.FrontToBack, BlendState.NonPremultiplied); activeBatch.Draw(mBackgroundTexture, new Rectangle(0, 0, 1280, 720), Color.White); mDeanRunner.draw(activeBatch, cameraLocation, cameraOffset, gHorizon); for (int i = 0; i < NUM_TREES; i++) { float depth = GlobalFunctions.calcDepth(treeLocs[i].Y, gHorizon, graphics.PreferredBackBufferHeight); float scale = GlobalFunctions.calcScale(depth); Color tint = GlobalFunctions.calcTint(depth); Vector2 drawPos = treeLocs[i]; drawPos.X -= cameraLocation.X; drawPos.X *= scale; drawPos.X += cameraOffset; treeUnitList[i].draw(activeBatch, drawPos, tint, scale, depth); //activeBatch.Draw(treeAnimations[i].mSpriteSourceTexture, drawPos, treeAnimations[i].mCurrentCelLocation, tint, 0.0f, new Vector2(192, 192), scale, SpriteEffects.None, depth); } for (int i = 0; i < NUM_HAM; i++) { float depth = GlobalFunctions.calcDepth(hamLocs[i].Y, gHorizon, graphics.PreferredBackBufferHeight); float scale = GlobalFunctions.calcScale(depth); Color tint = GlobalFunctions.calcTint(depth); Vector2 drawPos = hamLocs[i]; drawPos.X -= cameraLocation.X; drawPos.X *= scale; drawPos.X += cameraOffset; hamUnitList[i].draw(activeBatch, drawPos, tint, scale, depth); //activeBatch.Draw(hamUnitList[i].mAnimation.mSpriteSourceTexture, drawPos, hamUnitList[i].mAnimation.mCurrentCelLocation, tint, 0.0f, new Vector2(192, 192), scale, SpriteEffects.None, depth); } activeBatch.End(); overlayBatch.Begin(); overlayBatch.DrawString(Timeless, fps_string, new Vector2(10, 10), Color.Red, 0.0f, new Vector2(0, 0), 0.2f, SpriteEffects.None, 0.1f); overlayBatch.DrawString(Timeless, found_ham_string, new Vector2(10, 30), Color.Red, 0.0f, new Vector2(0, 0), 0.2f, SpriteEffects.None, 0.1f); overlayBatch.End(); }
public override void draw(SpriteBatch batch, Vector2 cameraPos, float cameraOffset, int horizonY) { float depth = GlobalFunctions.calcDepth(mAnimation.mSpritePosition.Y, horizonY, 656); float scale = GlobalFunctions.calcScale(depth); Vector2 drawPos = mAnimation.mSpritePosition; drawPos.X -= cameraPos.X; drawPos.X *= scale; drawPos.X += cameraOffset; batch.Draw(mAnimation.mSpriteSourceTexture, drawPos, mAnimation.mCurrentCelLocation, GlobalFunctions.calcTint(depth), mRotation, mOrigin, scale, mAnimation.mSpriteEffects, depth); }