SimpleSnake small updates

- CodeCleanup
- MIT License file
- readme update
This commit is contained in:
aismann 2022-06-15 07:02:08 +02:00
parent db6ea424ea
commit a0dfe6e2ab
86 changed files with 2536 additions and 385 deletions

View File

@ -46,6 +46,7 @@ include(PreventInSourceBuilds)
include(CocosBuildSet)
option(AX_BUILD_TESTS "Build cpp & lua tests" ON)
option(AX_BUILD_EXAMPLES "Build examples" ON)
set(AX_ENABLE_EXT_LUA ON)
@ -57,7 +58,7 @@ set(BUILD_ENGINE_DONE ON)
if(AX_BUILD_TESTS)
# add cpp-template-default into project(adxe) for tmp test
add_subdirectory(${ADXE_ROOT_PATH}/templates/cpp-template-default ${ENGINE_BINARY_PATH}/tests/HelloCpp)
# add cpp tests default
add_subdirectory(${ADXE_ROOT_PATH}/tests/cpp-tests ${ENGINE_BINARY_PATH}/tests/cpp-tests)
@ -72,3 +73,8 @@ if(AX_BUILD_TESTS)
endif(AX_ENABLE_EXT_LUA)
endif()
if(AX_BUILD_EXAMPLES)
# add examples/SimpleSnake into project(adxe) for tmp example
add_subdirectory(${ADXE_ROOT_PATH}/examples/SimpleSnake ${ENGINE_BINARY_PATH}/examples/SimpleSnake)
endif()

View File

@ -105,7 +105,7 @@ Open [APPENDIX.md](APPENDIX.md) for additional information and see [Milestones](
6. Note: If you use non-sdk provided CMake edition, you will need to download ```ninja``` from https://github.com/ninja-build/ninja/releases, and copy ```ninja.exe``` to cmake's bin directory
#### iOS
1. Ensure xcode11+ & [cmake3.21+](https://github.com/Kitware/CMake/releases) are installed, install cmake command line support: ```sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install```
1. Ensure xcode12+ & [cmake3.21+](https://github.com/Kitware/CMake/releases) are installed, install cmake command line support: ```sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install```
2. Execute the following command
```sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer```
3. Generate xcode project

View File

@ -80,7 +80,7 @@
6. 如果使用非sdk自动安装的CMake版本, 需要下载[ninja](https://github.com/ninja-build/ninja/releases) 并且拷贝```ninja.exe```到CMake的bin目录
#### iOS
1. 确保已安装xcode11+和[cmake3.21+](https://github.com/Kitware/CMake/releases), 安装CMake命令行支持: ```sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install```
1. 确保已安装xcode12+和[cmake3.21+](https://github.com/Kitware/CMake/releases), 安装CMake命令行支持: ```sudo "/Applications/CMake.app/Contents/bin/cmake-gui" --install```
2. 执行如下命令确保cmake能成功生成xcode工程:
```sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer```
3. 生成xcode工程, 进入adxe根目录执行如下命令之一:

View File

@ -27,6 +27,7 @@
****************************************************************************/
#include "2d/CCCamera.h"
#include "2d/CCCameraBackgroundBrush.h"
#include "base/CCDirector.h"
#include "platform/CCGLView.h"
#include "2d/CCScene.h"
#include "renderer/CCRenderer.h"
@ -93,14 +94,6 @@ const Camera* Camera::getVisitingCamera()
// end static methods
Camera::Camera()
: _eyeZdistance(1)
, _zoomFactor(1)
, _nearPlane(-1024)
, _farPlane(1024)
, _zoomFactorNearPlane(10)
, _zoomFactorFarPlane(1024)
, _originalPosition({0, 0})
, _isCameraInitialized(false)
{
// minggo comment
// _frustum.setClipZ(true);
@ -144,7 +137,6 @@ void Camera::lookAt(const Vec3& lookAtPos, const Vec3& up)
Vec3::cross(zaxis, xaxis, &yaxis);
yaxis.normalize();
Mat4 rotation;
rotation.m[0] = xaxis.x;
rotation.m[1] = xaxis.y;
rotation.m[2] = xaxis.z;
@ -154,7 +146,6 @@ void Camera::lookAt(const Vec3& lookAtPos, const Vec3& up)
rotation.m[5] = yaxis.y;
rotation.m[6] = yaxis.z;
rotation.m[7] = 0;
rotation.m[8] = zaxis.x;
rotation.m[9] = zaxis.y;
rotation.m[10] = zaxis.z;
@ -186,28 +177,15 @@ void Camera::setAdditionalProjection(const Mat4& mat)
bool Camera::initDefault()
{
if (_projectionType != _director->getProjection())
{
_projectionType = _director->getProjection();
_isCameraInitialized = false;
}
if (_isCameraInitialized)
{
applyCustomProperties();
return true;
}
_isCameraInitialized = true;
auto& size = _director->getWinSize();
auto size = _director->getWinSize();
// create default camera
switch (_projectionType)
auto projection = _director->getProjection();
switch (projection)
{
case Director::Projection::_2D:
{
initOrthographic(size.width, size.height, -1024, 1024);
setPosition3D(Vec3(size.width / 2, size.height / 2, 0.f));
_originalPosition = {size.width / 2, size.height / 2};
setPosition3D(Vec3(0.0f, 0.0f, 0.0f));
setRotation3D(Vec3(0.f, 0.f, 0.f));
break;
}
@ -215,9 +193,8 @@ bool Camera::initDefault()
{
float zeye = _director->getZEye();
initPerspective(60, (float)size.width / size.height, 10, zeye + size.height / 2.0f);
Vec3 eye(size.width / 2.0f, size.height / 2.0f, zeye), center(size.width / 2.0f, size.height / 2.0f, 0.0f),
Vec3 eye(size.width / 2, size.height / 2.0f, zeye), center(size.width / 2, size.height / 2, 0.0f),
up(0.0f, 1.0f, 0.0f);
_eyeZdistance = eye.z;
setPosition3D(eye);
lookAt(center, up);
break;
@ -226,24 +203,15 @@ bool Camera::initDefault()
CCLOG("unrecognized projection");
break;
}
if (_zoomFactor != 1.0F)
applyZoom();
setPosition(getPosition());
return true;
}
bool Camera::initPerspective(float fieldOfView, float aspectRatio, float nearPlane, float farPlane)
{
_fieldOfView = fieldOfView;
_aspectRatio = aspectRatio;
_nearPlane = nearPlane;
_farPlane = farPlane;
if (_zoomFactorFarPlane == 1024)
_zoomFactorFarPlane = farPlane;
if (_zoomFactorNearPlane == 10)
_zoomFactorNearPlane = nearPlane;
_fieldOfView = fieldOfView;
_aspectRatio = aspectRatio;
_nearPlane = nearPlane;
_farPlane = farPlane;
Mat4::createPerspective(_fieldOfView, _aspectRatio, _nearPlane, _farPlane, &_projection);
_viewProjectionDirty = true;
_frustumDirty = true;
@ -291,7 +259,7 @@ Vec2 Camera::projectGL(const Vec3& src) const
Vec4 clipPos;
getViewProjectionMatrix().transformVector(Vec4(src.x, src.y, src.z, 1.0f), &clipPos);
//CCASSERT(clipPos.w != 0.0f, "clipPos.w can't be 0.0f!");
CCASSERT(clipPos.w != 0.0f, "clipPos.w can't be 0.0f!");
float ndcX = clipPos.x / clipPos.w;
float ndcY = clipPos.y / clipPos.w;
@ -386,87 +354,6 @@ void Camera::setDepth(int8_t depth)
}
}
void Camera::setZoom(float factor)
{
if (_projectionType == Director::Projection::_3D)
{
// Push the far plane farther the more we zoom out.
if (_zoomFactorFarPlane * factor > _farPlane)
{
_farPlane = _zoomFactorFarPlane * factor;
applyCustomProperties();
}
// Push the near plane closer the more we zoom in.
if (_zoomFactorNearPlane * factor < _nearPlane)
{
_nearPlane = _zoomFactorNearPlane * factor;
applyCustomProperties();
}
}
_zoomFactor = factor;
applyZoom();
if (_projectionType == Director::Projection::_2D)
setPosition(getPosition());
}
void Camera::applyZoom()
{
switch (_projectionType)
{
case cocos2d::Director::Projection::_2D:
{
this->setScale(_zoomFactor);
break;
}
case cocos2d::Director::Projection::_3D:
{
this->setPositionZ(_eyeZdistance * _zoomFactor);
break;
}
}
}
void Camera::applyCustomProperties()
{
if (_projectionType != _director->getProjection())
{
_projectionType = _director->getProjection();
_isCameraInitialized = false;
initDefault();
return;
}
auto& size = _director->getWinSize();
// create default camera
switch (_projectionType)
{
case Director::Projection::_2D:
{
initOrthographic(size.width, size.height, _nearPlane, _farPlane);
setPosition3D(Vec3(size.width / 2, size.height / 2, 0.f));
_originalPosition = {size.width / 2, size.height / 2};
setRotation3D(Vec3(0.f, 0.f, 0.f));
break;
}
case Director::Projection::_3D:
{
float zeye = _director->getZEye();
initPerspective(_fieldOfView, _aspectRatio, _nearPlane, _farPlane);
Vec3 eye(size.width / 2.0f, size.height / 2.0f, zeye), center(size.width / 2.0f, size.height / 2.0f, 0.0f),
up(0.0f, 1.0f, 0.0f);
_eyeZdistance = eye.z;
setPosition3D(eye);
lookAt(center, up);
break;
}
}
if (_zoomFactor != 1.0F)
applyZoom();
setPosition(getPosition());
}
void Camera::onEnter()
{
if (_scene == nullptr)
@ -487,97 +374,6 @@ void Camera::onExit()
Node::onExit();
}
inline const Vec2& getPositionCenter(const Vec2& pos,
Director::Projection projectionType,
float zoomFactor,
float angleOfRotation)
{
auto director = Director::getInstance();
if (projectionType == Director::Projection::_2D)
{
auto v = director->getVisibleSize();
auto rpos = Vec2(0, 0);
rpos -= v / 2;
rpos.x += pos.x + v.width / 2 * (1.0F - zoomFactor);
rpos.y += pos.y + v.height / 2 * (1.0F - zoomFactor);
return rpos.rotateByAngle(rpos + v / 2 * zoomFactor, -CC_DEGREES_TO_RADIANS(angleOfRotation));
}
return pos;
}
const Vec2& Camera::getPosition() const
{
return _originalPosition;
}
void Camera::setPosition(const Vec2& position)
{
_originalPosition = position;
auto& pos = getPositionCenter(position, _projectionType, getZoom(), getRotation());
Node::setPosition(pos.x, pos.y);
}
void Camera::getPosition(float* x, float* y) const
{
*x = _originalPosition.x;
*y = _originalPosition.y;
}
void Camera::setPosition(float x, float y)
{
_originalPosition = getPositionCenter({x, y}, _projectionType, getZoom(), getRotation());
Node::setPosition(_originalPosition.x, _originalPosition.y);
_originalPosition = {x, y};
}
void Camera::setPosition3D(const Vec3& position)
{
_originalPosition = getPositionCenter({position.x, position.y}, _projectionType, getZoom(), getRotation());
Node::setPosition3D({_originalPosition.x, _originalPosition.y, position.z});
_originalPosition = {position.x, position.y};
}
Vec3 Camera::getPosition3D() const
{
return {_originalPosition.x, _originalPosition.y, getPositionZ()};
}
float Camera::getPositionX() const
{
return _originalPosition.x;
}
void Camera::setPositionX(float x)
{
setPosition(x, _originalPosition.y);
}
float Camera::getPositionY() const
{
return _originalPosition.y;
}
void Camera::setPositionY(float y)
{
setPosition(_originalPosition.x, y);
}
float Camera::getPositionZ() const
{
return Node::getPositionZ();
}
void Camera::setPositionZ(float positionZ)
{
Node::setPositionZ(positionZ);
}
void Camera::setRotation(float rotation)
{
Node::setRotation(rotation);
setPosition(getPosition());
}
void Camera::setScene(Scene* scene)
{
if (_scene != scene)
@ -635,30 +431,6 @@ int Camera::getRenderOrder() const
return result;
}
void Camera::setAspectRatio(float ratio)
{
_aspectRatio = ratio;
applyCustomProperties();
}
void Camera::setFOV(float fieldOfView)
{
_fieldOfView = fieldOfView;
applyCustomProperties();
}
void Camera::setFarPlane(float farPlane)
{
_farPlane = farPlane;
applyCustomProperties();
}
void Camera::setNearPlane(float nearPlane)
{
_nearPlane = nearPlane;
applyCustomProperties();
}
void Camera::visit(Renderer* renderer, const Mat4& parentTransform, uint32_t parentFlags)
{
_viewProjectionUpdated = _transformUpdated;

View File

@ -31,7 +31,6 @@ THE SOFTWARE.
#include "3d/CCFrustum.h"
#include "renderer/CCQuadCommand.h"
#include "renderer/CCCustomCommand.h"
#include "base/CCDirector.h"
NS_CC_BEGIN
@ -235,141 +234,22 @@ public:
int getRenderOrder() const;
/**
* Gets the aspect ratio of the camera if the projection mode is 3D.
*/
float getAspectRatio() const { return _fieldOfView; }
/**
* Sets the aspect ratio of the camera if the projection mode is 3D.
*/
void setAspectRatio(float ratio);
/**
* Gets the field of view of the camera if the projection mode is 3D.
*/
float getFOV() const { return _fieldOfView; }
/**
* Sets the field of view of the camera if the projection mode is 3D.
*/
void setFOV(float fov);
/**
* Gets the frustum's far plane.
* Get the frustum's far plane.
*/
float getFarPlane() const { return _farPlane; }
/**
* Sets the frustum's far plane.
*/
void setFarPlane(float farPlane);
/**
* Gets the frustum's near plane.
* Get the frustum's near plane.
*/
float getNearPlane() const { return _nearPlane; }
/**
* Gets the frustum's near plane.
*/
void setNearPlane(float nearPlane);
/**
* Gets the zoom multiplier of the camera.
*/
float getZoom() const { return _zoomFactor; }
/**
* Sets the zoom multiplier of the camera.
* This is designed to be used with 2D views only.
*
* @param factor The zoom factor of the camera.
*/
void setZoom(float factor);
/**
Apply the zoom factor.
*/
void applyZoom();
/**
Apply the fov, near far planes and aspect values non-destructively.
*/
void applyCustomProperties();
// override
virtual void onEnter() override;
virtual void onExit() override;
/**
* Override of getPosition() in Node class for custom behaviours
*/
virtual const Vec2& getPosition() const override;
/**
* Override of getPosition() in Node class for custom behaviours
*/
virtual void setPosition(const Vec2& position) override;
/**
* Override of getPosition() in Node class for custom behaviours
*/
virtual void getPosition(float* x, float* y) const override;
/**
* Override of setPosition() in Node class for custom behaviours
*/
virtual void setPosition(float x, float y) override;
/**
* Override of setPosition3D() in Node class for custom behaviours
*/
virtual void setPosition3D(const Vec3& position) override;
/**
* Override of getPosition3D() in Node class for custom behaviours
*/
virtual Vec3 getPosition3D() const override;
/**
* Override of getPositionX() in Node class for custom behaviours
*/
virtual float getPositionX() const override;
/**
* Override of setPositionX() in Node class for custom behaviours
*/
virtual void setPositionX(float x) override;
/**
* Override of getPositionY() in Node class for custom behaviours
*/
virtual float getPositionY() const override;
/**
* Override of setPositionY() in Node class for custom behaviours
*/
virtual void setPositionY(float y) override;
/**
* Override of getPositionZ() in Node class for custom behaviours
*/
virtual float getPositionZ() const override;
/**
* Override of setPositionZ() in Node class for custom behaviours
*/
virtual void setPositionZ(float positionZ) override;
/**
* Override of setRotation() in Node class for custom behaviours
*/
virtual void setRotation(float rotation) override;
/**
Before rendering the scene with this camera, the background needs to be cleared.
It will clear the depth buffer with max depth by default.
Use setBackgroundBrush to modify this default behavior.
Before rendering scene with this camera, the background need to be cleared. It clears the depth buffer with max
depth by default. Use setBackgroundBrush to modify the default behavior
*/
void clearBackground();
/**
@ -378,8 +258,8 @@ public:
void apply();
/**
* Whether or not the viewprojection matrix was updated last frame.
* @return True if the viewprojection matrix was updated last frame.
* Whether or not the viewprojection matrix was updated since the last frame.
* @return True if the viewprojection matrix was updated since the last frame.
*/
bool isViewProjectionUpdated() const { return _viewProjectionUpdated; }
@ -402,7 +282,7 @@ public:
~Camera();
/**
* Set the owner scene of the camera, this method shall not be invoked manually
* Set the scene,this method shall not be invoke manually
*/
void setScene(Scene* scene);
@ -420,7 +300,7 @@ protected:
static Camera* _visitingCamera;
static Viewport _defaultViewport;
Scene* _scene = nullptr; // Scene that owns this camera.
Scene* _scene = nullptr; // Scene camera belongs to
Mat4 _projection;
mutable Mat4 _view;
mutable Mat4 _viewInv;
@ -440,15 +320,6 @@ protected:
mutable bool _frustumDirty = true;
int8_t _depth = -1; // camera depth, the depth of camera with CameraFlag::DEFAULT flag is 0 by default, a camera
// with larger depth is drawn on top of camera with smaller depth
Director::Projection _projectionType;
float _eyeZdistance; // Z eye projection distance for 2D in 3D projection.
float _zoomFactor; // The zoom factor of the camera. 3D = (cameraZDistance * _zoomFactor), 2D = (cameraScale * _zoomFactor)
float _zoomFactorFarPlane;
float _zoomFactorNearPlane;
Vec2 _originalPosition;
bool _isCameraInitialized;
CameraBackgroundBrush* _clearBrush = nullptr; // brush used to clear the back ground
};

View File

@ -36,4 +36,9 @@ CC_DLL const char* adxeVersion()
return "adxe-1.0.0b7";
}
CC_DLL const char* cocos2dVersion()
{
return adxeVersion();
}
NS_CC_END

View File

@ -37,10 +37,7 @@ THE SOFTWARE.
NS_CC_BEGIN
inline const char* cocos2dVersion()
{
return adxeVersion();
}
CC_DLL const char* cocos2dVersion();
NS_CC_END

View File

@ -69,7 +69,7 @@ static bool checkReallySupportsASTC()
auto error = glGetError();
#if CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID
if (!error)
if (!error && glGetTexImage)
{
// read pixel RGB: should be: 255, 128, 0
uint8_t pixels[TEXTURE_DIM * TEXTURE_DIM * 4] = {0};

View File

@ -0,0 +1,203 @@
#/****************************************************************************
# Copyright (c) 2013-2014 cocos2d-x.org
# Copyright (c) 2021-2022 Bytedance Inc.
#
# https://adxeproject.github.io
#
# 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.
# ****************************************************************************/
cmake_minimum_required(VERSION 3.10)
set(APP_NAME SimpleSnake)
project(${APP_NAME})
if(NOT DEFINED BUILD_ENGINE_DONE) # to test HelloCpp into root project
if(XCODE)
set(CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY TRUE)
endif()
# config quick starter batch script run.bat for windows
if(WIN32)
file(RELATIVE_PATH CMAKE_BUILD_RELATIVE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/run.bat.in" "${CMAKE_CURRENT_SOURCE_DIR}/run.bat" @ONLY)
endif()
set(ADXE_ROOT "$ENV{ADXE_ROOT}")
if(NOT (ADXE_ROOT STREQUAL ""))
set(ADXE_ROOT_PATH "${ADXE_ROOT}")
file(TO_CMAKE_PATH ${ADXE_ROOT_PATH} ADXE_ROOT_PATH) # string(REPLACE "\\" "/" ADXE_ROOT_PATH ${ADXE_ROOT_PATH})
message(STATUS "Using system env var ADXE_ROOT=${ADXE_ROOT}")
else()
message(FATAL_ERROR "Please run setup.py add system env var 'ADXE_ROOT' to specific the engine root")
endif()
set(CMAKE_MODULE_PATH ${ADXE_ROOT_PATH}/cmake/Modules/)
include(CocosBuildSet)
set(_AX_USE_PREBUILT FALSE)
if (WIN32 AND DEFINED AX_PREBUILT_DIR AND IS_DIRECTORY ${ADXE_ROOT_PATH}/${AX_PREBUILT_DIR})
set(_AX_USE_PREBUILT TRUE)
endif()
if (NOT _AX_USE_PREBUILT)
add_subdirectory(${ADXE_ROOT_PATH}/core ${ENGINE_BINARY_PATH}/adxe/core)
endif()
endif()
# record sources, headers, resources...
set(GAME_SOURCE)
set(GAME_HEADER)
set(GAME_RES_FOLDER
"${CMAKE_CURRENT_SOURCE_DIR}/Resources"
)
if(APPLE OR WINDOWS)
cocos_mark_multi_resources(common_res_files RES_TO "Resources" FOLDERS ${GAME_RES_FOLDER})
endif()
# add cross-platforms source files and header files
list(APPEND GAME_SOURCE
Classes/AppDelegate.cpp
Classes/SimpleSnakeScene.cpp
)
list(APPEND GAME_HEADER
Classes/AppDelegate.h
Classes/SimpleSnakeScene.h
)
if(ANDROID)
# the APP_NAME should match on AndroidManifest.xml
list(APPEND GAME_SOURCE
proj.android/app/jni/hellocpp/main.cpp
)
elseif(LINUX)
list(APPEND GAME_SOURCE
proj.linux/main.cpp
)
elseif(WINDOWS)
list(APPEND GAME_HEADER
proj.win32/main.h
proj.win32/resource.h
)
list(APPEND GAME_SOURCE
proj.win32/main.cpp
proj.win32/game.rc
${common_res_files}
)
elseif(APPLE)
if(IOS)
list(APPEND GAME_HEADER
proj.ios_mac/ios/AppController.h
proj.ios_mac/ios/RootViewController.h
)
set(APP_UI_RES
proj.ios_mac/ios/LaunchScreen.storyboard
proj.ios_mac/ios/LaunchScreenBackground.png
proj.ios_mac/ios/Images.xcassets
)
list(APPEND GAME_SOURCE
proj.ios_mac/ios/main.m
proj.ios_mac/ios/AppController.mm
proj.ios_mac/ios/RootViewController.mm
proj.ios_mac/ios/Prefix.pch
${APP_UI_RES}
)
elseif(MACOSX)
set(APP_UI_RES
proj.ios_mac/mac/Icon.icns
proj.ios_mac/mac/Info.plist
)
list(APPEND GAME_SOURCE
proj.ios_mac/mac/main.cpp
proj.ios_mac/mac/Prefix.pch
${APP_UI_RES}
)
endif()
list(APPEND GAME_SOURCE ${common_res_files})
endif()
# mark app complie info and libs info
set(all_code_files
${GAME_HEADER}
${GAME_SOURCE}
)
if(NOT ANDROID)
add_executable(${APP_NAME} ${all_code_files})
else()
add_library(${APP_NAME} SHARED ${all_code_files})
# whole archive for jni
add_subdirectory(${ADXE_ROOT_PATH}/core/platform/android ${ENGINE_BINARY_PATH}/core/platform)
target_link_libraries(${APP_NAME} -Wl,--whole-archive cpp_android_spec -Wl,--no-whole-archive)
config_android_shared_libs("org.cocos2dx.lib" "${CMAKE_CURRENT_SOURCE_DIR}/proj.android/app/src")
endif()
if (NOT _AX_USE_PREBUILT)
target_link_libraries(${APP_NAME} ${ADXE_CORE_LIB})
endif()
target_include_directories(${APP_NAME}
PRIVATE Classes
PRIVATE ${ADXE_ROOT_PATH}/core/audio
)
# mark app resources
setup_cocos_app_config(${APP_NAME})
if(APPLE)
set_target_properties(${APP_NAME} PROPERTIES RESOURCE "${APP_UI_RES}")
set_xcode_property(${APP_NAME} INSTALL_PATH "\$(LOCAL_APPS_DIR)")
set_xcode_property(${APP_NAME} PRODUCT_BUNDLE_IDENTIFIER "org.adxe.hellocpp")
if(MACOSX)
set_target_properties(${APP_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/mac/Info.plist")
elseif(IOS)
set_target_properties(${APP_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/proj.ios_mac/ios/Info.plist")
set_xcode_property(${APP_NAME} ASSETCATALOG_COMPILER_APPICON_NAME "AppIcon")
endif()
# For code-signing, set the DEVELOPMENT_TEAM:
#set_xcode_property(${APP_NAME} DEVELOPMENT_TEAM "GRLXXXX2K9")
elseif(WINDOWS)
if(NOT _AX_USE_PREBUILT)
cocos_copy_target_dll(${APP_NAME})
endif()
endif()
if((WINDOWS AND (CMAKE_GENERATOR STREQUAL "Ninja")) OR LINUX)
cocos_get_resource_path(APP_RES_DIR ${APP_NAME})
cocos_copy_target_res(${APP_NAME} LINK_TO ${APP_RES_DIR} FOLDERS ${GAME_RES_FOLDER})
elseif(WINDOWS)
set_property(TARGET ${APP_NAME} PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "${GAME_RES_FOLDER}")
if(NOT DEFINED BUILD_ENGINE_DONE)
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT ${APP_NAME})
endif()
endif()
# The optional thirdparties(not dependent by engine)
if (AX_WITH_YAML_CPP)
target_include_directories(${APP_NAME} PRIVATE ${ADXE_ROOT_PATH}/thirdparty/yaml-cpp/include)
target_link_libraries(${APP_NAME} yaml-cpp)
endif()
if (_AX_USE_PREBUILT) # support windows only
include(${ADXE_ROOT_PATH}/cmake/Modules/AdxeLinkHelpers.cmake)
adxe_link_cxx_prebuilt(${APP_NAME} ${ADXE_ROOT_PATH} ${AX_PREBUILT_DIR})
endif()

View File

@ -0,0 +1,138 @@
/****************************************************************************
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
Copyright (c) 2021 Bytedance Inc.
https://adxeproject.github.io/
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.
****************************************************************************/
#include "AppDelegate.h"
#include "SimpleSnakeScene.h"
#define USE_AUDIO_ENGINE 1
#if USE_AUDIO_ENGINE
# include "audio/AudioEngine.h"
#endif
USING_NS_CC;
static cocos2d::Size designResolutionSize = cocos2d::Size(1280, 720);
static cocos2d::Size smallResolutionSize = cocos2d::Size(480, 320);
static cocos2d::Size mediumResolutionSize = cocos2d::Size(1024, 768);
static cocos2d::Size largeResolutionSize = cocos2d::Size(2048, 1536);
AppDelegate::AppDelegate() {}
AppDelegate::~AppDelegate() {}
// if you want a different context, modify the value of glContextAttrs
// it will affect all platforms
void AppDelegate::initGLContextAttrs()
{
// set OpenGL context attributes: red,green,blue,alpha,depth,stencil,multisamplesCount
GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8, 0};
GLView::setGLContextAttrs(glContextAttrs);
}
// if you want to use the package manager to install more packages,
// don't modify or remove this function
static int register_all_packages()
{
return 0; // flag for packages manager
}
bool AppDelegate::applicationDidFinishLaunching()
{
// initialize director
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if (!glview)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || \
(CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
glview = GLViewImpl::createWithRect(
"HelloCpp", cocos2d::Rect(0, 0, designResolutionSize.width, designResolutionSize.height));
#else
glview = GLViewImpl::create("HelloCpp");
#endif
director->setOpenGLView(glview);
}
// turn on display FPS
director->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0f / 60);
// Set the design resolution
glview->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height,
ResolutionPolicy::NO_BORDER);
auto frameSize = glview->getFrameSize();
// if the frame's height is larger than the height of medium size.
if (frameSize.height > mediumResolutionSize.height)
{
director->setContentScaleFactor(MIN(largeResolutionSize.height / designResolutionSize.height,
largeResolutionSize.width / designResolutionSize.width));
}
// if the frame's height is larger than the height of small size.
else if (frameSize.height > smallResolutionSize.height)
{
director->setContentScaleFactor(MIN(mediumResolutionSize.height / designResolutionSize.height,
mediumResolutionSize.width / designResolutionSize.width));
}
// if the frame's height is smaller than the height of medium size.
else
{
director->setContentScaleFactor(MIN(smallResolutionSize.height / designResolutionSize.height,
smallResolutionSize.width / designResolutionSize.width));
}
register_all_packages();
// create a scene. it's an autorelease object
auto scene = utils::createInstance<SimpleSnake>();
// run
director->runWithScene(scene);
return true;
}
// This function will be called when the app is inactive. Note, when receiving a phone call it is invoked.
void AppDelegate::applicationDidEnterBackground()
{
Director::getInstance()->stopAnimation();
#if USE_AUDIO_ENGINE
AudioEngine::pauseAll();
#endif
}
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
Director::getInstance()->startAnimation();
#if USE_AUDIO_ENGINE
AudioEngine::resumeAll();
#endif
}

View File

@ -0,0 +1,64 @@
/****************************************************************************
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
Copyright (c) 2021 Bytedance Inc.
https://adxeproject.github.io/
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.
****************************************************************************/
#ifndef _APP_DELEGATE_H_
#define _APP_DELEGATE_H_
#include "cocos2d.h"
/**
@brief The cocos2d Application.
Private inheritance here hides part of interface from Director.
*/
class AppDelegate : private cocos2d::Application
{
public:
AppDelegate();
virtual ~AppDelegate();
void initGLContextAttrs() override;
/**
@brief Implement Director and Scene init code here.
@return true Initialize success, app continue.
@return false Initialize failed, app terminate.
*/
bool applicationDidFinishLaunching() override;
/**
@brief Called when the application moves to the background
@param the pointer of the application
*/
void applicationDidEnterBackground() override;
/**
@brief Called when the application reenters the foreground
@param the pointer of the application
*/
void applicationWillEnterForeground() override;
};
#endif // _APP_DELEGATE_H_

View File

@ -0,0 +1,270 @@
/*
* Copyright (c) 2022 @aismann; Peter Eismann, Germany; dreifrankensoft
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
#include "SimpleSnakeScene.h"
#include <time.h>
USING_NS_CC;
struct Snake
{
int x, y;
} s[snakeBodies + StartBodies];
struct Fruit
{
int x, y;
} f;
// Print useful error message instead of segfaulting when files are not there.
static void problemLoading(const char* filename)
{
printf("Error while loading: %s\n", filename);
printf(
"Depending on how you compiled you might have to add 'Resources/' in front of filenames in "
"HelloWorldScene.cpp\n");
}
// on "init" you need to initialize your instance
bool SimpleSnake::init()
{
//////////////////////////////
// 1. super init first
if (!Scene::init())
{
return false;
}
auto visibleSize = Director::getInstance()->getVisibleSize();
auto origin = Director::getInstance()->getVisibleOrigin();
auto safeArea = Director::getInstance()->getSafeAreaRect();
auto safeOrigin = safeArea.origin;
/////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it.
// add a "close" icon to exit the progress. it's an autorelease object
auto closeItem = MenuItemImage::create("CloseNormal.png", "CloseSelected.png",
CC_CALLBACK_1(SimpleSnake::menuCloseCallback, this));
if (closeItem == nullptr || closeItem->getContentSize().width <= 0 || closeItem->getContentSize().height <= 0)
{
problemLoading("'CloseNormal.png' and 'CloseSelected.png'");
}
else
{
float x = safeOrigin.x + safeArea.size.width - closeItem->getContentSize().width / 2;
float y = safeOrigin.y + closeItem->getContentSize().height / 2;
closeItem->setPosition(Vec2(x, y));
}
// create menu, it's an autorelease object
auto menu = Menu::create(closeItem, NULL);
menu->setPosition(Vec2::ZERO);
this->addChild(menu, 1);
/////////////////////////////
// 3. add your codes below...
auto listener = EventListenerKeyboard::create();
listener->onKeyPressed = CC_CALLBACK_2(SimpleSnake::onKeyPressed, this);
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
// add a label shows "Hello World"
// create and initialize a label
auto label = Label::createWithTTF("Example - Simple Snake", "fonts/Marker Felt.ttf", 24);
if (label == nullptr)
{
problemLoading("'fonts/Marker Felt.ttf'");
}
else
{
// position the label on the center of the screen
label->setPosition(
Vec2(origin.x + visibleSize.width / 2, origin.y + visibleSize.height - label->getContentSize().height));
// add the label as a child to this layer
this->addChild(label, 1);
}
// add "HelloWorld" splash screen"
auto sprite = Sprite::create("ADXE.png"sv);
if (sprite == nullptr)
{
problemLoading("'ADXE.png'");
}
else
{
// position the sprite on the center of the screen
offset = Vec2(visibleSize.width / 2 + origin.x, visibleSize.height / 2 + origin.y);
sprite->setPosition(offset);
// add the sprite as a child to this layer
this->addChild(sprite, 0);
auto drawNode = DrawNode::create();
drawNode->setPosition(Vec2(0, 0));
addChild(drawNode);
drawNode->drawRect(safeArea.origin, safeArea.origin + safeArea.size, Color4F::BLUE);
}
srand(time(0));
mydraw = DrawNode::create();
addChild(mydraw, 10);
f.x = 10;
f.y = 10;
s[0].x = 20;
s[0].y = 20;
char buffer[1024];
for (int i = 0; i < snakeBodies; i++)
{
myScore[i] = 0.0;
sprintf(buffer, "Level %i Time : %f", i + 1, myScore[i]);
myScoreLabel[i] = Label::createWithTTF(std::string(buffer), "fonts/Marker Felt.ttf", 24);
myScoreLabel[i]->setPosition(
Vec2(130, origin.y + visibleSize.height - label->getContentSize().height - i * 30));
this->addChild(myScoreLabel[i], 1);
}
scheduleUpdate();
return true;
}
void SimpleSnake::onKeyPressed(EventKeyboard::KeyCode keyCode, Event* event)
{
switch (keyCode)
{
case cocos2d::EventKeyboard::KeyCode::KEY_LEFT_ARROW:
if (dir != 2) dir = 1;
break;
case cocos2d::EventKeyboard::KeyCode::KEY_RIGHT_ARROW:
if (dir != 1) dir = 2;
break;
case cocos2d::EventKeyboard::KeyCode::KEY_UP_ARROW:
if (dir != 3) dir = 0;
break;
case cocos2d::EventKeyboard::KeyCode::KEY_DOWN_ARROW:
if (dir != 0) dir = 3;
break;
default:
break;
}
}
void SimpleSnake::menuCloseCallback(Ref* sender)
{
Director::getInstance()->end();
}
void SimpleSnake::update(float delta)
{
static float runTime = 0;
static bool finish = false;
runTime += delta;
endLevelTime += delta;
if (finish)
{
return;
}
if (runTime > level)
{
for (int i = num; i > 0; --i)
{
s[i] = s[i - 1];
}
switch (dir)
{
case 0:
s[0].y++;
if (s[0].y >= M) s[0].y = 0;
break;
case 1:
s[0].x--;
if (s[0].x < 0) s[0].x = N;
break;
case 2:
s[0].x++;
if (s[0].x >= N) s[0].x = 0;
break;
case 3:
s[0].y--;
if (s[0].y < 0) s[0].y = M;
break;
default:
break;
}
if ((s[0].x == f.x) && (s[0].y == f.y))
{
bool posOk;
do
{
posOk = true;
f.x = rand() % N;
f.y = rand() % M;
for (int i = 0; i < num; i++)
{
if (f.x == s[i].x && f.y == s[i].y)
{
posOk = false;
break;
}
}
} while (!posOk);
// score
char buffer[124];
myScore[num - StartBodies] = endLevelTime;
sprintf(buffer, "Level %i Time : %f", num - StartBodies + 1, myScore[num - StartBodies]);
myScoreLabel[num - StartBodies]->setString(buffer);
if (num >= (snakeBodies + StartBodies - 1))
{
myScoreLabel[num - StartBodies]->setString("FINISH");
finish = true;
}
// next level
num++;
level -= 0.01;
startLevelTime = 0.0;
endLevelTime = startLevelTime;
}
runTime = 0;
}
//////// draw ///////
mydraw->clear();
// Draw food
mydraw->drawDot(Vec2(size / 2 + f.x * size, size / 2 + f.y * size), size / 2, Color4B::GREEN);
// Draw snake
for (int i = 0; i < num; i++)
{
mydraw->drawDot(Vec2(size / 2 + s[i].x * size, size / 2 + s[i].y * size), size / 2, Color4B::BLUE);
}
}

View File

@ -0,0 +1,55 @@
/*
* Copyright (c) 2022 @aismann; Peter Eismann, Germany; dreifrankensoft
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
#ifndef __SIMPLE_SNAKE_SCENE_H__
#define __SIMPLE_SNAKE_SCENE_H__
#include "cocos2d.h"
const int snakeBodies = 10;
const int StartBodies = 4;
class SimpleSnake : public cocos2d::Scene
{
public:
virtual bool init() override;
// a selector callback
void menuCloseCallback(Ref* sender);
virtual void update(float delta) override;
void onKeyPressed(cocos2d::EventKeyboard::KeyCode keyCode, cocos2d::Event* event);
cocos2d::Vec2 offset;
cocos2d::DrawNode* mydraw;
// game stuff
int N = 64, M = 36;
int size = 20;
int w = size * N;
int h = size * M;
float level = 0.1;
float myScore[snakeBodies + StartBodies];
float startLevelTime = 0.0;
float endLevelTime = 0.0;
int dir, num = StartBodies;
cocos2d::Label* myScoreLabel[snakeBodies + StartBodies + 1];
};
#endif // __SIMPLE_SNAKE_SCENE_H__

View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) @aismann; Peter Eismann, Germany; dreifrankensoft
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.

View File

@ -0,0 +1,20 @@
Simple Snake
adxe version of a "Simple Snake" game.
If you have any questions or want to continue this project feel free to do so.
Here are some ideas:
- Improve the "score optic"
- Save the "highsore times"
- Use sprites unstead of draw primitives
- Add some effects (sound, exploding stuff, traps, etc)
- or use it as startup
Idea from here:
https://www.youtube.com/channel/UCC7qpnId5RIQruKDJOt2exw
MIT License

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,72 @@
{
"do_default":{
"project_rename":{
"src_project_name":"HelloCpp",
"files":[
]
},
"project_replace_project_name":{
"src_project_name":"HelloCpp",
"files":[
"Classes/AppDelegate.cpp",
"proj.win32/main.cpp",
"proj.android/settings.gradle",
"proj.android/app/res/values/strings.xml",
"proj.ios_mac/ios/main.m",
"proj.ios_mac/ios/Prefix.pch",
"CMakeLists.txt"
]
},
"project_replace_package_name":{
"src_package_name":"org.cocos2dx.hellocpp",
"files":[
"proj.android/app/build.gradle",
"proj.android/app/AndroidManifest.xml"
]
},
"project_replace_so_name": {
"src_so_name": "HelloCpp",
"files": [
"proj.android/app/AndroidManifest.xml"
]
},
"project_replace_mac_bundleid": {
"src_bundle_id": "org.cocos2dx.hellocpp",
"files": [
"proj.ios_mac/mac/Info.plist"
]
},
"project_replace_ios_bundleid": {
"src_bundle_id": "org.cocos2dx.hellocpp",
"files": [
"proj.ios_mac/ios/Info.plist"
]
}
},
"change_orientation": {
"modify_files": [
{
"file_path": "Classes/AppDelegate.cpp",
"pattern": "static\\s+cocos2d\\:\\:Size\\s+([a-zA-Z_\\d]+)\\s*=\\s*cocos2d\\:\\:Size\\(\\s*(\\d+),\\s*(\\d+)\\)",
"replace_string": "static cocos2d::Size \\1 = cocos2d::Size(\\3, \\2)"
},
{
"file_path": "proj.ios_mac/ios/Info.plist",
"pattern": "UIInterfaceOrientationLandscapeRight",
"replace_string": "UIInterfaceOrientationPortrait"
},
{
"file_path": "proj.ios_mac/ios/Info.plist",
"pattern": "UIInterfaceOrientationLandscapeLeft",
"replace_string": "UIInterfaceOrientationPortraitUpsideDown"
},
{
"file_path": "proj.android/app/AndroidManifest.xml",
"pattern": "android:screenOrientation=\\\".*\\\"",
"replace_string": "android:screenOrientation=\"portrait\""
}
]
}
}

View File

@ -0,0 +1,8 @@
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
/.externalNativeBuild

View File

@ -0,0 +1,2 @@
/build
/.externalNativeBuild

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.cocos2dx.hellocpp"
android:installLocation="auto">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-feature android:glEsVersion="0x00020000" />
<application
android:label="@string/app_name"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher">
<!-- Tell Cocos2dxActivity the name of our .so -->
<meta-data android:name="android.app.lib_name"
android:value="HelloCpp" />
<activity
android:name="org.cocos2dx.cpp.AppActivity"
android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:launchMode="singleTask"
android:taskAffinity="" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@ -0,0 +1,123 @@
import org.gradle.internal.os.OperatingSystem
import java.nio.file.Paths
import java.nio.file.Files
apply plugin: 'com.android.application'
apply from: project(':libcocos2dx').projectDir.toString() + "/adxetools.gradle"
android {
compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger()
// setup ndk
def ndkInfo = adxetools.findNDK()
ndkVersion = ndkInfo[0]
if(ndkInfo[1]) {
ndkPath = ndkInfo[1]
}
// setup cmake
def cmakeVer = adxetools.findCMake("3.10.2+", project.rootProject)
defaultConfig {
applicationId "org.cocos2dx.hellocpp"
minSdkVersion PROP_MIN_SDK_VERSION
targetSdkVersion PROP_TARGET_SDK_VERSION
versionCode 1
versionName "1.0"
externalNativeBuild {
cmake {
arguments "-DCMAKE_FIND_ROOT_PATH=", "-DANDROID_STL=c++_shared", "-DANDROID_TOOLCHAIN=clang", "-DANDROID_ARM_NEON=TRUE"
cppFlags "-frtti -fexceptions -fsigned-char"
}
}
ndk {
abiFilters = []
abiFilters.addAll(PROP_APP_ABI.split(':').collect{it as String})
}
}
sourceSets.main {
java.srcDir "src"
res.srcDir "res"
manifest.srcFile "AndroidManifest.xml"
assets.srcDir "../../Resources"
}
externalNativeBuild {
cmake {
version "$cmakeVer"
path "../../CMakeLists.txt"
}
}
signingConfigs {
release {
if (project.hasProperty("RELEASE_STORE_FILE")) {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
keyAlias RELEASE_KEY_ALIAS
keyPassword RELEASE_KEY_PASSWORD
}
}
}
buildTypes {
release {
debuggable false
jniDebuggable false
renderscriptDebuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
if (project.hasProperty("RELEASE_STORE_FILE")) {
signingConfig signingConfigs.release
}
}
debug {
debuggable true
jniDebuggable true
renderscriptDebuggable true
}
}
aaptOptions {
noCompress 'mp3','ogg','wav','mp4','ttf','ttc'
}
}
android.applicationVariants.all { variant ->
def project_root_folder = "${projectDir}/../.."
def dest_assets_folder = "${projectDir}/assets"
// delete previous files first
delete dest_assets_folder
def targetName = variant.name.capitalize()
def copyTaskName = "copy${targetName}ResourcesToAssets"
tasks.register(copyTaskName) {
copy {
from "${buildDir}/../../../Resources"
into "${buildDir}/intermediates/assets/${variant.dirName}"
exclude "**/*.gz"
}
}
tasks.getByName("pre${targetName}Build").dependsOn copyTaskName
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':libcocos2dx')
}
project.afterEvaluate {
if (tasks.findByName("externalNativeBuildDebug")) {
compileDebugJavaWithJavac.dependsOn externalNativeBuildDebug
}
if (tasks.findByName("externalNativeBuildRelease")) {
compileReleaseJavaWithJavac.dependsOn externalNativeBuildRelease
}
}

View File

@ -0,0 +1,44 @@
/****************************************************************************
Copyright (c) 2017-2018 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.
****************************************************************************/
#include <memory>
#include <android/log.h>
#include <jni.h>
#include "AppDelegate.h"
#define LOG_TAG "main"
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
namespace
{
std::unique_ptr<AppDelegate> appDelegate;
}
void cocos_android_app_init(JNIEnv* env)
{
LOGD("cocos_android_app_init");
appDelegate.reset(new AppDelegate());
}

View File

@ -0,0 +1,37 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in E:\developSoftware\Android\SDK/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Proguard Cocos2d-x for release
-keep public class org.cocos2dx.** { *; }
-dontwarn org.cocos2dx.**
-keep public class com.chukong.** { *; }
-dontwarn com.chukong.**
-keep public class com.huawei.android.** { *; }
-dontwarn com.huawei.android.**
# Proguard Apache HTTP for release
-keep class org.apache.http.** { *; }
-dontwarn org.apache.http.**
# Proguard Android Webivew for release. uncomment if you are using a webview in cocos2d-x
#-keep public class android.net.http.SslError
#-keep public class android.webkit.WebViewClient
#-dontwarn android.webkit.WebView
#-dontwarn android.net.http.SslError
#-dontwarn android.webkit.WebViewClient

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@ -0,0 +1,3 @@
<resources>
<string name="app_name">HelloCpp</string>
</resources>

View File

@ -0,0 +1,63 @@
/****************************************************************************
Copyright (c) 2015-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 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.
****************************************************************************/
package org.cocos2dx.cpp;
import android.os.Bundle;
import org.cocos2dx.lib.Cocos2dxActivity;
import org.cocos2dx.lib.SharedLoader;
import android.os.Build;
import android.view.WindowManager;
//import android.view.WindowManager.LayoutParams;
public class AppActivity extends Cocos2dxActivity {
static {
// DNT remove, some android simulator require explicit load shared libraries, otherwise will crash
SharedLoader.load();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.setEnableVirtualButton(false);
super.onCreate(savedInstanceState);
// Workaround in https://stackoverflow.com/questions/16283079/re-launch-of-activity-on-home-button-but-only-the-first-time/16447508
if (!isTaskRoot()) {
// Android launched another instance of the root activity into an existing task
// so just quietly finish and go away, dropping the user back into the activity
// at the top of the stack (ie: the last state of this task)
// Don't need to finish it again since it's finished in super.onCreate .
return;
}
// Make sure we're running on Pie or higher to change cutout mode
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
// Enable rendering into the cutout area
WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
getWindow().setAttributes(lp);
}
// DO OTHER INITIALIZATION BELOW
}
}

View File

@ -0,0 +1,26 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

View File

@ -0,0 +1,42 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# Android SDK version that will be used as the compile project
PROP_COMPILE_SDK_VERSION=28
# Android SDK version that will be used as the earliest version of android this application can run on
PROP_MIN_SDK_VERSION=17
# Android SDK version that will be used as the latest version of android this application has been tested on
PROP_TARGET_SDK_VERSION=28
# List of CPU Archtexture to build that application with
# Available architextures (armeabi-v7a | arm64-v8a | x86)
# To build for multiple architexture, use the `:` between them
# Example - PROP_APP_ABI=armeabi-v7a:arm64-v8a:x86
PROP_APP_ABI=arm64-v8a
# uncomment it and fill in sign information for release mode
#RELEASE_STORE_FILE=file path of keystore
#RELEASE_STORE_PASSWORD=password of keystore
#RELEASE_KEY_ALIAS=alias of key
#RELEASE_KEY_PASSWORD=password of key
android.injected.testOnly=false

Binary file not shown.

View File

@ -0,0 +1,6 @@
#Tue Mar 14 17:40:59 CST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip

View File

@ -0,0 +1,164 @@
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"

View File

@ -0,0 +1,90 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

View File

@ -0,0 +1,6 @@
import java.nio.file.Paths
include ':libcocos2dx'
project(':libcocos2dx').projectDir = new File(Paths.get("${System.env.ADXE_ROOT}/core/platform/android/libcocos2dx").toUri())
include ':HelloCpp'
project(':HelloCpp').projectDir = new File(settingsDir, 'app')
rootProject.name = "HelloCpp"

View File

@ -0,0 +1,36 @@
/****************************************************************************
Copyright (c) 2010-2013 cocos2d-x.org
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 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 <UIKit/UIKit.h>
@class RootViewController;
@interface AppController : NSObject <UIApplicationDelegate> {
}
@property(nonatomic, readonly) RootViewController* viewController;
@end

View File

@ -0,0 +1,162 @@
/****************************************************************************
Copyright (c) 2010-2013 cocos2d-x.org
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 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 "AppController.h"
#import "cocos2d.h"
#import "AppDelegate.h"
#import "RootViewController.h"
@implementation AppController
@synthesize window;
#pragma mark -
#pragma mark Application lifecycle
// cocos2d application instance
static AppDelegate s_sharedApplication;
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
cocos2d::Application* app = cocos2d::Application::getInstance();
// Initialize the GLView attributes
app->initGLContextAttrs();
cocos2d::GLViewImpl::convertAttrs();
// Override point for customization after application launch.
// Add the view controller's view to the window and display.
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Use RootViewController to manage CCEAGLView
_viewController = [[RootViewController alloc] init];
_viewController.wantsFullScreenLayout = YES;
// Set RootViewController to window
if ([[UIDevice currentDevice].systemVersion floatValue] < 6.0)
{
// warning: addSubView doesn't work on iOS6
[window addSubview:_viewController.view];
}
else
{
// use this method on ios6
[window setRootViewController:_viewController];
}
[window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden:true];
// Launching the app with the arguments -NSAllowsDefaultLineBreakStrategy NO to force back to the old behavior.
if ([[UIDevice currentDevice].systemVersion floatValue] >= 13.0f)
{
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"NSAllowsDefaultLineBreakStrategy"];
}
// IMPORTANT: Setting the GLView should be done after creating the RootViewController
cocos2d::GLView* glview = cocos2d::GLViewImpl::createWithEAGLView((__bridge void*)_viewController.view);
cocos2d::Director::getInstance()->setOpenGLView(glview);
// run the cocos2d-x game scene
app->run();
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.
*/
// We don't need to call this method any more. It will interrupt user defined game pause&resume logic
/* cocos2d::Director::getInstance()->pause(); */
}
- (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.
*/
// We don't need to call this method any more. It will interrupt user defined game pause&resume logic
/* cocos2d::Director::getInstance()->resume(); */
}
- (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.
*/
cocos2d::Application::getInstance()->applicationDidEnterBackground();
}
- (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.
*/
cocos2d::Application::getInstance()->applicationWillEnterForeground();
}
- (void)applicationWillTerminate:(UIApplication*)application
{
/*
Called when the application is about to terminate.
See also applicationDidEnterBackground:.
*/
}
#pragma mark -
#pragma mark Memory management
- (void)applicationDidReceiveMemoryWarning:(UIApplication*)application
{
/*
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk)
later.
*/
}
#if __has_feature(objc_arc)
#else
- (void)dealloc
{
[window release];
[_viewController release];
[super dealloc];
}
#endif
@end

View File

@ -0,0 +1,157 @@
{
"images" : [
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Icon-20@2x.png",
"scale" : "2x"
},
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "Icon-20@3x.png",
"scale" : "3x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-29.png",
"scale" : "1x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-29@2x.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "Icon-29@3x.png",
"scale" : "3x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-40@2x.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "Icon-40@3x.png",
"scale" : "3x"
},
{
"size" : "57x57",
"idiom" : "iphone",
"filename" : "Icon-57.png",
"scale" : "1x"
},
{
"size" : "57x57",
"idiom" : "iphone",
"filename" : "Icon-57@2x.png",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-60@2x.png",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "Icon-60@3x.png",
"scale" : "3x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "Icon-20.png",
"scale" : "1x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"filename" : "Icon-20@2x.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Icon-29.png",
"scale" : "1x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "Icon-29@2x.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Icon-40.png",
"scale" : "1x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "Icon-40@2x.png",
"scale" : "2x"
},
{
"size" : "50x50",
"idiom" : "ipad",
"filename" : "Icon-50.png",
"scale" : "1x"
},
{
"size" : "50x50",
"idiom" : "ipad",
"filename" : "Icon-50@2x.png",
"scale" : "2x"
},
{
"size" : "72x72",
"idiom" : "ipad",
"filename" : "Icon-72.png",
"scale" : "1x"
},
{
"size" : "72x72",
"idiom" : "ipad",
"filename" : "Icon-72@2x.png",
"scale" : "2x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "Icon-76.png",
"scale" : "1x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "Icon-76@2x.png",
"scale" : "2x"
},
{
"size" : "83.5x83.5",
"idiom" : "ipad",
"filename" : "Icon-83.5@2x.png",
"scale" : "2x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

View File

@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@ -0,0 +1,45 @@
<?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>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleDisplayName</key>
<string>${PROJECT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string>Icon-57.png</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PROJECT_NAME}</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIAppFonts</key>
<array/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIPrerenderedIcon</key>
<true/>
<key>UIStatusBarHidden</key>
<true/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
</array>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2019. All rights reserved.</string>
</dict>
</plist>

View 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="1792" 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>

Binary file not shown.

After

Width:  |  Height:  |  Size: 574 KiB

View File

@ -0,0 +1,12 @@
//
// Prefix header for all source files of the 'iphone' target in the 'iphone' project
//
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#endif
#ifdef __cplusplus
#include "cocos2d.h"
#endif

View File

@ -0,0 +1,33 @@
/****************************************************************************
Copyright (c) 2013 cocos2d-x.org
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 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 <UIKit/UIKit.h>
@interface RootViewController : UIViewController {
}
- (BOOL)prefersStatusBarHidden;
@end

View File

@ -0,0 +1,130 @@
/****************************************************************************
Copyright (c) 2013 cocos2d-x.org
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 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 "RootViewController.h"
#import "cocos2d.h"
#import "platform/ios/CCEAGLView-ios.h"
@implementation RootViewController
/*
// The designated initializer. Override if you create the controller programmatically and want to perform
customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
// Custom initialization
}
return self;
}
*/
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView
{
// Initialize the CCEAGLView
CCEAGLView* eaglView = [CCEAGLView viewWithFrame:[UIScreen mainScreen].bounds
pixelFormat:(__bridge NSString*)cocos2d::GLViewImpl::_pixelFormat
depthFormat:cocos2d::GLViewImpl::_depthFormat
preserveBackbuffer:NO
sharegroup:nil
multiSampling:cocos2d::GLViewImpl::_multisamplingCount > 0 ? YES : NO
numberOfSamples:cocos2d::GLViewImpl::_multisamplingCount];
// Enable or disable multiple touches
[eaglView setMultipleTouchEnabled:NO];
// Set EAGLView as view of RootViewController
self.view = eaglView;
}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
}
// For ios6, use supportedInterfaceOrientations & shouldAutorotate instead
#ifdef __IPHONE_6_0
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAllButUpsideDown;
}
#endif
- (BOOL)shouldAutorotate
{
return YES;
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
auto glview = cocos2d::Director::getInstance()->getOpenGLView();
if (glview)
{
CCEAGLView* eaglview = (__bridge CCEAGLView*)glview->getEAGLView();
if (eaglview)
{
CGSize s = CGSizeMake([eaglview getWidth], [eaglview getHeight]);
cocos2d::Application::getInstance()->applicationScreenSizeChanged((int)s.width, (int)s.height);
}
}
}
// fix not hide status on ios7
- (BOOL)prefersStatusBarHidden
{
return YES;
}
// Controls the application's preferred home indicator auto-hiding when this view controller is shown.
- (BOOL)prefersHomeIndicatorAutoHidden
{
return YES;
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
@end

View File

@ -0,0 +1,15 @@
<?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>compileBitcode</key>
<false/>
<key>method</key>
<string>development</string>
<key>provisioningProfiles</key>
<dict>
<key>Bundle Identifier</key>
<string>Provision Prifile Name</string>
</dict>
</dict>
</plist>

View File

@ -0,0 +1,7 @@
#import <UIKit/UIKit.h>
int main(int argc, char *argv[]) {
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, @"AppController");
}
}

