Skip to content
Snippets Groups Projects
Commit ef96d95b authored by Chan Yong Lee's avatar Chan Yong Lee
Browse files

modified function

parent 2d5999ed
No related branches found
No related tags found
No related merge requests found
......@@ -630,14 +630,14 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = V6FHC84522;
DEVELOPMENT_TEAM = NYTT9V938N;
INFOPLIST_FILE = "Better Together/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 14.2;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.example1.Better-Together";
PRODUCT_BUNDLE_IDENTIFIER = "com.example.Better-Together";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 5.0;
......@@ -651,14 +651,14 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = V6FHC84522;
DEVELOPMENT_TEAM = NYTT9V938N;
INFOPLIST_FILE = "Better Together/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 14.2;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = "com.example1.Better-Together";
PRODUCT_BUNDLE_IDENTIFIER = "com.example.Better-Together";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
......
......
......@@ -528,11 +528,11 @@ class Character : SKNode {
}
// used to let the arms bent again if the character is at the corner of an object and somehow needs to "wrap around" the corner
if rightHandGrabbing && CGPointDistance(from: bodyParts[.Body]!.position, to: bodyParts[.LeftUpperArm]!.position) < upperArmBodyDistanceLB {
if rightHandGrabbing && distanceBetweenPoints(start: bodyParts[.Body]!.position, end: bodyParts[.LeftUpperArm]!.position) < upperArmBodyDistanceLB {
leftArmsGotClosureAgain = false
joints[.jointLeftUpperLeftLower]!.frictionTorque = lowerArmLowFriction
}
if leftHandGrabbing && CGPointDistance(from: bodyParts[.Body]!.position, to: bodyParts[.RightUpperArm]!.position) < upperArmBodyDistanceLB {
if leftHandGrabbing && distanceBetweenPoints(start: bodyParts[.Body]!.position, end: bodyParts[.RightUpperArm]!.position) < upperArmBodyDistanceLB {
rightArmsGotClosureAgain = false
joints[.jointRightUpperRightLower]!.frictionTorque = lowerArmLowFriction
}
......@@ -587,28 +587,28 @@ class Character : SKNode {
* these functions are used to keep the arms straight while moving
*/
func checkLeftArmsStraight() -> Bool {
if CGPointDistance(from: bodyParts[.LeftLowerArm]!.position, to: bodyParts[.LeftUpperArm]!.position) > armDistance {
if distanceBetweenPoints(start: bodyParts[.LeftLowerArm]!.position, end: bodyParts[.LeftUpperArm]!.position) > armDistance {
return true
}
return false
}
func checkRightArmsStraight() -> Bool {
if CGPointDistance(from: bodyParts[.RightLowerArm]!.position, to: bodyParts[.RightUpperArm]!.position) > armDistance {
if distanceBetweenPoints(start: bodyParts[.RightLowerArm]!.position, end: bodyParts[.RightUpperArm]!.position) > armDistance {
return true
}
return false
}
func checkLeftArmsClose() -> Bool {
if CGPointDistance(from: bodyParts[.LeftLowerArm]!.position, to: bodyParts[.LeftUpperArm]!.position) < armDistance {
if distanceBetweenPoints(start: bodyParts[.LeftLowerArm]!.position, end: bodyParts[.LeftUpperArm]!.position) < armDistance {
return true
}
return false
}
func checkRightArmsClose() -> Bool {
if CGPointDistance(from: bodyParts[.RightLowerArm]!.position, to: bodyParts[.RightUpperArm]!.position) < armDistance {
if distanceBetweenPoints(start: bodyParts[.RightLowerArm]!.position, end: bodyParts[.RightUpperArm]!.position) < armDistance {
return true
}
return false
......@@ -648,14 +648,8 @@ class Character : SKNode {
/*
* computes distance between two points
*/
//MARK: - delete or modifty, it was copied from internet
/* copied from intertnet*/
func CGPointDistanceSquared(from: CGPoint, to: CGPoint) -> CGFloat {
return (from.x - to.x) * (from.x - to.x) + (from.y - to.y) * (from.y - to.y)
}
func CGPointDistance(from: CGPoint, to: CGPoint) -> CGFloat {
return sqrt(CGPointDistanceSquared(from: from, to: to))
func distanceBetweenPoints(start: CGPoint, end: CGPoint) -> CGFloat {
return sqrt(start.x - end.x) * (start.x - end.x) + (start.y - end.y) * (start.y - end.y)
}
......
......
......@@ -93,46 +93,42 @@ switch bodyPart {
Auxilirary functions needed are:
```swift
/*
* these functions are used to keep the arms straight while moving
*/
func checkLeftArmsStraight() -> Bool {
//print(CGPointDistance(from: bodyParts[.LeftLowerArm]!.position, to: bodyParts[.LeftUpperArm]!.position))
//print(armDistance)
if CGPointDistance(from: bodyParts[.LeftLowerArm]!.position, to: bodyParts[.LeftUpperArm]!.position) > armDistance && leftArmsGotClosureAgain {
if distanceBetweenPoints(start: bodyParts[.LeftLowerArm]!.position, end: bodyParts[.LeftUpperArm]!.position) > armDistance {
return true
}
return false
}
func checkRightArmsStraight() -> Bool {
//print(CGPointDistance(from: bodyParts[.RightLowerArm]!.position, to: bodyParts[.RightUpperArm]!.position))
//print(armDistance)
if CGPointDistance(from: bodyParts[.RightLowerArm]!.position, to: bodyParts[.RightUpperArm]!.position) > armDistance && rightArmsGotClosureAgain {
if distanceBetweenPoints(start: bodyParts[.RightLowerArm]!.position, end: bodyParts[.RightUpperArm]!.position) > armDistance {
return true
}
return false
}
func checkLeftArmsClose() -> Bool {
if CGPointDistance(from: bodyParts[.LeftLowerArm]!.position, to: bodyParts[.LeftUpperArm]!.position) < armDistance {
if distanceBetweenPoints(start: bodyParts[.LeftLowerArm]!.position, end: bodyParts[.LeftUpperArm]!.position) < armDistance {
return true
}
return false
}
func checkRightArmsClose() -> Bool {
if CGPointDistance(from: bodyParts[.RightLowerArm]!.position, to: bodyParts[.RightUpperArm]!.position) < armDistance {
if distanceBetweenPoints(start: bodyParts[.RightLowerArm]!.position, end: bodyParts[.RightUpperArm]!.position) < armDistance {
return true
}
return false
}
//MARK: - delete or modifty, it was copied from internet
/* copied from intertnet*/
func CGPointDistanceSquared(from: CGPoint, to: CGPoint) -> CGFloat {
return (from.x - to.x) * (from.x - to.x) + (from.y - to.y) * (from.y - to.y)
}
func CGPointDistance(from: CGPoint, to: CGPoint) -> CGFloat {
return sqrt(CGPointDistanceSquared(from: from, to: to))
/*
* computes distance between two points
*/
func distanceBetweenPoints(start: CGPoint, end: CGPoint) -> CGFloat {
return sqrt(start.x - end.x) * (start.x - end.x) + (start.y - end.y) * (start.y - end.y)
}
```
##
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment