diff --git a/SQNumber/SQNumber.xcodeproj/project.pbxproj b/SQNumber/SQNumber.xcodeproj/project.pbxproj new file mode 100644 index 00000000..33333f77 --- /dev/null +++ b/SQNumber/SQNumber.xcodeproj/project.pbxproj @@ -0,0 +1,358 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 14EABDA3250B57520091F19B /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 14EABDA2250B57520091F19B /* AppDelegate.m */; }; + 14EABDA6250B57520091F19B /* SceneDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 14EABDA5250B57520091F19B /* SceneDelegate.m */; }; + 14EABDA9250B57520091F19B /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 14EABDA8250B57520091F19B /* ViewController.m */; }; + 14EABDAC250B57520091F19B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 14EABDAA250B57520091F19B /* Main.storyboard */; }; + 14EABDAE250B57530091F19B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 14EABDAD250B57530091F19B /* Assets.xcassets */; }; + 14EABDB1250B57530091F19B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 14EABDAF250B57530091F19B /* LaunchScreen.storyboard */; }; + 14EABDB4250B57530091F19B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 14EABDB3250B57530091F19B /* main.m */; }; + 14EABDC1250B60A10091F19B /* SQSpriteView.m in Sources */ = {isa = PBXBuildFile; fileRef = 14EABDC0250B60A10091F19B /* SQSpriteView.m */; }; + 14EABE11250BB6FA0091F19B /* SQTimer.m in Sources */ = {isa = PBXBuildFile; fileRef = 14EABE0F250BB6F90091F19B /* SQTimer.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 14EABD9E250B57520091F19B /* SQNumber.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SQNumber.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 14EABDA1250B57520091F19B /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 14EABDA2250B57520091F19B /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 14EABDA4250B57520091F19B /* SceneDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SceneDelegate.h; sourceTree = ""; }; + 14EABDA5250B57520091F19B /* SceneDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SceneDelegate.m; sourceTree = ""; }; + 14EABDA7250B57520091F19B /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; + 14EABDA8250B57520091F19B /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; + 14EABDAB250B57520091F19B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 14EABDAD250B57530091F19B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 14EABDB0250B57530091F19B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 14EABDB2250B57530091F19B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 14EABDB3250B57530091F19B /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 14EABDBF250B60A10091F19B /* SQSpriteView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SQSpriteView.h; sourceTree = ""; }; + 14EABDC0250B60A10091F19B /* SQSpriteView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SQSpriteView.m; sourceTree = ""; }; + 14EABE0F250BB6F90091F19B /* SQTimer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SQTimer.m; sourceTree = ""; }; + 14EABE10250BB6FA0091F19B /* SQTimer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SQTimer.h; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 14EABD9B250B57520091F19B /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 14EABD95250B57520091F19B = { + isa = PBXGroup; + children = ( + 14EABDA0250B57520091F19B /* SQNumber */, + 14EABD9F250B57520091F19B /* Products */, + ); + sourceTree = ""; + }; + 14EABD9F250B57520091F19B /* Products */ = { + isa = PBXGroup; + children = ( + 14EABD9E250B57520091F19B /* SQNumber.app */, + ); + name = Products; + sourceTree = ""; + }; + 14EABDA0250B57520091F19B /* SQNumber */ = { + isa = PBXGroup; + children = ( + 14EABDA1250B57520091F19B /* AppDelegate.h */, + 14EABDA2250B57520091F19B /* AppDelegate.m */, + 14EABDA4250B57520091F19B /* SceneDelegate.h */, + 14EABDA5250B57520091F19B /* SceneDelegate.m */, + 14EABDA7250B57520091F19B /* ViewController.h */, + 14EABDA8250B57520091F19B /* ViewController.m */, + 14EABDBF250B60A10091F19B /* SQSpriteView.h */, + 14EABDC0250B60A10091F19B /* SQSpriteView.m */, + 14EABE10250BB6FA0091F19B /* SQTimer.h */, + 14EABE0F250BB6F90091F19B /* SQTimer.m */, + 14EABDAA250B57520091F19B /* Main.storyboard */, + 14EABDAD250B57530091F19B /* Assets.xcassets */, + 14EABDAF250B57530091F19B /* LaunchScreen.storyboard */, + 14EABDB2250B57530091F19B /* Info.plist */, + 14EABDB3250B57530091F19B /* main.m */, + ); + path = SQNumber; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 14EABD9D250B57520091F19B /* SQNumber */ = { + isa = PBXNativeTarget; + buildConfigurationList = 14EABDB7250B57530091F19B /* Build configuration list for PBXNativeTarget "SQNumber" */; + buildPhases = ( + 14EABD9A250B57520091F19B /* Sources */, + 14EABD9B250B57520091F19B /* Frameworks */, + 14EABD9C250B57520091F19B /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = SQNumber; + productName = SQNumber; + productReference = 14EABD9E250B57520091F19B /* SQNumber.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 14EABD96250B57520091F19B /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 1170; + ORGANIZATIONNAME = "朱双泉"; + TargetAttributes = { + 14EABD9D250B57520091F19B = { + CreatedOnToolsVersion = 11.7; + }; + }; + }; + buildConfigurationList = 14EABD99250B57520091F19B /* Build configuration list for PBXProject "SQNumber" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 14EABD95250B57520091F19B; + productRefGroup = 14EABD9F250B57520091F19B /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 14EABD9D250B57520091F19B /* SQNumber */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 14EABD9C250B57520091F19B /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 14EABDB1250B57530091F19B /* LaunchScreen.storyboard in Resources */, + 14EABDAE250B57530091F19B /* Assets.xcassets in Resources */, + 14EABDAC250B57520091F19B /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 14EABD9A250B57520091F19B /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 14EABDA9250B57520091F19B /* ViewController.m in Sources */, + 14EABDA3250B57520091F19B /* AppDelegate.m in Sources */, + 14EABDB4250B57530091F19B /* main.m in Sources */, + 14EABE11250BB6FA0091F19B /* SQTimer.m in Sources */, + 14EABDA6250B57520091F19B /* SceneDelegate.m in Sources */, + 14EABDC1250B60A10091F19B /* SQSpriteView.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 14EABDAA250B57520091F19B /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 14EABDAB250B57520091F19B /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 14EABDAF250B57530091F19B /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 14EABDB0250B57530091F19B /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 14EABDB5250B57530091F19B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.7; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 14EABDB6250B57530091F19B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 13.7; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 14EABDB8250B57530091F19B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = NGPFU6GT2A; + INFOPLIST_FILE = SQNumber/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = coderZsq.SQNumber; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 14EABDB9250B57530091F19B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = NGPFU6GT2A; + INFOPLIST_FILE = SQNumber/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = coderZsq.SQNumber; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 14EABD99250B57520091F19B /* Build configuration list for PBXProject "SQNumber" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 14EABDB5250B57530091F19B /* Debug */, + 14EABDB6250B57530091F19B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 14EABDB7250B57530091F19B /* Build configuration list for PBXNativeTarget "SQNumber" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 14EABDB8250B57530091F19B /* Debug */, + 14EABDB9250B57530091F19B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 14EABD96250B57520091F19B /* Project object */; +} diff --git a/SQNumber/SQNumber.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/SQNumber/SQNumber.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..9c7093de --- /dev/null +++ b/SQNumber/SQNumber.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/SQNumber/SQNumber.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/SQNumber/SQNumber.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/SQNumber/SQNumber.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/SQNumber/SQNumber/AppDelegate.h b/SQNumber/SQNumber/AppDelegate.h new file mode 100644 index 00000000..39dab909 --- /dev/null +++ b/SQNumber/SQNumber/AppDelegate.h @@ -0,0 +1,15 @@ +// +// AppDelegate.h +// SQNumber +// +// Created by 朱双泉 on 2020/9/11. +// Copyright © 2020 朱双泉. All rights reserved. +// + +#import + +@interface AppDelegate : UIResponder + + +@end + diff --git a/SQNumber/SQNumber/AppDelegate.m b/SQNumber/SQNumber/AppDelegate.m new file mode 100644 index 00000000..8e70b32c --- /dev/null +++ b/SQNumber/SQNumber/AppDelegate.m @@ -0,0 +1,41 @@ +// +// AppDelegate.m +// SQNumber +// +// Created by 朱双泉 on 2020/9/11. +// Copyright © 2020 朱双泉. All rights reserved. +// + +#import "AppDelegate.h" + +@interface AppDelegate () + +@end + +@implementation AppDelegate + + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + // Override point for customization after application launch. + return YES; +} + + +#pragma mark - UISceneSession lifecycle + + +- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options { + // Called when a new scene session is being created. + // Use this method to select a configuration to create the new scene with. + return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role]; +} + + +- (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet *)sceneSessions { + // Called when the user discards a scene session. + // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. + // Use this method to release any resources that were specific to the discarded scenes, as they will not return. +} + + +@end diff --git a/SQNumber/SQNumber/Assets.xcassets/AppIcon.appiconset/Contents.json b/SQNumber/SQNumber/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..9221b9bb --- /dev/null +++ b/SQNumber/SQNumber/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "20x20" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "29x29" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "60x60" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "60x60" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "20x20" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "29x29" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "40x40" + }, + { + "idiom" : "ipad", + "scale" : "1x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "76x76" + }, + { + "idiom" : "ipad", + "scale" : "2x", + "size" : "83.5x83.5" + }, + { + "idiom" : "ios-marketing", + "scale" : "1x", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/SQNumber/SQNumber/Assets.xcassets/Contents.json b/SQNumber/SQNumber/Assets.xcassets/Contents.json new file mode 100644 index 00000000..73c00596 --- /dev/null +++ b/SQNumber/SQNumber/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/SQNumber/SQNumber/Base.lproj/LaunchScreen.storyboard b/SQNumber/SQNumber/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 00000000..865e9329 --- /dev/null +++ b/SQNumber/SQNumber/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SQNumber/SQNumber/Base.lproj/Main.storyboard b/SQNumber/SQNumber/Base.lproj/Main.storyboard new file mode 100644 index 00000000..808a21ce --- /dev/null +++ b/SQNumber/SQNumber/Base.lproj/Main.storyboard @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SQNumber/SQNumber/Info.plist b/SQNumber/SQNumber/Info.plist new file mode 100644 index 00000000..8726d2a9 --- /dev/null +++ b/SQNumber/SQNumber/Info.plist @@ -0,0 +1,63 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + $(PRODUCT_BUNDLE_PACKAGE_TYPE) + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + UIWindowSceneSessionRoleApplication + + + UISceneConfigurationName + Default Configuration + UISceneDelegateClassName + SceneDelegate + UISceneStoryboardFile + Main + + + + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/SQNumber/SQNumber/SQSpriteView.h b/SQNumber/SQNumber/SQSpriteView.h new file mode 100755 index 00000000..403e7f40 --- /dev/null +++ b/SQNumber/SQNumber/SQSpriteView.h @@ -0,0 +1,21 @@ +// +// SQSpriteView.h +// +// Created by Doubles_Z on 15/9/5. +// Copyright (c) 2015年 Doubles_Z. All rights reserved. +// + +#import + +@interface SQSpriteView : UIView + +@property (nonatomic, assign) CGRect matchRect; + +@property (nonatomic, assign, getter=isMatch, readonly) BOOL match; + +@property (nonatomic, copy) void(^matching)(SQSpriteView *); + +@property (nonatomic, assign, getter=isMatched) BOOL matched; + +@end + diff --git a/SQNumber/SQNumber/SQSpriteView.m b/SQNumber/SQNumber/SQSpriteView.m new file mode 100755 index 00000000..b923a145 --- /dev/null +++ b/SQNumber/SQNumber/SQSpriteView.m @@ -0,0 +1,140 @@ +// +// SQSpriteView.m +// +// Created by Doubles_Z on 15/9/5. +// Copyright (c) 2015年 Doubles_Z. All rights reserved. +// + +#import "SQSpriteView.h" +#import "SQTimer.h" + +@interface SQSpriteView () + +@property (nonatomic, copy) NSString *directionTimerId; +@property (nonatomic, copy) NSString *frameTimerId; + +@end + +@implementation SQSpriteView + +- (instancetype)initWithFrame:(CGRect)frame { + self = [super initWithFrame:frame]; + if (self) { + [self updateCoordinate]; + } + return self; +} + +typedef NS_ENUM(NSUInteger, SQSpriteDirection) { + SQSpriteDirectionNone = 0, + SQSpriteDirectionUp, + SQSpriteDirectionDown, + SQSpriteDirectionLeft, + SQSpriteDirectionRight, + SQSpriteDirectionLeftUp, + SQSpriteDirectionRightUp, + SQSpriteDirectionLeftDown, + SQSpriteDirectionRightDown +}; + +- (void)updateCoordinate { + __block NSInteger direction = 0; + + self.directionTimerId = [SQTimer execTask:^{ + direction = arc4random() % 9; + } start:0 interval:2 repeats:YES async:NO]; + self.frameTimerId = [SQTimer execTask:^{ + CGRect frame = self.frame; + switch (direction) { + case SQSpriteDirectionNone: + break; + case SQSpriteDirectionUp: + frame.origin.y -= 1; + break; + case SQSpriteDirectionDown: + frame.origin.y += 1; + break; + case SQSpriteDirectionLeft: + frame.origin.x -= 1; + break; + case SQSpriteDirectionRight: + frame.origin.x += 1; + break; + case SQSpriteDirectionLeftUp: { + frame.origin.x -= 1; + frame.origin.y -= 1; + } break; + case SQSpriteDirectionRightUp: { + frame.origin.x += 1; + frame.origin.y -= 1; + } break; + case SQSpriteDirectionLeftDown: { + frame.origin.x -= 1; + frame.origin.y += 1; + } break; + case SQSpriteDirectionRightDown: { + frame.origin.x += 1; + frame.origin.y += 1; + } break; + default: + break; + } + self.frame = frame; + + NSInteger margin = 5; + if (self.frame.origin.x <= margin) { + direction = SQSpriteDirectionRight; + } else if (self.frame.origin.y <= margin) { + direction = SQSpriteDirectionDown; + } else if (self.frame.origin.x + self.bounds.size.width + margin >= self.superview.bounds.size.width) { + direction = SQSpriteDirectionLeft; + } else if (self.frame.origin.y + self.bounds.size.height + margin >= self.superview.bounds.size.height) { + direction = SQSpriteDirectionUp; + } + } start:0 interval:0.03 repeats:YES async:NO]; +} + +- (void)clearTimer { + [SQTimer cancelTask:self.directionTimerId]; + [SQTimer cancelTask:self.frameTimerId]; +} + +- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { + [super touchesMoved:touches withEvent:event]; + [self clearTimer]; + + if (self.matched) return; + + UITouch * touch = [touches anyObject]; + CGPoint current = [touch locationInView:self]; + CGPoint previous = [touch previousLocationInView:self]; + + CGPoint center = self.center; + center.x += current.x - previous.x; center.y += current.y - previous.y; + + CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width; + CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height; + + CGFloat xMin = self.frame.size.width * 0.5; CGFloat xMax = screenWidth - xMin; + CGFloat yMin = self.frame.size.height * 0.5; CGFloat yMax = screenHeight - yMin; + + if (center.x > xMax) center.x = xMax; if (center.y > yMax) center.y = yMax; + if (center.x < xMin) center.x = xMin; if (center.y < yMin) center.y = yMin; + self.center = center; +} + +- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { + if (self.matched) return; + + _match = CGRectContainsRect(self.matchRect, self.frame); + if (self.isMatch) { + [self clearTimer]; + } else { + [self updateCoordinate]; + } + if (self.matching) { + self.matching(self); + } +} + +@end diff --git a/SQNumber/SQNumber/SQTimer.h b/SQNumber/SQNumber/SQTimer.h new file mode 100644 index 00000000..17696fcf --- /dev/null +++ b/SQNumber/SQNumber/SQTimer.h @@ -0,0 +1,32 @@ +// +// SQTimer.h +// 12-内存管理 +// +// Created by 朱双泉 on 2019/5/22. +// Copyright © 2019 Castie!. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface SQTimer : NSObject + ++ (NSString *)execTask:(void(^)(void))task + start:(NSTimeInterval)start + interval:(NSTimeInterval)interval + repeats:(BOOL)repeats + async:(BOOL)async; + ++ (NSString *)execTask:(id)target + selector:(SEL)selector + start:(NSTimeInterval)start + interval:(NSTimeInterval)interval + repeats:(BOOL)repeats + async:(BOOL)async; + ++ (void)cancelTask:(NSString *)name; + +@end + +NS_ASSUME_NONNULL_END diff --git a/SQNumber/SQNumber/SQTimer.m b/SQNumber/SQNumber/SQTimer.m new file mode 100644 index 00000000..dc470ca8 --- /dev/null +++ b/SQNumber/SQNumber/SQTimer.m @@ -0,0 +1,89 @@ +// +// SQTimer.m +// 12-内存管理 +// +// Created by 朱双泉 on 2019/5/22. +// Copyright © 2019 Castie!. All rights reserved. +// + +#import "SQTimer.h" + +@implementation SQTimer + +static NSMutableDictionary *timers_; +dispatch_semaphore_t semaphore_; ++ (void)initialize { + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + timers_ = [NSMutableDictionary dictionary]; + semaphore_ = dispatch_semaphore_create(1); + }); +} + ++ (NSString *)execTask:(void (^)(void))task start:(NSTimeInterval)start interval:(NSTimeInterval)interval repeats:(BOOL)repeats async:(BOOL)async { + + if (!task || start < 0 || (interval <= 0 && repeats)) return nil; + + // 队列 + dispatch_queue_t queue = async ? dispatch_get_global_queue(0, 0) + : dispatch_get_main_queue(); + + // 创建定时器 + dispatch_source_t timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue); + + // 设置时间 + dispatch_source_set_timer(timer, + dispatch_time(DISPATCH_TIME_NOW, start * NSEC_PER_SEC), + interval * NSEC_PER_SEC, 0); + + dispatch_semaphore_wait(semaphore_, DISPATCH_TIME_FOREVER); + + // 定时器的唯一标识 + NSString *name = [NSString stringWithFormat:@"%zd", timers_.count]; + // 存放到字典中 + timers_[name] = timer; + + dispatch_semaphore_signal(semaphore_); + + // 设置回调 + dispatch_source_set_event_handler(timer, ^{ + task(); + + if (!repeats) { // 不重复的任务 + [self cancelTask:name]; + } + }); + + // 启动定时器 + dispatch_resume(timer); + + return name; +} + ++ (NSString *)execTask:(id)target selector:(SEL)selector start:(NSTimeInterval)start interval:(NSTimeInterval)interval repeats:(BOOL)repeats async:(BOOL)async { + if (!target || !selector) return nil; + return [self execTask:^{ + if ([target respondsToSelector:selector]) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Warc-performSelector-leaks" + [target performSelector:selector]; +#pragma clang diagnostic pop + } + } start:start interval:interval repeats:repeats async:async]; +} + ++ (void)cancelTask:(NSString *)name { + if (name.length == 0) return; + + dispatch_semaphore_wait(semaphore_, DISPATCH_TIME_FOREVER); + + dispatch_source_t timer = timers_[name]; + if (timer) { + dispatch_source_cancel(timer); + [timers_ removeObjectForKey:name]; + } + + dispatch_semaphore_signal(semaphore_); +} + +@end diff --git a/SQNumber/SQNumber/SceneDelegate.h b/SQNumber/SQNumber/SceneDelegate.h new file mode 100644 index 00000000..fe940f1d --- /dev/null +++ b/SQNumber/SQNumber/SceneDelegate.h @@ -0,0 +1,16 @@ +// +// SceneDelegate.h +// SQNumber +// +// Created by 朱双泉 on 2020/9/11. +// Copyright © 2020 朱双泉. All rights reserved. +// + +#import + +@interface SceneDelegate : UIResponder + +@property (strong, nonatomic) UIWindow * window; + +@end + diff --git a/SQNumber/SQNumber/SceneDelegate.m b/SQNumber/SQNumber/SceneDelegate.m new file mode 100644 index 00000000..6f543400 --- /dev/null +++ b/SQNumber/SQNumber/SceneDelegate.m @@ -0,0 +1,58 @@ +// +// SceneDelegate.m +// SQNumber +// +// Created by 朱双泉 on 2020/9/11. +// Copyright © 2020 朱双泉. All rights reserved. +// + +#import "SceneDelegate.h" + +@interface SceneDelegate () + +@end + +@implementation SceneDelegate + + +- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions { + // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. + // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. + // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). +} + + +- (void)sceneDidDisconnect:(UIScene *)scene { + // Called as the scene is being released by the system. + // This occurs shortly after the scene enters the background, or when its session is discarded. + // Release any resources associated with this scene that can be re-created the next time the scene connects. + // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead). +} + + +- (void)sceneDidBecomeActive:(UIScene *)scene { + // Called when the scene has moved from an inactive state to an active state. + // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. +} + + +- (void)sceneWillResignActive:(UIScene *)scene { + // Called when the scene will move from an active state to an inactive state. + // This may occur due to temporary interruptions (ex. an incoming phone call). +} + + +- (void)sceneWillEnterForeground:(UIScene *)scene { + // Called as the scene transitions from the background to the foreground. + // Use this method to undo the changes made on entering the background. +} + + +- (void)sceneDidEnterBackground:(UIScene *)scene { + // Called as the scene transitions from the foreground to the background. + // Use this method to save data, release shared resources, and store enough scene-specific state information + // to restore the scene back to its current state. +} + + +@end diff --git a/SQNumber/SQNumber/ViewController.h b/SQNumber/SQNumber/ViewController.h new file mode 100644 index 00000000..cc45dbbb --- /dev/null +++ b/SQNumber/SQNumber/ViewController.h @@ -0,0 +1,15 @@ +// +// ViewController.h +// SQNumber +// +// Created by 朱双泉 on 2020/9/11. +// Copyright © 2020 朱双泉. All rights reserved. +// + +#import + +@interface ViewController : UIViewController + + +@end + diff --git a/SQNumber/SQNumber/ViewController.m b/SQNumber/SQNumber/ViewController.m new file mode 100644 index 00000000..5c63c468 --- /dev/null +++ b/SQNumber/SQNumber/ViewController.m @@ -0,0 +1,90 @@ +// +// ViewController.m +// SQNumber +// +// Created by 朱双泉 on 2020/9/11. +// Copyright © 2020 朱双泉. All rights reserved. +// + +#import "ViewController.h" +#import "SQSpriteView.h" + +@interface ViewController () + +@end + +@implementation ViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + + NSInteger count = 2; + NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:count]; + + UIView *containerView = [UIView new]; + CGFloat containerViewW = self.view.bounds.size.width * 0.9; + CGFloat containerViewH = containerViewW * 0.2; + CGFloat containerViewX = (self.view.bounds.size.width - containerViewW) * 0.5; + CGFloat containerViewY = (self.view.bounds.size.height - containerViewH) * 0.5; + containerView.frame = CGRectMake(containerViewX, containerViewY, containerViewW, containerViewH); + [self.view addSubview:containerView]; + + CGFloat innerViewW = containerViewH - 20; + CGFloat innerViewH = innerViewW; + CGFloat innerViewY = (containerViewH - innerViewH) * 0.5; + CGFloat innerViewS = (containerViewW - (innerViewW * count)) / (count + 1); + CGFloat movableViewW = innerViewW - 20; + CGFloat movableViewH = movableViewW; + for (NSInteger i = 0; i < count; i++) { + UIView *innerView = [UIView new]; + innerView.tag = i + 1; + CGFloat innerViewX = innerViewS + (i * (innerViewW + innerViewS)); + innerView.backgroundColor = [UIColor lightGrayColor]; + innerView.frame = CGRectMake(innerViewX, innerViewY, innerViewW, innerViewH); + [containerView addSubview:innerView]; + + UILabel *innerLabel = [UILabel new]; + innerLabel.text = @(innerView.tag).stringValue; + innerLabel.textAlignment = NSTextAlignmentCenter; + innerLabel.font = [UIFont boldSystemFontOfSize:120]; + innerLabel.frame = innerView.bounds; + [innerView addSubview:innerLabel]; + + SQSpriteView *movableView = [SQSpriteView new]; + movableView.matchRect = [innerView.superview convertRect:innerView.frame toView:self.view]; + movableView.backgroundColor = [UIColor systemGreenColor]; + NSString *address = [NSString stringWithFormat:@"%p", movableView]; + dict[address] = @(NO); + + movableView.matching = ^(SQSpriteView *matchView) { + if (matchView.isMatch) { + matchView.matched = YES; + dict[address] = @(YES); + } + BOOL successed = YES; + for (NSNumber *num in dict.allValues) { + if (!num.boolValue) { + successed = NO; + } + } + if (successed) { + NSLog(@"游戏通关"); + } + }; + + CGFloat movableViewX = arc4random() % (int)(self.view.bounds.size.width - movableViewW); + CGFloat movableViewY = arc4random() % (int)(self.view.bounds.size.height - movableViewH); + movableView.frame = CGRectMake(movableViewX, movableViewY, movableViewW, movableViewH); + [self.view addSubview:movableView]; + + UILabel *movableLabel = [UILabel new]; + movableLabel.text = innerLabel.text; + movableLabel.textAlignment = innerLabel.textAlignment; + movableLabel.font = innerLabel.font; + movableLabel.frame = movableView.bounds; + [movableView addSubview:movableLabel]; + } +} + + +@end diff --git a/SQNumber/SQNumber/main.m b/SQNumber/SQNumber/main.m new file mode 100644 index 00000000..66b4ce79 --- /dev/null +++ b/SQNumber/SQNumber/main.m @@ -0,0 +1,19 @@ +// +// main.m +// SQNumber +// +// Created by 朱双泉 on 2020/9/11. +// Copyright © 2020 朱双泉. All rights reserved. +// + +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + NSString * appDelegateClassName; + @autoreleasepool { + // Setup code that might create autoreleased objects goes here. + appDelegateClassName = NSStringFromClass([AppDelegate class]); + } + return UIApplicationMain(argc, argv, nil, appDelegateClassName); +}