Binary file not shown.

View File

@ -0,0 +1,36 @@
<?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>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string>Icon</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PROJECT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.games</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2013. All rights reserved.</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>

View File

@ -0,0 +1,11 @@
//
// Prefix header for all source files of the 'Paralaxer' target in the 'Paralaxer' project
//
#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#endif
#ifdef __cplusplus
#include "cocos2d.h"
#endif

View File

@ -0,0 +1,35 @@
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
Copyright (c) 2017-2018 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.
****************************************************************************/
#include "AppDelegate.h"
#include "cocos2d.h"
USING_NS_CC;
int main(int argc, char* argv[])
{
AppDelegate app;
return Application::getInstance()->run();
}

View File

@ -0,0 +1,39 @@
/****************************************************************************
Copyright (c) 2017-2018 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.
****************************************************************************/
#include "../Classes/AppDelegate.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string>
USING_NS_CC;
int main(int argc, char** argv)
{
// create the application instance
AppDelegate app;
return Application::getInstance()->run();
}

View File

@ -0,0 +1,8 @@
{
"copy_resources": [
{
"from": "../Resources",
"to": ""
}
]
}

View File

@ -0,0 +1,86 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#define APSTUDIO_HIDDEN_SYMBOLS
#include "windows.h"
#undef APSTUDIO_HIDDEN_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
GLFW_ICON ICON "res\\game.ico"
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904B0"
BEGIN
VALUE "CompanyName", "\0"
VALUE "FileDescription", "game Module\0"
VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", "game\0"
VALUE "LegalCopyright", "Copyright \0"
VALUE "OriginalFilename", "game.exe\0"
VALUE "ProductName", "game Module\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0409, 0x04B0
END
END
/////////////////////////////////////////////////////////////////////////////
#endif // !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)

