public void Update(GameTime gameTime) { flipbook.Position = new Vector2(position.X, -(GameScene.Camera.CameraOffset + Parameter.ScreenResolution / 2).Y); spriteText.Position = flipbook.Position + new Vector2(0, 0); if (fadeAnimation != 1) { fadeAnimation = Math.Min(fadeAnimation + (float)gameTime.ElapsedGameTime.TotalSeconds / 2, 1); flipbook.SetTransparency(fadeAnimation); spriteText.SetTransparency(fadeAnimation); } }
public virtual void Update(Vector2 projectilePosition, Vector2 angularPositionOffset, float currentProjectileAngle, float elapsedTime, float angleOffset, float rotationFactor = 1f, float angleFactor = 1f) { rotationAngle += elapsedTime * MathHelper.TwoPi * rotationFactor; //Update DC positionRotatedOffset = Vector2.Transform(angularPositionOffset * (float)Math.Sin(rotationAngle + angleOffset) * angleFactor, Matrix.CreateRotationZ(currentProjectileAngle)); positionOffset = projectilePosition + positionRotatedOffset; if (lastSpawn == null || Vector2.Distance(lastSpawn, positionOffset) > 8) { //Top Flipbook newFlipbook = SpawnFlipbook(mobileType, shotType); newFlipbook.Position = positionOffset; newFlipbook.SetTransparency(0); lastSpawn = positionOffset; traceList.Add(newFlipbook); float f = 1; for (int i = traceList.Count - 1; i >= 0; i--, f -= 0.03f) { if (i - 1 >= 0) { var prev = traceList[i - 1]; var curr = traceList[i]; curr.Rotation = (float)Helper.AngleBetween(curr.Position, prev.Position) + MathHelper.Pi / 2; } traceList[i].Color = Color * f; } } leadTrace.Position = positionOffset; leadTrace.Rotation = currentProjectileAngle; #if DEBUG dc0.Update(projectilePosition); dc1.Update(positionRotatedOffset + projectilePosition); #endif }