Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 13

{\rtf1\ansi\ansicpg1252\cocoartf1343\cocoasubrtf140

{\fonttbl\f0\fnil\fcharset0 Menlo-Regular;}
{\colortbl;\red255\green255\blue255;\red0\green116\blue0;\red100\green56\blue32;
\red196\green26\blue22;
\red170\green13\blue145;\red92\green38\blue153;\red46\green13\blue110;\red28\gre
en0\blue207;\red63\green110\blue116;
\red38\green71\blue75;}
\margl1440\margr1440\vieww10800\viewh8400\viewkind0
\deftab529
\pard\tx529\pardeftab529\pardirnatural
\f0\fs22 \cf2 \CocoaLigature0 //\cf0 \
\cf2 // GameScene.m\cf0 \
\cf2 // squares\cf0 \
\cf2 //\cf0 \
\cf2 // Created by William Wang on 11/28/14.\cf0 \
\cf2 // Copyright (c) 2014 williamwang. All rights reserved.\cf0 \
\cf2 //\cf0 \
\
\cf3 #import \cf4 "GameScene.h"\cf3 \
\cf0 \
\cf5 @implementation\cf0 GameScene\
\
\cf2 //list of global variables\cf0 \
\{\
\cf2 //provides the current scene the user is in to interpret touch actions
differently\cf0 \
\cf6 NSString\cf0 *currentScene;\
\cf6 NSArray\cf0 *currentSceneList;\
\
\cf2 //nodes\cf0 \
\cf6 SKLabelNode\cf0 *title;\
\cf6 SKSpriteNode\cf0 *playerSquare;\
\cf6 SKSpriteNode\cf0 *playButton;\
\cf6 SKSpriteNode\cf0 *otherButton;\
\
\cf2 //used to define actions for nodes to do\cf0 \
\cf6 SKAction\cf0 *fadeAway;\
\cf6 SKAction\cf0 *fadeIn;\
\
\cf2 //used in multiple places to keep track of loop iterations\cf0 \
\cf5 int\cf0 numTimes;\
\
\cf2 //the smallest float value for playerSquare's method setScale\cf0 \
\cf5 float\cf0 smallestScale;\
\
\cf2 //the dimensions of the original playerSquare sprite\cf0 \
\cf6 CGPoint\cf0 playerSquareOriginalSize;\
\
\cf2 //used to regulate actions such as moving playerSquare by storing the a
mount of milliseconds that have passed since the last time -(void)update was cal
led\cf0 \
\cf6 NSTimeInterval\cf0 lastUpdateTime;\
\cf6 NSTimeInterval\cf0 dt;\
\
\cf2 //used as the string where each character of a line from lineNumberList
if concatenated to produce a typing effect\cf0 \
\cf6 NSString\cf0 *newText;\
\
\cf2 //the nodes for the lines of text\cf0 \

\cf6 NSArray\cf0 *lines;\


\cf6 SKLabelNode\cf0 *line1;\
\cf6 SKLabelNode\cf0 *line2;\
\cf6 SKLabelNode\cf0 *line3;\
\cf6 SKLabelNode\cf0 *line4;\
\cf6 SKLabelNode\cf0 *line5;\
\cf6 SKLabelNode\cf0 *line6;\
\cf6 SKLabelNode\cf0 *line7;\
\cf6 SKLabelNode\cf0 *line8;\
\cf6 SKLabelNode\cf0 *line9;\
\cf6 SKLabelNode\cf0 *line10;\
\cf6 SKLabelNode\cf0 *line11;\
\
\cf2 //the lines of text in otherScene\cf0 \
\cf6 NSArray\cf0 *lineNumberList;\
\cf6 NSArray\cf0 *line1List;\
\cf6 NSArray\cf0 *line2List;\
\cf6 NSArray\cf0 *line3List;\
\cf6 NSArray\cf0 *line4List;\
\cf6 NSArray\cf0 *line5List;\
\cf6 NSArray\cf0 *line6List;\
\cf6 NSArray\cf0 *line7List;\
\cf6 NSArray\cf0 *line8List;\
\cf6 NSArray\cf0 *line9List;\
\cf6 NSArray\cf0 *line10List;\
\cf6 NSArray\cf0 *line11List;\
\
\cf2 //boolean values used to know when to do certain methods everytime -(vo
id)update is called\cf0 \
\cf5 BOOL\cf0 transitioningShrink;\
\cf5 BOOL\cf0 transitioningMove;\
\cf5 BOOL\cf0 transitioningType;\
\cf5 BOOL\cf0 transitioningType1;\
\cf5 BOOL\cf0 transitioningType2;\
\cf5 BOOL\cf0 transitioningType3;\
\cf5 BOOL\cf0 transitioningType4;\
\cf5 BOOL\cf0 transitioningType5;\
\cf5 BOOL\cf0 transitioningType6;\
\cf5 BOOL\cf0 transitioningType7;\
\cf5 BOOL\cf0 transitioningType8;\
\cf5 BOOL\cf0 transitioningType9;\
\cf5 BOOL\cf0 transitioningType10;\
\cf5 BOOL\cf0 transitioningType11;\
\}\
\
\cf2 //runs at the start of the program\cf0 \
-(\cf5 id\cf0 )initWithSize:(\cf6 CGSize\cf0 )size\
\{\
\cf5 if\cf0 (\cf5 self\cf0 = [\cf5 super\cf0 \cf7 initWithSize\cf0 :size]
) \{\
\cf5 self\cf0 .\cf6 backgroundColor\cf0 = [\cf3 SKColor\cf0 \cf7 color
WithRed\cf0 :\cf8 22.0\cf0 \cf7 green\cf0 :\cf8 22.0\cf0 \cf7 blue\cf0 :\cf8 2
2.0\cf0 \cf7 alpha\cf0 :\cf8 .115\cf0 ];\
\
\cf9 currentScene\cf0 = \cf4 @"menuScene"\cf0 ;\
\
\cf9 fadeAway\cf0 = [\cf6 SKAction\cf0 \cf7 fadeOutWithDuration\cf0 :\
cf8 1\cf0 ];\
\cf9 fadeIn\cf0 = [\cf6 SKAction\cf0 \cf7 fadeInWithDuration\cf0 :\cf8
1\cf0 ];\

\
\cf9 numTimes\cf0 = \cf8 1\cf0 ;\
\cf9 newText\cf0 = \cf4 @""\cf0 ;\
\
\cf2 //boolean values accessed from an array cannot be changed, and an a
rray of these values are only needed in one method, so the array of these boolea
n values is defined in the function and kept as a local variable\cf0 \
\cf9 transitioningShrink\cf0 = \cf5 false\cf0 ;\
\cf9 transitioningMove\cf0 = \cf5 false\cf0 ;\
\cf9 transitioningType\cf0 = \cf5 false\cf0 ;\
\cf9 transitioningType1\cf0 = \cf5 false\cf0 ;\
\cf9 transitioningType2\cf0 = \cf5 false\cf0 ;\
\cf9 transitioningType3\cf0 = \cf5 false\cf0 ;\
\cf9 transitioningType4\cf0 = \cf5 false\cf0 ;\
\cf9 transitioningType5\cf0 = \cf5 false\cf0 ;\
\cf9 transitioningType6\cf0 = \cf5 false\cf0 ;\
\cf9 transitioningType7\cf0 = \cf5 false\cf0 ;\
\cf9 transitioningType8\cf0 = \cf5 false\cf0 ;\
\cf9 transitioningType9\cf0 = \cf5 false\cf0 ;\
\cf9 transitioningType10\cf0 = \cf5 false\cf0 ;\
\cf9 transitioningType11\cf0 = \cf5 false\cf0 ;\
\
\cf2 //nodes must first be assigned before being put in a NSArray.\cf0 \
\cf9 line1\cf0 = [\cf6 SKLabelNode\cf0 \cf7 labelNodeWithFontNamed\cf0
:\cf4 @"American Typewriter Light"\cf0 ];\
\cf9 line2\cf0 = [\cf6 SKLabelNode\cf0 \cf7 labelNodeWithFontNamed\cf0
:\cf4 @"American Typewriter Light"\cf0 ];\
\cf9 line3\cf0 = [\cf6 SKLabelNode\cf0 \cf7 labelNodeWithFontNamed\cf0
:\cf4 @"American Typewriter Light"\cf0 ];\
\cf9 line4\cf0 = [\cf6 SKLabelNode\cf0 \cf7 labelNodeWithFontNamed\cf0
:\cf4 @"American Typewriter Light"\cf0 ];\
\cf9 line5\cf0 = [\cf6 SKLabelNode\cf0 \cf7 labelNodeWithFontNamed\cf0
:\cf4 @"American Typewriter Light"\cf0 ];\
\cf9 line6\cf0 = [\cf6 SKLabelNode\cf0 \cf7 labelNodeWithFontNamed\cf0
:\cf4 @"American Typewriter Light"\cf0 ];\
\cf9 line7\cf0 = [\cf6 SKLabelNode\cf0 \cf7 labelNodeWithFontNamed\cf0
:\cf4 @"American Typewriter Light"\cf0 ];\
\cf9 line8\cf0 = [\cf6 SKLabelNode\cf0 \cf7 labelNodeWithFontNamed\cf0
:\cf4 @"American Typewriter Light"\cf0 ];\
\cf9 line9\cf0 = [\cf6 SKLabelNode\cf0 \cf7 labelNodeWithFontNamed\cf0
:\cf4 @"American Typewriter Light"\cf0 ];\
\cf9 line10\cf0 = [\cf6 SKLabelNode\cf0 \cf7 labelNodeWithFontNamed\cf
0 :\cf4 @"American Typewriter Light"\cf0 ];\
\cf9 line11\cf0 = [\cf6 SKLabelNode\cf0 \cf7 labelNodeWithFontNamed\cf
0 :\cf4 @"American Typewriter Light"\cf0 ];\
\
\cf2 //the lists of characters of a line; used to create a typing effect
\cf0 \
\cf9 line1List\cf0 = \cf8 @[\cf4 @"T"\cf0 ,\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"\cf0 ,\cf4 @"."\cf8 ]\cf0 ;\
\cf9 line10List\cf0 = \cf8 @[\cf4 @"G"\cf0 ,\cf4 @"o"\cf0 ,\cf4 @"o"\cf
0 ,\cf4 @"d"\cf0 ,\cf4 @" "\cf0 ,\cf4 @"l"\cf0 ,\cf4 @"u"\cf0 ,\cf4 @"c"\cf0 ,\c
f4 @"k"\cf0 ,\cf4 @"!"\cf0 ,\cf8 ]\cf0 ;\
\cf9 line11List\cf0 = \cf8 @[\cf4 @"b"\cf0 ,\cf4 @"y"\cf0 ,\cf4 @" "\cf
0 ,\cf4 @"W"\cf0 ,\cf4 @"i"\cf0 ,\cf4 @"l"\cf0 ,\cf4 @"l"\cf0 ,\cf4 @"i"\cf0 ,\c
f4 @"a"\cf0 ,\cf4 @"m"\cf0 ,\cf4 @" "\cf0 ,\cf4 @"W"\cf0 ,\cf4 @"a"\cf0 ,\cf4 @"
n"\cf0 ,\cf4 @"g"\cf0 ,\cf8 ]\cf0 ;\
\
\cf2 //lists of certain values related to each other so code is less rep
etitive\cf0 \
\cf9 lines\cf0 = \cf8 @[\cf9 line1\cf0 ,\cf9 line2\cf0 ,\cf9 line3\cf0
,\cf9 line4\cf0 ,\cf9 line5\cf0 ,\cf9 line6\cf0 ,\cf9 line7\cf0 ,\cf9 line8\cf0
,\cf9 line9\cf0 ,\cf9 line10\cf0 ,\cf9 line11\cf8 ]\cf0 ;\
\cf9 lineNumberList\cf0 = \cf8 @[\cf9 line1List\cf0 ,\cf9 line2List\cf0
,\cf9 line3List\cf0 ,\cf9 line4List\cf0 ,\cf9 line5List\cf0 ,\cf9 line6List\cf0
,\cf9 line7List\cf0 ,\cf9 line8List\cf0 ,\cf9 line9List\cf0 ,\cf9 line10List\cf
0 ,\cf9 line11List\cf8 ]\cf0 ;\
\cf9 currentSceneList\cf0 = \cf8 @[\cf4 @"menuScene"\cf0 ,\cf4 @"menuSc
eneFromOtherScene"\cf0 ,\cf4 @"menuSceneFromEndScene"\cf0 ,\cf4 @"otherScene"\cf
0 ,\cf4 @"gameSceneFromMenuScene"\cf0 ,\cf4 @"gameSceneFromEndScene"\cf0 ,\cf4 @
"endScene"\cf8 ]\cf0 ;\
\
\cf2 //nodes that will appear at the start\cf0 \
\cf9 playerSquare\cf0 = [\cf6 SKSpriteNode\cf0 \cf7 spriteNodeWithImag
eNamed\cf0 :\cf4 @"playersquare"\cf0 ];\
\cf9 playerSquare\cf0 .\cf6 position\cf0 = \cf7 CGPointMake\cf0 (\cf5 s
elf\cf0 .\cf6 size\cf0 .\cf6 width\cf0 * \cf8 .5\cf0 ,\cf5 self\cf0 .\cf6 size\
cf0 .\cf6 height\cf0 * \cf8 .7\cf0 );\
\
\cf9 title\cf0 = [\cf6 SKLabelNode\cf0 \cf7 labelNodeWithFontNamed\cf0
:\cf4 @"American Typewriter Light"\cf0 ];\
\cf9 title\cf0 .\cf6 text\cf0 = \cf4 @"SQUARES"\cf0 ;\
\cf9 title\cf0 .\cf6 fontSize\cf0 = \cf8 40\cf0 ;\
\cf9 title\cf0 .\cf6 position\cf0 = \cf7 CGPointMake\cf0 (\cf5 self\cf0
.\cf6 size\cf0 .\cf6 width\cf0 * \cf8 .5\cf0 ,\cf5 self\cf0 .\cf6 size\cf0 .\c
f6 height\cf0 * \cf8 .7\cf0 );\
\cf9 title\cf0 .\cf6 name\cf0 = \cf4 @"titleNode"\cf0 ;\
\cf9 title\cf0 .\cf6 zPosition\cf0 = \cf8 1.0\cf0 ;\
\
\cf9 playButton\cf0 = [\cf6 SKSpriteNode\cf0 \cf7 spriteNodeWithImageN
amed\cf0 :\cf4 @"playlabel"\cf0 ];\
\cf9 playButton\cf0 .\cf6 position\cf0 = \cf7 CGPointMake\cf0 (\cf5 sel
f\cf0 .\cf6 size\cf0 .\cf6 width\cf0 * \cf8 .5\cf0 ,\cf5 self\cf0 .\cf6 size\cf
0 .\cf6 height\cf0 * \cf8 .4\cf0 );\
\cf9 playButton\cf0 .\cf6 name\cf0 = \cf4 @"playButtonNode"\cf0 ;\
\cf9 playButton\cf0 .\cf6 zPosition\cf0 = \cf8 1.0\cf0 ;\
\
\cf9 otherButton\cf0 = [\cf6 SKSpriteNode\cf0 \cf7 spriteNodeWithImage
Named\cf0 :\cf4 @"otherlabel"\cf0 ];\
\cf9 otherButton\cf0 .\cf6 position\cf0 = \cf7 CGPointMake\cf0 (\cf5 se
lf\cf0 .\cf6 size\cf0 .\cf6 width\cf0 * \cf8 .5\cf0 ,\cf5 self\cf0 .\cf6 size\c
f0 .\cf6 height\cf0 * \cf8 .2\cf0 );\
\cf9 otherButton\cf0 .\cf6 name\cf0 = \cf4 @"otherButtonNode"\cf0 ;\
\cf9 otherButton\cf0 .\cf6 zPosition\cf0 = \cf8 1.0\cf0 ;\

\
\
[\cf5 self\cf0 \cf7 addChild\cf0 :\cf9 title\cf0 ];\
[\cf5 self\cf0 \cf7 addChild\cf0 :\cf9 playerSquare\cf0 ];\
[\cf5 self\cf0 \cf7 addChild\cf0 :\cf9 playButton\cf0 ];\
[\cf5 self\cf0 \cf7 addChild\cf0 :\cf9 otherButton\cf0 ];\
\
\cf9 playerSquareOriginalSize\cf0 = \cf7 CGPointMake\cf0 (\cf9 playerSq
uare\cf0 .\cf6 size\cf0 .\cf6 width\cf0 , \cf9 playerSquare\cf0 .\cf6 size\cf0 .
\cf6 height\cf0 );\
\}\
\cf5 return\cf0 \cf5 self\cf0 ;\
\}\
\
\cf2 //executed whenever the user touches the screen\cf0 \
-(\cf5 void\cf0 )touchesBegan:(\cf6 NSSet\cf0 *)touches withEvent:(\cf6 UIEvent
\cf0 *)event\
\{\
\cf2 //creates the coordinates of where the user touched\cf0 \
\cf6 UITouch\cf0 *touch = [touches \cf7 anyObject\cf0 ];\
\cf6 CGPoint\cf0 location = [touch \cf7 locationInNode\cf0 :\cf5 self\cf0 ]
;\
\
\cf2 //checks if there are any nodes in the area and stores it in node\cf0 \
\cf6 SKNode\cf0 *node = [\cf5 self\cf0 \cf7 nodeAtPoint\cf0 :location];\
\
\cf2 //checks which scene it currently is in\cf0 \
\cf5 if\cf0 (\cf9 currentScene\cf0 == \cf9 currentSceneList\cf0 [\cf8 0\cf
0 ] || \cf9 currentScene\cf0 == \cf9 currentSceneList\cf0 [\cf8 1\cf0 ]) \{\
\cf2 //checks to see what node the user touched, if any\cf0 \
\cf5 if\cf0 ([node.\cf6 name\cf0 \cf7 isEqualToString\cf0 :\cf4 @"play
ButtonNode"\cf0 ]) \{\
[\cf5 self\cf0 \cf10 createGameScene\cf0 ];\
\} \cf5 else\cf0 \cf5 if\cf0 ([node.\cf6 name\cf0 \cf7 isEqualToStrin
g\cf0 :\cf4 @"otherButtonNode"\cf0 ])\{\
[\cf5 self\cf0 \cf10 createOtherScene\cf0 ];\
\}\
\} \cf5 else\cf0 \cf5 if\cf0 (\cf9 currentScene\cf0 == \cf9 currentSceneL
ist\cf0 [\cf8 3\cf0 ]) \{\
\cf5 if\cf0 ([node.\cf6 name\cf0 \cf7 isEqualToString\cf0 :\cf4 @"titl
eNode"\cf0 ]) \{\
[\cf5 self\cf0 \cf10 createMenuScene\cf0 ];\
\}\
\}\
\}\
\
\cf2 //executed every time before the device shows a new frame\cf0 \
-(\cf5 void\cf0 )update:(\cf6 CFTimeInterval\cf0 )currentTime \{\
\cf2 //checks to see if we must do a transition into another scene, such as
moving playerSquare\cf0 \
\cf5 if\cf0 (\cf9 transitioningShrink\cf0 || \cf9 transitioningMove\cf0 |
| \cf9 transitioningType\cf0 ) \{\
\cf2 //executes a method that will do a transition with currentTime, a C
FTimeInterval that stores what time it was when -(void)update was just called\cf
0 \
[\cf5 self\cf0 \cf10 doTransitions\cf0 :currentTime];\
\}\
\}\
\
\cf2 //executed when called to do so, it creates the menuScene\cf0 \

-(\cf5 void\cf0 )createMenuScene\


\{\
\cf2 //checks to see what scene it is coming from using a list of possible c
urrentScenes\cf0 \
\cf5 if\cf0 (\cf9 currentScene\cf0 == \cf9 currentSceneList\cf0 [\cf8 3\cf
0 ]) \{\
\cf2 //this code is executed when the user is coming from otherScene\cf0
\
\
\cf2 //this removes all the lines of text from otherScene\cf0 \
\cf5 for\cf0 (\cf6 SKLabelNode\cf0 *line \cf5 in\cf0 \cf9 lines\cf0 )
\{\
[line \cf7 removeFromParent\cf0 ];\
\}\
\
\cf2 //this makes nodes fade back in as well as out using methods I defi
ned\cf0 \
[\cf9 playButton\cf0 \cf7 runAction\cf0 :\cf9 fadeIn\cf0 ];\
[\cf9 otherButton\cf0 \cf7 runAction\cf0 :\cf9 fadeIn\cf0 ];\
[\cf9 title\cf0 \cf7 runAction\cf0 :\cf9 fadeAway\cf0 ];\
\
\cf2 //changes the currentScene so that (void)update and the methods it
calls can do correct transitions\cf0 \
\cf9 currentScene\cf0 = \cf4 @"menuSceneFromOtherScene"\cf0 ;\
\
\cf2 //changes a boolean value so that (void)update and the methods it c
alls can start doing the correct transitions\cf0 \
\cf9 transitioningMove\cf0 = \cf5 true\cf0 ;\
\}\
\}\
\
\cf2 //executed when called to do so, it creates the gameScene (currently, I hav
e not created the game yet)\cf0 \
-(\cf5 void\cf0 )createGameScene\
\{\
\cf9 currentScene\cf0 = \cf4 @"gameScene"\cf0 ;\
\}\
\
\cf2 //executed when called to do so, it creates the endScene (currently, I have
not created the game yet)\cf0 \
-(\cf5 void\cf0 )createEndScene\
\{\
\cf9 currentScene\cf0 = \cf4 @"endScene"\cf0 ;\
\}\
\
\cf2 //executed when called to do so, it creates the otherScene\cf0 \
-(\cf5 void\cf0 )createOtherScene\
\{\
\cf2 //this makes nodes fade out using a method I defined\cf0 \
[\cf9 playButton\cf0 \cf7 runAction\cf0 :\cf9 fadeAway\cf0 ];\
[\cf9 otherButton\cf0 \cf7 runAction\cf0 :\cf9 fadeAway\cf0 ];\
[\cf9 title\cf0 \cf7 runAction\cf0 :\cf9 fadeAway\cf0 ];\
\
\cf2 //changes the currentScene so that (void)update and the methods it call
s can do correct transitions\cf0 \
\cf9 currentScene\cf0 = \cf4 @"otherScene"\cf0 ;\
\
\cf2 //changes a boolean value so that (void)update and the methods it calls
can start doing the correct transitions\cf0 \
\cf9 transitioningShrink\cf0 = \cf5 true\cf0 ;\

\}\
\
\cf2 //executed when -(void)update confirms that a transition should be started\
cf0 \
-(\cf5 void\cf0 )doTransitions:(\cf6 CFTimeInterval\cf0 )currentTime\
\{\
\cf2 //checks to see what currentScene is as well as what transition it shou
ld be in order to do the correct transition\cf0 \
\cf5 if\cf0 ((\cf9 currentScene\cf0 == \cf9 currentSceneList\cf0 [\cf8 3\c
f0 ]) && \cf9 transitioningShrink\cf0 ) \{\
\cf2 //checks to see if current size of playerSquare is small enough to
stop shrinking it\cf0 \
\cf5 if\cf0 ((\cf9 playerSquare\cf0 .\cf6 size\cf0 .\cf6 width\cf0 > \
cf9 playerSquareOriginalSize\cf0 .\cf6 x\cf0 / \cf8 2\cf0 ) && (\cf9 playerSqua
re\cf0 .\cf6 size\cf0 .\cf6 height\cf0 > \cf9 playerSquareOriginalSize\cf0 .\cf
6 y\cf0 / \cf8 2\cf0 )) \{\
\cf2 //figures out the amount of time that has passed and adds it to
dt (delta time)\cf0 \
\cf5 if\cf0 (\cf9 lastUpdateTime\cf0 ) \{\
\cf9 dt\cf0 = \cf9 dt\cf0 + (currentTime - \cf9 lastUpdateTime
\cf0 );\
\} \cf5 else\cf0 \{\
\cf2 //this will only happpen the first time that this method is
called, because there was no lastUpdate time; therefore, dt is 0\cf0 \
\cf9 dt\cf0 = \cf8 0\cf0 ;\
\}\
\
\cf2 //changes what time it was last time to the time now for the ne
xt iteration\cf0 \
\cf9 lastUpdateTime\cf0 = currentTime;\
\
\cf2 //checks to see if a certain number of milliseconds has passed
in order to keep the transition from being irregular\cf0 \
\cf5 if\cf0 (\cf9 dt\cf0 * \cf8 1000\cf0 > \cf8 30\cf0 ) \{\
\cf2 //shrinks playerSquare and title by a certain amount using
numTimes\cf0 \
[\cf9 playerSquare\cf0 \cf7 setScale\cf0 :\cf8 1\cf0 - (\cf9 n
umTimes\cf0 * \cf8 .01\cf0 )];\
[\cf9 title\cf0 \cf7 setScale\cf0 :\cf8 1\cf0 - (\cf9 numTimes
\cf0 * \cf8 .01\cf0 )];\
\
\cf2 //resets dt back to zero\cf0 \
\cf9 dt\cf0 = \cf8 0\cf0 ;\
\
\cf2 //adds 1 to numTimes to shrink the 2 nodes more\cf0 \
\cf9 numTimes\cf0 ++;\
\}\
\} \cf5 else\cf0 \{\
\cf2 //executed when the transition is finished\cf0 \
\
\cf2 //changes boolean values to stop executing this method and star
t executing another transition\cf0 \
\cf9 transitioningShrink\cf0 = \cf5 false\cf0 ;\
\cf9 transitioningMove\cf0 = \cf5 true\cf0 ;\
\
\cf2 //stores what the final float for setScale was for this transit
ion\cf0 \
\cf9 smallestScale\cf0 = \cf8 1\cf0 - (\cf9 numTimes\cf0 * \cf8 .
01\cf0 );\
\

\cf2 //resets numTimes, but this time to 0 for another use\cf0 \


\cf9 numTimes\cf0 = \cf8 0\cf0 ;\
\}\
\} \cf5 else\cf0 \cf5 if\cf0 ((\cf9 currentScene\cf0 == \cf9 currentScene
List\cf0 [\cf8 3\cf0 ]) && \cf9 transitioningMove\cf0 ) \{\
\cf2 //checks to see if playerSquare has moved up enough\cf0 \
\cf5 if\cf0 (\cf9 playerSquare\cf0 .\cf6 position\cf0 .\cf6 y\cf0 < \c
f5 self\cf0 .\cf6 size\cf0 .\cf6 height\cf0 * \cf8 .85\cf0 ) \{\
\cf2 //same as before\cf0 \
\cf5 if\cf0 (\cf9 lastUpdateTime\cf0 ) \{\
\cf9 dt\cf0 = \cf9 dt\cf0 + (currentTime - \cf9 lastUpdateTime
\cf0 );\
\} \cf5 else\cf0 \{\
\cf9 dt\cf0 = \cf8 0\cf0 ;\
\}\
\cf9 lastUpdateTime\cf0 = currentTime;\
\
\cf5 if\cf0 (\cf9 dt\cf0 * \cf8 1000\cf0 > \cf8 30\cf0 ) \{\
\cf2 //changes playerSquare and title's positions to be 2 pixels
higher\cf0 \
\cf9 playerSquare\cf0 .\cf6 position\cf0 = \cf7 CGPointMake\cf0
(\cf9 playerSquare\cf0 .\cf6 position\cf0 .\cf6 x\cf0 , \cf9 playerSquare\cf0 .
\cf6 position\cf0 .\cf6 y\cf0 + \cf8 2\cf0 );\
\cf9 title\cf0 .\cf6 position\cf0 = \cf7 CGPointMake\cf0 (\cf9
playerSquare\cf0 .\cf6 position\cf0 .\cf6 x\cf0 , \cf9 playerSquare\cf0 .\cf6 po
sition\cf0 .\cf6 y\cf0 );\
\
\cf2 //same as before\cf0 \
\cf9 dt\cf0 = \cf8 0\cf0 ;\
\}\
\} \cf5 else\cf0 \{\
\cf2 //same as before\cf0 \
\cf9 transitioningMove\cf0 = \cf5 false\cf0 ;\
\cf9 transitioningType\cf0 = \cf5 true\cf0 ;\
\cf9 transitioningType1\cf0 = \cf5 true\cf0 ;\
\
\cf2 //changes title's text and makes it fade back in\cf0 \
\cf9 title\cf0 .\cf6 text\cf0 = \cf4 @"BACK"\cf0 ;\
[\cf9 title\cf0 \cf7 runAction\cf0 :\cf9 fadeIn\cf0 ];\
\
\cf2 //creates the positions for each line in NSArray lines as well
as other parameters and adds them to the screen\cf0 \
\cf5 float\cf0 screenPercentage = \cf8 .7\cf0 ;\
\cf5 for\cf0 (\cf6 SKLabelNode\cf0 *line \cf5 in\cf0 \cf9 lines\c
f0 ) \{\
line.\cf6 text\cf0 = \cf4 @""\cf0 ;\
line.\cf6 fontSize\cf0 = \cf8 14\cf0 ;\
line.\cf6 position\cf0 = \cf7 CGPointMake\cf0 (\cf5 self\cf0 .\
cf6 size\cf0 .\cf6 width\cf0 * \cf8 .5\cf0 ,\cf5 self\cf0 .\cf6 size\cf0 .\cf6
height\cf0 * screenPercentage);\
[\cf5 self\cf0 \cf7 addChild\cf0 :line];\
\
\cf2 //changes screenPercentage so that each line of text's posi
tion is different\cf0 \
screenPercentage = screenPercentage - \cf8 .05\cf0 ;\
\}\
\}\
\} \cf5 else\cf0 \cf5 if\cf0 ((\cf9 currentScene\cf0 == \cf9 currentScene
List\cf0 [\cf8 3\cf0 ]) && \cf9 transitioningType\cf0 ) \{\
\cf2 //creates the list of boolean variables specifically for the typing

transition\cf0 \
\cf5 BOOL\cf0 transitioningTypeList[\cf8 12\cf0 ] = \{\cf9 transitionin
gType1\cf0 ,\cf9 transitioningType2\cf0 ,\cf9 transitioningType3\cf0 ,\cf9 trans
itioningType4\cf0 ,\cf9 transitioningType5\cf0 ,\cf9 transitioningType6\cf0 ,\cf
9 transitioningType7\cf0 ,\cf9 transitioningType8\cf0 ,\cf9 transitioningType9\c
f0 ,\cf9 transitioningType10\cf0 ,\cf9 transitioningType11\cf0 ,\cf9 transitioni
ngType\cf0 \};\
\
\cf2 //the for loop makes the method executed for each line of text\cf0
\
\cf5 for\cf0 (\cf5 int\cf0 i = \cf8 0\cf0 ; i < \cf8 11\cf0 ; i ++) \{
\
\cf5 if\cf0 (transitioningTypeList[i]) \{\
\cf2 //another method is executed to keep this method simpler\cf
0 \
[\cf5 self\cf0 \cf10 type\cf0 :\cf9 lines\cf0 [i] \cf10 with\cf
0 :\cf9 lineNumberList\cf0 [i] \cf10 and\cf0 :currentTime];\
\}\
\}\
\} \cf5 else\cf0 \cf5 if\cf0 ((\cf9 currentScene\cf0 == \cf9 currentScene
List\cf0 [\cf8 1\cf0 ]) && \cf9 transitioningMove\cf0 ) \{\
\cf5 if\cf0 (\cf9 playerSquare\cf0 .\cf6 position\cf0 .\cf6 y\cf0 > \c
f5 self\cf0 .\cf6 size\cf0 .\cf6 height\cf0 * \cf8 .7\cf0 ) \{\
\cf2 //same as before\cf0 \
\cf5 if\cf0 (\cf9 lastUpdateTime\cf0 ) \{\
\cf9 dt\cf0 = \cf9 dt\cf0 + (currentTime - \cf9 lastUpdateTime
\cf0 );\
\} \cf5 else\cf0 \{\
\cf9 dt\cf0 = \cf8 0\cf0 ;\
\}\
\cf9 lastUpdateTime\cf0 = currentTime;\
\
\cf5 if\cf0 (\cf9 dt\cf0 * \cf8 1000\cf0 > \cf8 30\cf0 ) \{\
\cf2 //this time, the positions of playerSquare and title are be
ing moved down 2 pixels every time\cf0 \
\cf9 playerSquare\cf0 .\cf6 position\cf0 = \cf7 CGPointMake\cf0
(\cf9 playerSquare\cf0 .\cf6 position\cf0 .\cf6 x\cf0 , \cf9 playerSquare\cf0 .
\cf6 position\cf0 .\cf6 y\cf0 - \cf8 2\cf0 );\
\cf9 title\cf0 .\cf6 position\cf0 = \cf7 CGPointMake\cf0 (\cf9
playerSquare\cf0 .\cf6 position\cf0 .\cf6 x\cf0 , \cf9 playerSquare\cf0 .\cf6 po
sition\cf0 .\cf6 y\cf0 );\
\
\cf2 //same as before\cf0 \
\cf9 dt\cf0 = \cf8 0\cf0 ;\
\}\
\} \cf5 else\cf0 \{\
\cf2 //same as before\cf0 \
\cf9 transitioningMove\cf0 = \cf5 false\cf0 ;\
\cf9 transitioningShrink\cf0 = \cf5 true\cf0 ;\
\
\cf2 //resets the positions of playerSquare and title to the origina
l ones so that any offsets in moving it down are not permanent; no differences w
ill be noticed because this is just a precaution against any miniscule differenc
e in positions\cf0 \
\cf9 playerSquare\cf0 .\cf6 position\cf0 = \cf7 CGPointMake\cf0 (\c
f5 self\cf0 .\cf6 size\cf0 .\cf6 width\cf0 * \cf8 .5\cf0 ,\cf5 self\cf0 .\cf6 s
ize\cf0 .\cf6 height\cf0 * \cf8 .7\cf0 );\
\cf9 title\cf0 .\cf6 position\cf0 = \cf7 CGPointMake\cf0 (\cf5 self
\cf0 .\cf6 size\cf0 .\cf6 width\cf0 * \cf8 .5\cf0 ,\cf5 self\cf0 .\cf6 size\cf0
.\cf6 height\cf0 * \cf8 .7\cf0 );\

\}\
\} \cf5 else\cf0 \cf5 if\cf0 ((\cf9 currentScene\cf0 == \cf9 currentScene
List\cf0 [\cf8 1\cf0 ]) && \cf9 transitioningShrink\cf0 ) \{\
\cf2 //same as before\cf0 \
\cf5 if\cf0 ((\cf9 playerSquare\cf0 .\cf6 size\cf0 .\cf6 width\cf0 < \
cf9 playerSquareOriginalSize\cf0 .\cf6 x\cf0 ) && (\cf9 playerSquare\cf0 .\cf6 s
ize\cf0 .\cf6 height\cf0 < \cf9 playerSquareOriginalSize\cf0 .\cf6 y\cf0 )) \{\
\cf5 if\cf0 (\cf9 lastUpdateTime\cf0 ) \{\
\cf9 dt\cf0 = \cf9 dt\cf0 + (currentTime - \cf9 lastUpdateTime
\cf0 );\
\} \cf5 else\cf0 \{\
\cf9 dt\cf0 = \cf8 0\cf0 ;\
\}\
\cf9 lastUpdateTime\cf0 = currentTime;\
\
\cf5 if\cf0 (\cf9 dt\cf0 * \cf8 1000\cf0 > \cf8 30\cf0 ) \{\
\cf2 //uses numTimes and the current smallestScale to correctly
expand the 2 nodes back\cf0 \
[\cf9 playerSquare\cf0 \cf7 setScale\cf0 :\cf9 smallestScale\cf
0 + (\cf9 numTimes\cf0 * \cf8 .01\cf0 )];\
[\cf9 title\cf0 \cf7 setScale\cf0 :\cf9 smallestScale\cf0 + (\
cf9 numTimes\cf0 * \cf8 .01\cf0 )];\
\
\cf2 //same as before\cf0 \
\cf9 dt\cf0 = \cf8 0\cf0 ;\
\
\cf9 numTimes\cf0 ++;\
\}\
\} \cf5 else\cf0 \{\
\cf2 //same as before\cf0 \
\cf9 transitioningShrink\cf0 = \cf5 false\cf0 ;\
\
\cf9 numTimes\cf0 = \cf8 1\cf0 ;\
\
\cf2 //resets the positions of playerSquare and title to the origina
l ones so that any offsets in expanding it are not permanent; no differences wil
l be noticed because this is just a precaution against any miniscule difference
in sizes\cf0 \
[\cf9 playerSquare\cf0 \cf7 setScale\cf0 :\cf8 1\cf0 ];\
[\cf9 playerSquare\cf0 \cf7 setScale\cf0 :\cf8 1\cf0 ];\
\
\cf2 //changes title's text and makes it fade back in\cf0 \
\cf9 title\cf0 .\cf6 text\cf0 = \cf4 @"SQUARES"\cf0 ;\
[\cf9 title\cf0 \cf7 runAction\cf0 :\cf9 fadeIn\cf0 ];\
\}\
\}\
\}\
\
\cf2 //called for typing out the text of otherScene\cf0 \
-(\cf5 void\cf0 )type:(\cf6 SKLabelNode\cf0 *)line with:(\cf6 NSArray\cf0 *)line
List and:(\cf6 CFTimeInterval\cf0 )currentTime\
\{\
\cf2 //checks to see that there are still characters to type\cf0 \
\cf5 if\cf0 (\cf9 numTimes\cf0 < [lineList \cf7 count\cf0 ]) \{\
\cf2 //same as before\cf0 \
\cf5 if\cf0 (\cf9 lastUpdateTime\cf0 ) \{\
\cf9 dt\cf0 = \cf9 dt\cf0 + (currentTime - \cf9 lastUpdateTime\cf0
);\
\} \cf5 else\cf0 \{\
\cf9 dt\cf0 = \cf8 0\cf0 ;\

\}\
\cf9 lastUpdateTime\cf0 = currentTime;\
\
\cf5 if\cf0 (\cf9 dt\cf0 * \cf8 1000\cf0 > \cf8 30\cf0 ) \{\
\cf2 //stores the new character indexed with numTimes as string\cf0
\
\cf6 NSString\cf0 *string = lineList[\cf9 numTimes\cf0 ];\
\
\cf2 //appends string to newText; it cannot be appended directly fro
m something indexed from a list\cf0 \
\cf9 newText\cf0 = [\cf9 newText\cf0 \cf7 stringByAppendingString\
cf0 :string];\
\
\cf2 //changes line's text to the new string with the appended chara
cter\cf0 \
line.\cf6 text\cf0 = \cf9 newText\cf0 ;\
\
\cf2 //adds 1 to numTimes to change the index next time\cf0 \
\cf9 numTimes\cf0 ++;\
\
\cf2 //same as before\cf0 \
\cf9 dt\cf0 = \cf8 0\cf0 ;\
\}\
\} \cf5 else\cf0 \{\
\cf2 //resets variables back for the new line of text that has to be typ
ed\cf0 \
\cf9 newText\cf0 = \cf4 @""\cf0 ;\
\cf9 numTimes\cf0 = \cf8 0\cf0 ;\
\
\cf2 //boolean values can only be changed directly, not from an array\cf
0 \
\cf5 if\cf0 (lineList == \cf9 line1List\cf0 ) \{\
\cf2 //changes the current boolean value that is true to false, and
the next one to true for the next line of text that has to be typed\cf0 \
\cf9 transitioningType1\cf0 = \cf5 false\cf0 ;\
\cf9 transitioningType2\cf0 = \cf5 true\cf0 ;\
\} \cf5 else\cf0 \cf5 if\cf0 (lineList == \cf9 line2List\cf0 ) \{\
\cf9 transitioningType2\cf0 = \cf5 false\cf0 ;\
\cf9 transitioningType3\cf0 = \cf5 true\cf0 ;\
\} \cf5 else\cf0 \cf5 if\cf0 (lineList == \cf9 line3List\cf0 ) \{\
\cf9 transitioningType3\cf0 = \cf5 false\cf0 ;\
\cf9 transitioningType4\cf0 = \cf5 true\cf0 ;\
\} \cf5 else\cf0 \cf5 if\cf0 (lineList == \cf9 line4List\cf0 ) \{\
\cf9 transitioningType4\cf0 = \cf5 false\cf0 ;\
\cf9 transitioningType5\cf0 = \cf5 true\cf0 ;\
\} \cf5 else\cf0 \cf5 if\cf0 (lineList == \cf9 line5List\cf0 ) \{\
\cf9 transitioningType5\cf0 = \cf5 false\cf0 ;\
\cf9 transitioningType6\cf0 = \cf5 true\cf0 ;\
\} \cf5 else\cf0 \cf5 if\cf0 (lineList == \cf9 line6List\cf0 ) \{\
\cf9 transitioningType6\cf0 = \cf5 false\cf0 ;\
\cf9 transitioningType7\cf0 = \cf5 true\cf0 ;\
\} \cf5 else\cf0 \cf5 if\cf0 (lineList == \cf9 line7List\cf0 ) \{\
\cf9 transitioningType7\cf0 = \cf5 false\cf0 ;\
\cf9 transitioningType8\cf0 = \cf5 true\cf0 ;\
\} \cf5 else\cf0 \cf5 if\cf0 (lineList == \cf9 line8List\cf0 ) \{\
\cf9 transitioningType8\cf0 = \cf5 false\cf0 ;\
\cf9 transitioningType9\cf0 = \cf5 true\cf0 ;\
\} \cf5 else\cf0 \cf5 if\cf0 (lineList == \cf9 line9List\cf0 ) \{\
\cf9 transitioningType9\cf0 = \cf5 false\cf0 ;\
\cf9 transitioningType10\cf0 = \cf5 true\cf0 ;\

\} \cf5 else\cf0 \cf5 if\cf0 (lineList == \cf9 line10List\cf0 ) \{\


\cf9 transitioningType10\cf0 = \cf5 false\cf0 ;\
\cf9 transitioningType11\cf0 = \cf5 true\cf0 ;\
\} \cf5 else\cf0 \cf5 if\cf0 (lineList == \cf9 line11List\cf0 ) \{\
\cf9 transitioningType11\cf0 = \cf5 false\cf0 ;\
\cf2 //this time, there is no more typing to do, so the variable tra
nsitioningType is changed to false to stop the entire transition\cf0 \
\cf9 transitioningType\cf0 = \cf5 false\cf0 ;\
\
\cf2 //resets numTimes, but this time to 1 for another use\cf0 \
\cf9 numTimes\cf0 = \cf8 1\cf0 ;\
\}\
\}\
\}\
\
\cf5 @end\cf0 \
}

You might also like