From 7f6149c1b2e63af8c3ac4f2861b34a43e62a08e6 Mon Sep 17 00:00:00 2001 From: KatjaSimone Date: Thu, 13 Apr 2017 13:18:33 +0200 Subject: [PATCH] flappyBird_version1 --- FlappySwift.xcodeproj/project.pbxproj | 8 ++ FlappySwift/Base.lproj/Main.storyboard | 14 ++-- FlappySwift/FlyScene.sks | Bin 0 -> 3492 bytes FlappySwift/ViewController.swift | 11 +++ FlyScene.swift | 105 +++++++++++++++++++++++++ 5 files changed, 133 insertions(+), 5 deletions(-) create mode 100644 FlappySwift/FlyScene.sks create mode 100644 FlyScene.swift diff --git a/FlappySwift.xcodeproj/project.pbxproj b/FlappySwift.xcodeproj/project.pbxproj index d3612a2..932415d 100644 --- a/FlappySwift.xcodeproj/project.pbxproj +++ b/FlappySwift.xcodeproj/project.pbxproj @@ -13,6 +13,8 @@ 873BE2A61D06195B00A69FF5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 873BE2A51D06195B00A69FF5 /* Assets.xcassets */; }; 873BE2A91D06195B00A69FF5 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 873BE2A71D06195B00A69FF5 /* LaunchScreen.storyboard */; }; 87AA11DC1D0B4D6E006C614F /* bird.atlas in Resources */ = {isa = PBXBuildFile; fileRef = 87AA11DB1D0B4D6E006C614F /* bird.atlas */; }; + C2B44A101E9F7A9300CD4B11 /* FlyScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = C2B44A0F1E9F7A9300CD4B11 /* FlyScene.swift */; }; + C2B44A121E9F7B0800CD4B11 /* FlyScene.sks in Resources */ = {isa = PBXBuildFile; fileRef = C2B44A111E9F7B0800CD4B11 /* FlyScene.sks */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -24,6 +26,8 @@ 873BE2A81D06195B00A69FF5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 873BE2AA1D06195B00A69FF5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 87AA11DB1D0B4D6E006C614F /* bird.atlas */ = {isa = PBXFileReference; lastKnownFileType = folder.skatlas; path = bird.atlas; sourceTree = ""; }; + C2B44A0F1E9F7A9300CD4B11 /* FlyScene.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FlyScene.swift; path = ../FlyScene.swift; sourceTree = ""; }; + C2B44A111E9F7B0800CD4B11 /* FlyScene.sks */ = {isa = PBXFileReference; lastKnownFileType = file.sks; path = FlyScene.sks; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -58,6 +62,8 @@ children = ( 873BE29A1D06195B00A69FF5 /* AppDelegate.swift */, 873BE2A21D06195B00A69FF5 /* Main.storyboard */, + C2B44A0F1E9F7A9300CD4B11 /* FlyScene.swift */, + C2B44A111E9F7B0800CD4B11 /* FlyScene.sks */, 873BE2A01D06195B00A69FF5 /* ViewController.swift */, 873BE2A51D06195B00A69FF5 /* Assets.xcassets */, 87AA11DB1D0B4D6E006C614F /* bird.atlas */, @@ -137,6 +143,7 @@ 873BE2A91D06195B00A69FF5 /* LaunchScreen.storyboard in Resources */, 873BE2A61D06195B00A69FF5 /* Assets.xcassets in Resources */, 87AA11DC1D0B4D6E006C614F /* bird.atlas in Resources */, + C2B44A121E9F7B0800CD4B11 /* FlyScene.sks in Resources */, 873BE2A41D06195B00A69FF5 /* Main.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -149,6 +156,7 @@ buildActionMask = 2147483647; files = ( 873BE2A11D06195B00A69FF5 /* ViewController.swift in Sources */, + C2B44A101E9F7A9300CD4B11 /* FlyScene.swift in Sources */, 873BE29B1D06195B00A69FF5 /* AppDelegate.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/FlappySwift/Base.lproj/Main.storyboard b/FlappySwift/Base.lproj/Main.storyboard index af837b3..4a56362 100644 --- a/FlappySwift/Base.lproj/Main.storyboard +++ b/FlappySwift/Base.lproj/Main.storyboard @@ -1,8 +1,12 @@ - - + + + + + - + + @@ -14,9 +18,9 @@ - + - + diff --git a/FlappySwift/FlyScene.sks b/FlappySwift/FlyScene.sks new file mode 100644 index 0000000000000000000000000000000000000000..647b6ce0ca9edc0f8d17802a4efb6ff121df5991 GIT binary patch literal 3492 zcmaJ@32+?675zOuvvUYrE6JDSOO}K!+p>@>OFpQ?NVYMtun<~Ht9uyjj#h(4Gt11Z z%~}{58!+Yu1I7?zAsZ5G5}-mQh6Dl$MJiNM6c|$wNVp0DRH%Xw&T!<<%t{;~*{a^| z`Q5*N|KIPw{sU>#aJ`zEXMq3*6nGFILQ2Vk&Wf$N;~KWrSz!;Ht0z3St3q=ULk5bs zRCso}5Xfa?_eM_z5hUn>Za4=tNWl;ouno?KENq8SxBxDKov;fofy?1axCX9;U&628 z*YI0-435B2_&q!g&%kkb7G8kAz+d5c_#3&m=C3} z0Lq{oD&S;T2#cT+7Q+%)3RSQSs^Ju2|B^ByJ}d2c3e$pBf6t?s{^KPB{$ni zysZO=}rf zPj;$yT1yySwq3Q*m+#rCtykS@xCUBoL%V%yI`l4XJ7%&=#XX$$nuj6CP8_FG&EFi$(XF^T7=(kBF_BRgVZf@e0b9VPv)R~7 z*ygesI6DVtr?YBoA}dAd!r;SEv3&UvFg!5o4Dpex}UEgAk6%NA)SYSh%$xLB+?4-lsfD0aE*c3LE zMOgtWRHLP8Ym=IG^sR=zE!NzE*S9X?diF?w#g^c@=6`cZfah3{0_~PDXgec_p0aPQ zXx@-CJlhGfD~1?5LpM@Go*G^7{}#oKq&L)gx`{}|yL%>ZYzJI8#`42hF}N6AY;+tg zJC1iYShoJIN1<%}sSHWVkL9IsnHnu>iEYk!K7iL7K@Mq7_7G0(hQZ#J*w?af`#o^Q z7@HQVUj=`r1~{0l`%EM_DI^WQthgX z(ZU=vn|iCGIj<>rs>oDdfmh1z(Mbzp_|Dj!`rO6!#$4fdWM$?`6@rRWruFs ze#T+0X+bXQ$)@Z^N81|6W+FQA2?=-Gg8I3=`c1>qHD^M(bI=LH7*A#qp+*98d`L^{ zTe4|9W`08R^px#nbILI_U4z+}z|&$X+g488r*v^ zLZi7LbYLVbJsC${L=MiDuYGX;{xL*6n<*82mHU;i{bMMUqrhe{e)3z2a*UVD*R~F9 zeg$nH}LCFx_|51428yI;KC4UMql0x+OD0vDSq9m?5L7b#XH|6g*O#-KP zTKgC}jmu6v#!3VC-%+1`G#I>l|HETAI1VQQo_Y>>>Up0j9E1SU6e~w=qH1*dXh=_0 zrK2nBk*I3x>Q?O7F`@OMuf@zr9#)R(Cnrie9|8o002LHYjOQX->3-}W0B-R|hkv?H|guIEw-=@21+rsKV zjTR^Dk!mfSHg$Xf{2E}`@T!A{={O;TgSmtfo(NqkKGaxjpsOnSnjUglEnCj&0yl{m zxS0bXQAi$aMGzJSAS6>setctyzi~1Z1}Bykkm>NqAyP<+$TU{Z8raH1WCoc@X0cUl zHCw|<{0BHZQ?uc9gta7+XZUP}mcH2(~p?3Lb+;h(;`uCA-Kz za**6Z9wL7xuadXPCmi8KE}tvm7IQ1OOF$l#muK5-t;V3$F?93m->HB8wt*kqwcqh#T1%xiYdha(m>y$ODl- zL{3Crio6y1DDs6Uh*QO=SRj^&OQmH}wX{-NB{fQ$q?mM$G%Srs zwsfAfN4ifwCOs{^E`2C{Aq(;pIbSZ2i{$C@Ou1BEAeYNka;;n^*UKyAMtPIm zCHKoC@^<+G`9gV*e1m*IJ|f>QKPzbU^beD~r%1mXJQmo8YDwHav zR{5c_LD{JMNNHBulr2h!(y4SSmU4-5K)Fjfsyv`Pp}eTPoi{bFC~r<)Szbln!o147 TCCHih, with event: UIEvent?) { + + if self.speed == 0 { + self.speed = 1 + self.physicsWorld.speed = 1 + bird.position = CGPoint(x: -100, y: -100) + bird.physicsBody?.velocity = CGVector(dx: 0, dy: 0) + for obstacle in obstacles.children { + obstacle.removeFromParent() + } + + } + + bird.physicsBody?.applyImpulse(CGVector(dx: 0, dy: impulseOnFlap)) + } + + func didBegin(_ contact: SKPhysicsContact) { + print("Game over!") + self.speed = 0 + self.physicsWorld.speed = 0 + } +}