protected override void UpdateImpl() { for (int i = onpus.Count - 1; i >= 0; i--) { OnpuObject onpu = onpus[i]; onpu.Position = new SharpDX.Vector2(onpu.Position.X + onpu.VelX, onpu.Position.Y); onpu.Alpha = (black.Position.X - onpu.Position.X) / (black.Width - black.Rectangle.Width); if (onpu.Alpha <= 0) { onpuSprite.RemoveChild(onpus[i]); onpus.RemoveAt(i); } } }
public void CreateOnpu(int num) { var r = new Random(); for (int i = 0; i < num; i++) { var po = new OnpuObject(device, resourceManager, Utility.Path.Combine("lifegage", "onpu", String.Format("{0}.png", r.Next(1, 6))), 5 + i * 3, 12, true); var scale = (float)(r.NextDouble() / 2 + 0.5); po.Scale = new Vector2(scale, scale); var rotation = (float)((r.NextDouble() - 0.5) * Math.PI / 8); po.Rotation = rotation; po.VelX = (float)((r.NextDouble() + 0.5) * 2); onpus.Add(po); onpuSprite.AddChild(po); } }