仓库中添加内置的demo
41
demo/native/engine/ios/AppDelegate.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2010-2013 cocos2d-x.org
|
||||
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
||||
Copyright (c) 2017-2022 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You
|
||||
shall not use Cocos Creator software for developing other software or tools
|
||||
that's used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to
|
||||
you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#import "platform/ios/AppDelegateBridge.h"
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@class ViewController;
|
||||
|
||||
@interface AppDelegate : NSObject <UIApplicationDelegate> {
|
||||
}
|
||||
|
||||
@property(nonatomic, readonly) ViewController *viewController;
|
||||
@property(nonatomic, readonly) AppDelegateBridge *appDelegateBridge;
|
||||
@end
|
||||
107
demo/native/engine/ios/AppDelegate.mm
Normal file
@@ -0,0 +1,107 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2010-2013 cocos2d-x.org
|
||||
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
||||
Copyright (c) 2017-2022 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You shall
|
||||
not use Cocos Creator software for developing other software or tools that's
|
||||
used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#import "AppDelegate.h"
|
||||
#import "ViewController.h"
|
||||
#import "View.h"
|
||||
|
||||
#include "platform/ios/IOSPlatform.h"
|
||||
#import "platform/ios/AppDelegateBridge.h"
|
||||
#import "service/SDKWrapper.h"
|
||||
|
||||
@implementation AppDelegate
|
||||
@synthesize window;
|
||||
@synthesize appDelegateBridge;
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Application lifecycle
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||
[[SDKWrapper shared] application:application didFinishLaunchingWithOptions:launchOptions];
|
||||
appDelegateBridge = [[AppDelegateBridge alloc] init];
|
||||
|
||||
// Add the view controller's view to the window and display.
|
||||
CGRect bounds = [[UIScreen mainScreen] bounds];
|
||||
self.window = [[UIWindow alloc] initWithFrame:bounds];
|
||||
|
||||
// Should create view controller first, cc::Application will use it.
|
||||
_viewController = [[ViewController alloc] init];
|
||||
_viewController.view = [[View alloc] initWithFrame:bounds];
|
||||
_viewController.view.contentScaleFactor = UIScreen.mainScreen.scale;
|
||||
_viewController.view.multipleTouchEnabled = true;
|
||||
[self.window setRootViewController:_viewController];
|
||||
|
||||
[self.window makeKeyAndVisible];
|
||||
[appDelegateBridge application:application didFinishLaunchingWithOptions:launchOptions];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)applicationWillResignActive:(UIApplication *)application {
|
||||
/*
|
||||
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
||||
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
|
||||
*/
|
||||
[[SDKWrapper shared] applicationWillResignActive:application];
|
||||
[appDelegateBridge applicationWillResignActive:application];
|
||||
}
|
||||
|
||||
- (void)applicationDidBecomeActive:(UIApplication *)application {
|
||||
/*
|
||||
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
|
||||
*/
|
||||
[[SDKWrapper shared] applicationDidBecomeActive:application];
|
||||
[appDelegateBridge applicationDidBecomeActive:application];
|
||||
}
|
||||
|
||||
- (void)applicationDidEnterBackground:(UIApplication *)application {
|
||||
/*
|
||||
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
|
||||
If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
|
||||
*/
|
||||
[[SDKWrapper shared] applicationDidEnterBackground:application];
|
||||
}
|
||||
|
||||
- (void)applicationWillEnterForeground:(UIApplication *)application {
|
||||
/*
|
||||
Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
|
||||
*/
|
||||
[[SDKWrapper shared] applicationWillEnterForeground:application];
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(UIApplication *)application {
|
||||
[[SDKWrapper shared] applicationWillTerminate:application];
|
||||
[appDelegateBridge applicationWillTerminate:application];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Memory management
|
||||
|
||||
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
|
||||
[[SDKWrapper shared] applicationDidReceiveMemoryWarning:application];
|
||||
}
|
||||
|
||||
@end
|
||||
45
demo/native/engine/ios/Base.lproj/LaunchScreen.storyboard
Normal file
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13196" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
|
||||
<device id="retina5_9" orientation="landscape">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<dependencies>
|
||||
<deployment version="2048" identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13173"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--View Controller-->
|
||||
<scene sceneID="EHf-IW-A2E">
|
||||
<objects>
|
||||
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="fm7-M6-edp"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="uRH-d6-mvd"/>
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
|
||||
<rect key="frame" x="0.0" y="0.0" width="812" height="375"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<imageView opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleAspectFill" insetsLayoutMarginsFromSafeArea="NO" image="LaunchScreenBackground.png" translatesAutoresizingMaskIntoConstraints="NO" id="YCC-wj-Gww" userLabel="Background">
|
||||
<rect key="frame" x="0.0" y="0.0" width="812" height="375"/>
|
||||
</imageView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="bottom" secondItem="YCC-wj-Gww" secondAttribute="bottom" id="Naz-ae-jWI"/>
|
||||
<constraint firstAttribute="trailing" secondItem="YCC-wj-Gww" secondAttribute="trailing" id="myj-85-hk9"/>
|
||||
<constraint firstItem="YCC-wj-Gww" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" id="qOq-Cg-doS"/>
|
||||
<constraint firstItem="YCC-wj-Gww" firstAttribute="top" secondItem="Ze5-6b-2t3" secondAttribute="top" id="xL7-Fo-4bl"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="50.399999999999999" y="373.15270935960592"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<resources>
|
||||
<image name="LaunchScreenBackground.png" width="2208" height="1242"/>
|
||||
</resources>
|
||||
</document>
|
||||
9
demo/native/engine/ios/Base.lproj/Localizable.strings
Normal file
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
Localizable.strings
|
||||
*/
|
||||
|
||||
"done" = "Done";
|
||||
"next" = "Next";
|
||||
"search" = "Search";
|
||||
"go" = "Go";
|
||||
"send" = "Send";
|
||||
20
demo/native/engine/ios/CMakeLists.txt
Executable file
@@ -0,0 +1,20 @@
|
||||
cmake_minimum_required(VERSION 3.8)
|
||||
|
||||
set(CMAKE_SYSTEM_NAME iOS)
|
||||
set(APP_NAME "kunpocreator" CACHE STRING "Project Name")
|
||||
|
||||
project(${APP_NAME} CXX)
|
||||
|
||||
set(CC_PROJECT_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||
set(CC_UI_RESOURCES)
|
||||
set(CC_PROJ_SOURCES)
|
||||
set(CC_ASSET_FILES)
|
||||
set(CC_COMMON_SOURCES)
|
||||
set(CC_ALL_SOURCES)
|
||||
|
||||
include(${CC_PROJECT_DIR}/../common/CMakeLists.txt)
|
||||
set(EXECUTABLE_NAME ${APP_NAME}-mobile)
|
||||
|
||||
cc_ios_before_target(${EXECUTABLE_NAME})
|
||||
add_executable(${EXECUTABLE_NAME} ${CC_ALL_SOURCES})
|
||||
cc_ios_after_target(${EXECUTABLE_NAME})
|
||||
|
After Width: | Height: | Size: 216 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 23 KiB |
BIN
demo/native/engine/ios/Images.xcassets/AppIcon.appiconset/29.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
demo/native/engine/ios/Images.xcassets/AppIcon.appiconset/40.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
demo/native/engine/ios/Images.xcassets/AppIcon.appiconset/57.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
demo/native/engine/ios/Images.xcassets/AppIcon.appiconset/58.png
Normal file
|
After Width: | Height: | Size: 4.7 KiB |
BIN
demo/native/engine/ios/Images.xcassets/AppIcon.appiconset/60.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
demo/native/engine/ios/Images.xcassets/AppIcon.appiconset/80.png
Normal file
|
After Width: | Height: | Size: 7.4 KiB |
BIN
demo/native/engine/ios/Images.xcassets/AppIcon.appiconset/87.png
Normal file
|
After Width: | Height: | Size: 8.3 KiB |
@@ -0,0 +1 @@
|
||||
{"images":[{"size":"60x60","expected-size":"180","filename":"180.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"3x"},{"size":"40x40","expected-size":"80","filename":"80.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"40x40","expected-size":"120","filename":"120.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"3x"},{"size":"60x60","expected-size":"120","filename":"120.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"57x57","expected-size":"57","filename":"57.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"1x"},{"size":"29x29","expected-size":"58","filename":"58.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"29x29","expected-size":"29","filename":"29.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"1x"},{"size":"29x29","expected-size":"87","filename":"87.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"3x"},{"size":"57x57","expected-size":"114","filename":"114.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"20x20","expected-size":"40","filename":"40.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"2x"},{"size":"20x20","expected-size":"60","filename":"60.png","folder":"Assets.xcassets/AppIcon.appiconset/","idiom":"iphone","scale":"3x"},{"size":"1024x1024","filename":"1024.png","expected-size":"1024","idiom":"ios-marketing","folder":"Assets.xcassets/AppIcon.appiconset/","scale":"1x"}]}
|
||||
6
demo/native/engine/ios/Images.xcassets/Contents.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
55
demo/native/engine/ios/Info.plist
Normal file
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${CC_EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIcons~ipad</key>
|
||||
<dict/>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsArbitraryLoads</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>UIPrerenderedIcon</key>
|
||||
<true/>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<dict>
|
||||
<key>accelerometer</key>
|
||||
<true/>
|
||||
<key>opengles-1</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>UIRequiresFullScreen</key>
|
||||
<true/>
|
||||
<key>UIStatusBarHidden</key>
|
||||
<true/>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
BIN
demo/native/engine/ios/LaunchScreenBackground.png
Normal file
|
After Width: | Height: | Size: 128 KiB |
BIN
demo/native/engine/ios/LaunchScreenBackgroundLandscape.png
Normal file
|
After Width: | Height: | Size: 89 KiB |
BIN
demo/native/engine/ios/LaunchScreenBackgroundPortrait.png
Normal file
|
After Width: | Height: | Size: 128 KiB |
1
demo/native/engine/ios/Post-service.cmake
Normal file
@@ -0,0 +1 @@
|
||||
# Supported for Cocos Service!
|
||||
1
demo/native/engine/ios/Pre-service.cmake
Normal file
@@ -0,0 +1 @@
|
||||
# Supported for Cocos Service!
|
||||
8
demo/native/engine/ios/Prefix.pch
Normal file
@@ -0,0 +1,8 @@
|
||||
//
|
||||
// Prefix header for all source files of the 'HelloJavascript' target in the 'HelloJavascript' project
|
||||
//
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
#endif
|
||||
35
demo/native/engine/ios/ViewController.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2013 cocos2d-x.org
|
||||
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
||||
Copyright (c) 2017-2022 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You
|
||||
shall not use Cocos Creator software for developing other software or tools
|
||||
that's used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to
|
||||
you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface ViewController : UIViewController
|
||||
|
||||
@end
|
||||
76
demo/native/engine/ios/ViewController.mm
Normal file
@@ -0,0 +1,76 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2013 cocos2d-x.org
|
||||
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
||||
Copyright (c) 2017-2022 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You shall
|
||||
not use Cocos Creator software for developing other software or tools that's
|
||||
used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#import "ViewController.h"
|
||||
#import "AppDelegate.h"
|
||||
#import "platform/ios/AppDelegateBridge.h"
|
||||
//#include "cocos/platform/Device.h"
|
||||
|
||||
namespace {
|
||||
// cc::Device::Orientation _lastOrientation;
|
||||
}
|
||||
|
||||
@interface ViewController ()
|
||||
|
||||
@end
|
||||
|
||||
@implementation ViewController
|
||||
|
||||
|
||||
- (BOOL) shouldAutorotate {
|
||||
return YES;
|
||||
}
|
||||
|
||||
//fix not hide status on ios7
|
||||
- (BOOL)prefersStatusBarHidden {
|
||||
return YES;
|
||||
}
|
||||
|
||||
// Controls the application's screen edge gesture delay to prevent accidental touches
|
||||
- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures
|
||||
{
|
||||
return UIRectEdgeAll;
|
||||
}
|
||||
|
||||
// Controls the application's preferred home indicator auto-showing otherwise preferredScreenEdgesDeferringSystemGestures is invalidation
|
||||
- (BOOL)prefersHomeIndicatorAutoHidden {
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
|
||||
AppDelegate* delegate = [[UIApplication sharedApplication] delegate];
|
||||
[delegate.appDelegateBridge viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
|
||||
float pixelRatio = [delegate.appDelegateBridge getPixelRatio];
|
||||
|
||||
//CAMetalLayer is available on ios8.0, ios-simulator13.0.
|
||||
CAMetalLayer *layer = (CAMetalLayer *)self.view.layer;
|
||||
CGSize tsize = CGSizeMake(static_cast<int>(size.width * pixelRatio),
|
||||
static_cast<int>(size.height * pixelRatio));
|
||||
layer.drawableSize = tsize;
|
||||
}
|
||||
|
||||
@end
|
||||
42
demo/native/engine/ios/main.mm
Normal file
@@ -0,0 +1,42 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You shall
|
||||
not use Cocos Creator software for developing other software or tools that's
|
||||
used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "platform/BasePlatform.h"
|
||||
#include "AppDelegate.h"
|
||||
|
||||
int main(int argc, const char * argv[]) {
|
||||
cc::BasePlatform* platform = cc::BasePlatform::getPlatform();
|
||||
if (platform->init()) {
|
||||
return -1;
|
||||
}
|
||||
platform->run(argc, argv);
|
||||
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
|
||||
int retVal = UIApplicationMain(argc, (char**)argv, nil, @"AppDelegate");
|
||||
[pool release];
|
||||
return retVal;
|
||||
}
|
||||
|
||||
60
demo/native/engine/ios/service/SDKWrapper.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2017-2022 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You
|
||||
shall not use Cocos Creator software for developing other software or tools
|
||||
that's used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to
|
||||
you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol SDKDelegate <NSObject>
|
||||
|
||||
@optional
|
||||
- (void)application:(UIApplication *)application
|
||||
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions;
|
||||
- (void)applicationDidBecomeActive:(UIApplication *)application;
|
||||
- (void)applicationWillResignActive:(UIApplication *)application;
|
||||
- (void)applicationDidEnterBackground:(UIApplication *)application;
|
||||
- (void)applicationWillEnterForeground:(UIApplication *)application;
|
||||
- (void)applicationWillTerminate:(UIApplication *)application;
|
||||
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application;
|
||||
|
||||
@end
|
||||
|
||||
@interface SDKWrapper : NSObject
|
||||
@property(nonatomic, strong) NSString *name;
|
||||
+ (instancetype)shared;
|
||||
- (void)application:(UIApplication *)application
|
||||
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions;
|
||||
- (void)applicationDidBecomeActive:(UIApplication *)application;
|
||||
- (void)applicationWillResignActive:(UIApplication *)application;
|
||||
- (void)applicationDidEnterBackground:(UIApplication *)application;
|
||||
- (void)applicationWillEnterForeground:(UIApplication *)application;
|
||||
- (void)applicationWillTerminate:(UIApplication *)application;
|
||||
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
142
demo/native/engine/ios/service/SDKWrapper.m
Normal file
@@ -0,0 +1,142 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2017-2020 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
#import "SDKWrapper.h"
|
||||
|
||||
@interface SDKWrapper ()
|
||||
|
||||
@property (nonatomic, strong) NSArray *serviceInstances;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SDKWrapper
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Singleton
|
||||
|
||||
static SDKWrapper *mInstace = nil;
|
||||
|
||||
+ (instancetype)shared {
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
mInstace = [[super allocWithZone:NULL] init];
|
||||
[mInstace initSDKWrapper];
|
||||
});
|
||||
return mInstace;
|
||||
}
|
||||
+ (id)allocWithZone:(struct _NSZone *)zone {
|
||||
return [SDKWrapper shared];
|
||||
}
|
||||
|
||||
+ (id)copyWithZone:(struct _NSZone *)zone {
|
||||
return [SDKWrapper shared];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark private methods
|
||||
- (void)initSDKWrapper {
|
||||
[self loadSDKClass];
|
||||
}
|
||||
|
||||
- (void)loadSDKClass {
|
||||
NSMutableArray *sdks = [NSMutableArray array];
|
||||
@try {
|
||||
NSString *path = [NSString stringWithFormat:@"%@/service.json", [[NSBundle mainBundle] resourcePath]];
|
||||
NSData *data = [NSData dataWithContentsOfFile:path options:NSDataReadingMappedIfSafe error:nil];
|
||||
id obj = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
|
||||
id dic = obj[@"serviceClasses"];
|
||||
if (dic == nil) @throw [[NSException alloc] initWithName:@"JSON Exception" reason:@"serviceClasses not found" userInfo:nil];
|
||||
for (NSString *str in dic) {
|
||||
NSString *className = [[str componentsSeparatedByString:@"."] lastObject];
|
||||
Class clazz = NSClassFromString(className);
|
||||
if (clazz == nil) @throw [[NSException alloc] initWithName:@"Cass Exception"
|
||||
reason:[NSString stringWithFormat:@"class '%@' not found", className]
|
||||
userInfo:nil];
|
||||
id sdk = [[clazz alloc] init];
|
||||
[sdks addObject:sdk];
|
||||
}
|
||||
} @catch (NSException *e) {
|
||||
}
|
||||
self.serviceInstances = [NSArray arrayWithArray:sdks];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Application lifecycle
|
||||
- (void)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||
for (id <SDKDelegate> sdk in self.serviceInstances) {
|
||||
if ([sdk respondsToSelector:@selector(application:didFinishLaunchingWithOptions:)]) {
|
||||
[sdk application:application didFinishLaunchingWithOptions:launchOptions];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
- (void)applicationDidBecomeActive:(UIApplication *)application {
|
||||
for (id sdk in self.serviceInstances) {
|
||||
if ([sdk respondsToSelector:@selector(applicationDidBecomeActive:)]) {
|
||||
[sdk applicationDidBecomeActive:application];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)applicationWillResignActive:(UIApplication *)application {
|
||||
for (id sdk in self.serviceInstances) {
|
||||
if ([sdk respondsToSelector:@selector(applicationWillResignActive:)]) {
|
||||
[sdk applicationWillResignActive:application];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)applicationDidEnterBackground:(UIApplication *)application {
|
||||
for (id sdk in self.serviceInstances) {
|
||||
if ([sdk respondsToSelector:@selector(applicationDidEnterBackground:)]) {
|
||||
[sdk applicationDidEnterBackground:application];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)applicationWillEnterForeground:(UIApplication *)application {
|
||||
for (id sdk in self.serviceInstances) {
|
||||
if ([sdk respondsToSelector:@selector(applicationWillEnterForeground:)]) {
|
||||
[sdk applicationWillEnterForeground:application];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(UIApplication *)application {
|
||||
for (id sdk in self.serviceInstances) {
|
||||
if ([sdk respondsToSelector:@selector(applicationWillTerminate:)]) {
|
||||
[sdk applicationWillTerminate:application];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
|
||||
for (id sdk in self.serviceInstances) {
|
||||
if ([sdk respondsToSelector:@selector(applicationDidReceiveMemoryWarning:)]) {
|
||||
[sdk applicationDidReceiveMemoryWarning:application];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
9
demo/native/engine/ios/zh-Hans.lproj/Localizable.strings
Normal file
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
Localizable.strings
|
||||
*/
|
||||
|
||||
"done" = "完成";
|
||||
"next" = "下一个";
|
||||
"search" = "搜索";
|
||||
"go" = "前往";
|
||||
"send" = "发送";
|
||||