diff --git a/Pendu/Assets.xcassets/confetti.imageset/Contents.json b/Pendu/Assets.xcassets/confetti.imageset/Contents.json new file mode 100644 index 0000000000000000000000000000000000000000..72442ace320dc747890ce1827f44f8a25865cd19 --- /dev/null +++ b/Pendu/Assets.xcassets/confetti.imageset/Contents.json @@ -0,0 +1,21 @@ +{ + "images" : [ + { + "filename" : "pngegg.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "idiom" : "universal", + "scale" : "2x" + }, + { + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Pendu/Assets.xcassets/confetti.imageset/pngegg.png b/Pendu/Assets.xcassets/confetti.imageset/pngegg.png new file mode 100644 index 0000000000000000000000000000000000000000..9ecb818a15e1083bb2326513cc5f7bbb7ae118be Binary files /dev/null and b/Pendu/Assets.xcassets/confetti.imageset/pngegg.png differ diff --git a/Pendu/GameViewController.swift b/Pendu/GameViewController.swift index 7a64ba081b22df2b92625f660d2bff78c0cf7175..b2263ce4be1e91478c9595cab168a2b7658751c7 100644 --- a/Pendu/GameViewController.swift +++ b/Pendu/GameViewController.swift @@ -229,6 +229,34 @@ class GameViewController: UIViewController { V_Button.isHidden = true B_Button.isHidden = true N_Button.isHidden = true + + let emmitterLayer = CAEmitterLayer() + emmitterLayer.emitterPosition = CGPoint(x: view.bounds.width / 2, y: view.bounds.height / 2) + emmitterLayer.emitterShape = .point + emmitterLayer.emitterMode = .outline + emmitterLayer.emitterSize = CGSize(width: 5, height: 0) + + let confetti = CAEmitterCell() + confetti.birthRate = 3 + confetti.lifetime = 50 + confetti.velocity = 100 + confetti.velocityRange = 50 + confetti.emissionLongitude = .pi + confetti.spin = 2 + confetti.spinRange = 8 + confetti.scaleRange = 0.5 + confetti.contents = UIImage(named: "confetti.png")?.cgImage + + emmitterLayer.emitterCells = [confetti] + + view.layer.addSublayer(emmitterLayer) + + emmitterLayer.beginTime = CACurrentMediaTime() + + DispatchQueue.main.asyncAfter(deadline: .now() + 3) { + emmitterLayer.removeFromSuperlayer() + } + } }