View File

@ -0,0 +1,39 @@
/****************************************************************************
Copyright (c) 2017-2018 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.
****************************************************************************/
#include "main.h"
#include "AppDelegate.h"
#include "cocos2d.h"
USING_NS_CC;
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
// create the application instance
AppDelegate app;
return Application::getInstance()->run();
}

View File

@ -0,0 +1,37 @@
/****************************************************************************
Copyright (c) 2017-2018 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.
****************************************************************************/
#ifndef __MAIN_H__
#define __MAIN_H__
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>
#include <tchar.h>
// C RunTime Header Files
#include "platform/CCStdC.h"
#endif // __MAIN_H__

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

View File

@ -0,0 +1,44 @@
/****************************************************************************
Copyright (c) 2017-2018 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.
****************************************************************************/
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by game.RC
//
#define IDS_PROJNAME 100
#define IDR_TESTJS 100
#define ID_FILE_NEW_WINDOW 32771
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
# ifndef APSTUDIO_READONLY_SYMBOLS
# define _APS_NEXT_RESOURCE_VALUE 201
# define _APS_NEXT_CONTROL_VALUE 1000
# define _APS_NEXT_SYMED_VALUE 101
# define _APS_NEXT_COMMAND_VALUE 32775
# endif
#endif

View File

@ -0,0 +1,25 @@
@echo off
rem !!!Don't move this file
rem usage: run.bat <BUILD_CFG>
rem BUILD_CFG could be Debug,Release,MinSizeRel,RelWithDebInfo
set myDir=%~dp0
set cacheFile=%myDir%run.bat.txt
echo Entering run.bat directory: %myDir%
cd /d %myDir%
set APP_NAME=@APP_NAME@
set BUILD_DIR=@CMAKE_BUILD_RELATIVE_DIR@
set BUILD_CFG=%1
rem Determine which build config to run
if not defined BUILD_CFG if exist %cacheFile% set /p BUILD_CFG=< %cacheFile%
if not defined BUILD_CFG set /p BUILD_CFG=Please input Build config(Debug,Release,MinSizeRel,RelWithDebInfo):
if not defined BUILD_CFG set BUILD_CFG=Debug
rem Save run config to run.bat.txt
echo %BUILD_CFG%>%cacheFile%
start /D %myDir%Resources %BUILD_DIR%/bin/%APP_NAME%/%BUILD_CFG%/%APP_NAME%.exe

View File

@ -200,4 +200,4 @@ endif()
if (_AX_USE_PREBUILT) # support windows only
include(${ADXE_ROOT_PATH}/cmake/Modules/AdxeLinkHelpers.cmake)
adxe_link_cxx_prebuilt(${APP_NAME} ${ADXE_ROOT_PATH} ${AX_PREBUILT_DIR})
endif()
endif()