Repository: zym2014/mir9-lua
Branch: master
Commit: 2b7bd046f42a
Files: 427
Total size: 4.7 MB
Directory structure:
gitextract_n8c0ksdh/
├── README.md
├── 发布说明.txt
└── 源代码/
├── 2.2.5/
│ └── mir9/
│ ├── .buildpath
│ ├── .cocos-project.json
│ ├── .project
│ ├── .settings/
│ │ ├── org.eclipse.core.resources.prefs
│ │ └── version.json
│ ├── config.json
│ ├── proj.android/
│ │ ├── .classpath
│ │ ├── .project
│ │ ├── .settings/
│ │ │ └── org.eclipse.jdt.core.prefs
│ │ ├── AndroidManifest.xml
│ │ ├── build_native.bat
│ │ ├── build_native.sh
│ │ ├── clean.bat
│ │ ├── clean.sh
│ │ ├── gen/
│ │ │ └── com/
│ │ │ └── zym/
│ │ │ └── mir9/
│ │ │ ├── BuildConfig.java
│ │ │ └── R.java
│ │ ├── jni/
│ │ │ ├── Android.mk
│ │ │ ├── Application.mk
│ │ │ ├── hellocpp/
│ │ │ │ └── main.cpp
│ │ │ └── list.sh
│ │ ├── project.properties
│ │ ├── res/
│ │ │ └── values/
│ │ │ └── strings.xml
│ │ └── src/
│ │ └── com/
│ │ └── zym/
│ │ └── mir9/
│ │ └── Mir9.java
│ ├── proj.ios/
│ │ ├── AppController.h
│ │ ├── AppController.mm
│ │ ├── Resources/
│ │ │ └── Info.plist
│ │ ├── RootViewController.h
│ │ ├── RootViewController.mm
│ │ ├── main.m
│ │ └── mir9.xcodeproj/
│ │ └── project.pbxproj
│ ├── proj.mac/
│ │ ├── AppController.h
│ │ ├── AppController.mm
│ │ ├── Icon.icns
│ │ ├── Info.plist
│ │ ├── MainMenu.xib
│ │ ├── main.m
│ │ └── mir9.xcodeproj/
│ │ └── project.pbxproj
│ ├── proj.win32/
│ │ ├── app.cpp
│ │ ├── app.h
│ │ ├── app.rc
│ │ ├── mir9.sln
│ │ ├── mir9.v11.suo
│ │ ├── mir9.vcxproj
│ │ ├── mir9.vcxproj.filters
│ │ ├── resource.h
│ │ ├── stdafx.cpp
│ │ ├── stdafx.h
│ │ └── targetver.h
│ ├── run-mac.sh
│ ├── run-win.bat
│ ├── scripts/
│ │ ├── app/
│ │ │ ├── GameSocket.lua
│ │ │ ├── MyApp.lua
│ │ │ ├── figure/
│ │ │ │ ├── Enemy.lua
│ │ │ │ ├── Figure.lua
│ │ │ │ ├── Monomer.lua
│ │ │ │ ├── Player.lua
│ │ │ │ ├── PlayerController.lua
│ │ │ │ └── TextureController.lua
│ │ │ ├── game_ui/
│ │ │ │ ├── AttackEnemyInfo.lua
│ │ │ │ ├── CCTouchMouse.lua
│ │ │ │ ├── FlutteringFairy.lua
│ │ │ │ ├── GameInfoUIController.lua
│ │ │ │ ├── GameOptions.lua
│ │ │ │ ├── GameTabBarMenu.lua
│ │ │ │ ├── LAlertView.lua
│ │ │ │ ├── LOperationMenu.lua
│ │ │ │ ├── MapThumbnailLayer.lua
│ │ │ │ ├── ProgressAutomatic.lua
│ │ │ │ ├── PropColumn.lua
│ │ │ │ └── SkillTableView.lua
│ │ │ ├── map/
│ │ │ │ ├── AStarSearch.lua
│ │ │ │ ├── BgMap.lua
│ │ │ │ ├── BgMapFloorTile.lua
│ │ │ │ ├── MapPoint.lua
│ │ │ │ ├── NpcFigure.lua
│ │ │ │ ├── NpcInfo.lua
│ │ │ │ ├── NpcInfoSystem.lua
│ │ │ │ ├── PathAStar.lua
│ │ │ │ └── PortalSprite.lua
│ │ │ ├── prop_system/
│ │ │ │ ├── PropIconShow.lua
│ │ │ │ ├── PropInfo.lua
│ │ │ │ └── PropSystem.lua
│ │ │ ├── scenes/
│ │ │ │ ├── GameLoading.lua
│ │ │ │ ├── LoginScene.lua
│ │ │ │ ├── MainScene.lua
│ │ │ │ └── RoleSelScene.lua
│ │ │ └── skill_system/
│ │ │ ├── AttackSkillInfo.lua
│ │ │ ├── AttackSkillSystem.lua
│ │ │ └── SkillEffectShow.lua
│ │ ├── config.lua
│ │ └── main.lua
│ └── sources/
│ ├── AppDelegate.cpp
│ └── AppDelegate.h
└── mir9/
├── .project
├── config.json
├── frameworks/
│ └── runtime-src/
│ ├── Classes/
│ │ ├── AppDelegate.cpp
│ │ ├── AppDelegate.h
│ │ ├── CodeIDESupport.h
│ │ ├── ConfigParser.cpp
│ │ ├── ConfigParser.h
│ │ ├── VisibleRect.cpp
│ │ ├── VisibleRect.h
│ │ ├── anysdk_manual_bindings.cpp
│ │ ├── anysdk_manual_bindings.h
│ │ ├── anysdkbindings.cpp
│ │ ├── anysdkbindings.h
│ │ ├── lua_module_register.h
│ │ └── runtime/
│ │ ├── ConnectWaitLayer.cpp
│ │ ├── ConnectWaitLayer.h
│ │ ├── ConsoleCommand.cpp
│ │ ├── ConsoleCommand.h
│ │ ├── FileServer.cpp
│ │ ├── FileServer.h
│ │ ├── Landscape_png.cpp
│ │ ├── PlayDisable_png.cpp
│ │ ├── PlayEnable_png.cpp
│ │ ├── Portrait_png.cpp
│ │ ├── Protos.pb.cc
│ │ ├── Protos.pb.h
│ │ ├── ResData.h
│ │ ├── Runtime.cpp
│ │ ├── Runtime.h
│ │ ├── Shine_png.cpp
│ │ ├── lua_debugger.c
│ │ └── lua_debugger.h
│ ├── proj.android/
│ │ ├── AndroidManifest.xml
│ │ ├── ant.properties
│ │ ├── build-cfg.json
│ │ ├── build.xml
│ │ ├── build_apk.bat
│ │ ├── build_apk.sh
│ │ ├── build_native.bat
│ │ ├── build_native.sh
│ │ ├── build_native_release.bat
│ │ ├── build_native_release.sh
│ │ ├── clean.bat
│ │ ├── clean.sh
│ │ ├── gen/
│ │ │ └── com/
│ │ │ └── zym/
│ │ │ └── mir9/
│ │ │ └── R.java
│ │ ├── jni/
│ │ │ ├── Android.mk
│ │ │ ├── Application.mk
│ │ │ └── hellolua/
│ │ │ ├── Runtime_android.cpp
│ │ │ └── main.cpp
│ │ ├── libs/
│ │ │ └── libPluginProtocol.jar
│ │ ├── proguard-project.txt
│ │ ├── project.properties
│ │ ├── protocols/
│ │ │ ├── android/
│ │ │ │ ├── Android.mk
│ │ │ │ ├── PluginJavaData.h
│ │ │ │ ├── PluginJniHelper.h
│ │ │ │ ├── PluginJniMacros.h
│ │ │ │ ├── PluginUtils.h
│ │ │ │ ├── lib/
│ │ │ │ │ ├── armeabi/
│ │ │ │ │ │ └── libPluginProtocolStatic.a
│ │ │ │ │ ├── armeabi-v7a/
│ │ │ │ │ │ └── libPluginProtocolStatic.a
│ │ │ │ │ └── x86/
│ │ │ │ │ └── libPluginProtocolStatic.a
│ │ │ │ └── libPluginProtocol.jar
│ │ │ ├── include/
│ │ │ │ ├── AgentManager.h
│ │ │ │ ├── PluginFactory.h
│ │ │ │ ├── PluginManager.h
│ │ │ │ ├── PluginParam.h
│ │ │ │ ├── PluginProtocol.h
│ │ │ │ ├── ProtocolAds.h
│ │ │ │ ├── ProtocolAnalytics.h
│ │ │ │ ├── ProtocolIAP.h
│ │ │ │ ├── ProtocolPush.h
│ │ │ │ ├── ProtocolShare.h
│ │ │ │ ├── ProtocolSocial.h
│ │ │ │ └── ProtocolUser.h
│ │ │ └── res/
│ │ │ ├── layout/
│ │ │ │ ├── plugin_ads.xml
│ │ │ │ └── plugin_login.xml
│ │ │ └── values/
│ │ │ └── plugin_string.xml
│ │ ├── res/
│ │ │ ├── layout/
│ │ │ │ ├── plugin_ads.xml
│ │ │ │ └── plugin_login.xml
│ │ │ └── values/
│ │ │ ├── plugin_string.xml
│ │ │ └── strings.xml
│ │ └── src/
│ │ └── org/
│ │ └── cocos2dx/
│ │ ├── lib/
│ │ │ └── QuickHTTPInterface.java
│ │ └── lua/
│ │ └── AppActivity.java
│ ├── proj.android_no_anysdk/
│ │ ├── .classpath
│ │ ├── .project
│ │ ├── .settings/
│ │ │ └── org.eclipse.jdt.core.prefs
│ │ ├── AndroidManifest.xml
│ │ ├── ant.properties
│ │ ├── build-cfg.json
│ │ ├── build.xml
│ │ ├── build_apk.bat
│ │ ├── build_apk.sh
│ │ ├── build_native.bat
│ │ ├── build_native.sh
│ │ ├── build_native_release.bat
│ │ ├── build_native_release.sh
│ │ ├── clean.bat
│ │ ├── clean.sh
│ │ ├── gen/
│ │ │ └── com/
│ │ │ └── zym/
│ │ │ └── mir9/
│ │ │ ├── BuildConfig.java
│ │ │ └── R.java
│ │ ├── jni/
│ │ │ ├── Android.mk
│ │ │ ├── Application.mk
│ │ │ └── hellolua/
│ │ │ ├── Runtime_android.cpp
│ │ │ └── main.cpp
│ │ ├── keystore
│ │ ├── proguard-project.txt
│ │ ├── project.properties
│ │ ├── res/
│ │ │ └── values/
│ │ │ └── strings.xml
│ │ └── src/
│ │ └── org/
│ │ └── cocos2dx/
│ │ ├── lib/
│ │ │ └── QuickHTTPInterface.java
│ │ └── lua/
│ │ └── AppActivity.java
│ ├── proj.ios_mac/
│ │ ├── Runtime_ios-mac.mm
│ │ ├── ios/
│ │ │ ├── AppController.h
│ │ │ ├── AppController.mm
│ │ │ ├── Info.plist
│ │ │ ├── Prefix.pch
│ │ │ ├── RootViewController.h
│ │ │ ├── RootViewController.mm
│ │ │ ├── build-cfg.json
│ │ │ └── main.m
│ │ ├── mac/
│ │ │ ├── ConsoleWindow.xib
│ │ │ ├── ConsoleWindowController.h
│ │ │ ├── ConsoleWindowController.m
│ │ │ ├── Icon.icns
│ │ │ ├── Info.plist
│ │ │ ├── Prefix.pch
│ │ │ ├── SimulatorApp.h
│ │ │ ├── SimulatorApp.mm
│ │ │ ├── build-cfg.json
│ │ │ ├── en.lproj/
│ │ │ │ └── MainMenu.xib
│ │ │ └── main.m
│ │ └── mir9.xcodeproj/
│ │ └── project.pbxproj
│ ├── proj.win32/
│ │ ├── Runtime_win32.cpp
│ │ ├── SimulatorWindow.cpp
│ │ ├── SimulatorWindow.h
│ │ ├── build-cfg.json
│ │ ├── game.rc
│ │ ├── main.cpp
│ │ ├── main.h
│ │ ├── mir9.sln
│ │ ├── mir9.vcxproj
│ │ ├── mir9.vcxproj.filters
│ │ ├── mir9.vcxproj.user
│ │ └── resource.h
│ └── proj.wp8-xaml/
│ ├── App/
│ │ ├── App.xaml
│ │ ├── App.xaml.cs
│ │ ├── EditBox.xaml
│ │ ├── EditBox.xaml.cs
│ │ ├── LocalizedStrings.cs
│ │ ├── MainPage.xaml
│ │ ├── MainPage.xaml.cs
│ │ ├── Properties/
│ │ │ ├── AppManifest.xml
│ │ │ ├── AssemblyInfo.cs
│ │ │ └── WMAppManifest.xml
│ │ ├── Resources/
│ │ │ ├── AppResources.Designer.cs
│ │ │ └── AppResources.resx
│ │ └── mir9.csproj
│ ├── AppComponent/
│ │ ├── mir9Component.vcxproj
│ │ ├── mir9Component.vcxproj.filters
│ │ └── src/
│ │ ├── Cocos2dRenderer.cpp
│ │ ├── Cocos2dRenderer.h
│ │ ├── Direct3DContentProvider.cpp
│ │ ├── Direct3DContentProvider.h
│ │ ├── Direct3DInterop.cpp
│ │ ├── Direct3DInterop.h
│ │ ├── DirectXBase.cpp
│ │ ├── DirectXBase.h
│ │ ├── DirectXHelper.h
│ │ ├── EditBoxEvent.cpp
│ │ ├── EditBoxEvent.h
│ │ ├── pch.cpp
│ │ └── pch.h
│ └── mir9.sln
├── res/
│ └── README.txt
└── src/
├── app/
│ ├── GameSocket.lua
│ ├── MyApp.lua
│ ├── figure/
│ │ ├── Enemy.lua
│ │ ├── Figure.lua
│ │ ├── Monomer.lua
│ │ ├── Player.lua
│ │ ├── PlayerController.lua
│ │ └── TextureController.lua
│ ├── game_ui/
│ │ ├── AttackEnemyInfo.lua
│ │ ├── CCTouchMouse.lua
│ │ ├── FlutteringFairy.lua
│ │ ├── GameInfoUIController.lua
│ │ ├── GameOptions.lua
│ │ ├── GameTabBarMenu.lua
│ │ ├── LAlertView.lua
│ │ ├── LOperationMenu.lua
│ │ ├── MapThumbnailLayer.lua
│ │ ├── ProgressAutomatic.lua
│ │ ├── PropColumn.lua
│ │ └── SkillTableView.lua
│ ├── map/
│ │ ├── AStarSearch.lua
│ │ ├── BgMap.lua
│ │ ├── BgMapFloorTile.lua
│ │ ├── MapPoint.lua
│ │ ├── NpcFigure.lua
│ │ ├── NpcInfo.lua
│ │ ├── NpcInfoSystem.lua
│ │ ├── PathAStar.lua
│ │ └── PortalSprite.lua
│ ├── prop_system/
│ │ ├── PropIconShow.lua
│ │ ├── PropInfo.lua
│ │ └── PropSystem.lua
│ ├── scenes/
│ │ ├── GameLoading.lua
│ │ ├── LoginScene.lua
│ │ ├── MainScene.lua
│ │ └── RoleSelScene.lua
│ └── skill_system/
│ ├── AttackSkillInfo.lua
│ ├── AttackSkillSystem.lua
│ └── SkillEffectShow.lua
├── cocos/
│ ├── cocos2d/
│ │ ├── Cocos2d.lua
│ │ ├── Cocos2dConstants.lua
│ │ ├── DeprecatedCocos2dClass.lua
│ │ ├── DeprecatedCocos2dEnum.lua
│ │ ├── DeprecatedCocos2dFunc.lua
│ │ ├── DeprecatedOpenglEnum.lua
│ │ ├── DrawPrimitives.lua
│ │ ├── Opengl.lua
│ │ ├── OpenglConstants.lua
│ │ ├── bitExtend.lua
│ │ ├── extern.lua
│ │ ├── json.lua
│ │ ├── luaj.lua
│ │ └── luaoc.lua
│ ├── cocosbuilder/
│ │ ├── CCBReaderLoad.lua
│ │ └── DeprecatedCocosBuilderClass.lua
│ ├── cocosdenshion/
│ │ ├── AudioEngine.lua
│ │ ├── DeprecatedCocosDenshionClass.lua
│ │ └── DeprecatedCocosDenshionFunc.lua
│ ├── cocostudio/
│ │ ├── CocoStudio.lua
│ │ ├── DeprecatedCocoStudioClass.lua
│ │ ├── DeprecatedCocoStudioFunc.lua
│ │ └── StudioConstants.lua
│ ├── controller/
│ │ └── ControllerConstants.lua
│ ├── extension/
│ │ ├── DeprecatedExtensionClass.lua
│ │ ├── DeprecatedExtensionEnum.lua
│ │ ├── DeprecatedExtensionFunc.lua
│ │ └── ExtensionConstants.lua
│ ├── init.lua
│ ├── network/
│ │ ├── DeprecatedNetworkClass.lua
│ │ ├── DeprecatedNetworkEnum.lua
│ │ ├── DeprecatedNetworkFunc.lua
│ │ └── NetworkConstants.lua
│ ├── spine/
│ │ └── SpineConstants.lua
│ └── ui/
│ ├── DeprecatedUIEnum.lua
│ ├── DeprecatedUIFunc.lua
│ ├── GuiConstants.lua
│ └── experimentalUIConstants.lua
├── config.lua
├── framework/
│ ├── anysdkConst.lua
│ ├── audio.lua
│ ├── cc/
│ │ ├── EventProxy.lua
│ │ ├── GameObject.lua
│ │ ├── Registry.lua
│ │ ├── components/
│ │ │ ├── Component.lua
│ │ │ ├── behavior/
│ │ │ │ ├── EventProtocol.lua
│ │ │ │ └── StateMachine.lua
│ │ │ └── ui/
│ │ │ ├── BasicLayoutProtocol.lua
│ │ │ ├── DraggableProtocol.lua
│ │ │ └── LayoutProtocol.lua
│ │ ├── init.lua
│ │ ├── mvc/
│ │ │ ├── AppBase.lua
│ │ │ ├── ModelBase.lua
│ │ │ └── init.lua
│ │ ├── net/
│ │ │ ├── SocketTCP.lua
│ │ │ └── init.lua
│ │ ├── sdk/
│ │ │ └── Store.lua
│ │ ├── ui/
│ │ │ ├── UIBoxLayout.lua
│ │ │ ├── UIButton.lua
│ │ │ ├── UICheckBoxButton.lua
│ │ │ ├── UICheckBoxButtonGroup.lua
│ │ │ ├── UIGroup.lua
│ │ │ ├── UIImage.lua
│ │ │ ├── UIInput.lua
│ │ │ ├── UILabel.lua
│ │ │ ├── UILayout.lua
│ │ │ ├── UIListView.lua
│ │ │ ├── UIListViewItem.lua
│ │ │ ├── UILoadingBar.lua
│ │ │ ├── UIPageView.lua
│ │ │ ├── UIPageViewItem.lua
│ │ │ ├── UIPushButton.lua
│ │ │ ├── UIScrollView.lua
│ │ │ ├── UISlider.lua
│ │ │ ├── UIStretch.lua
│ │ │ └── init.lua
│ │ ├── uiloader/
│ │ │ ├── CCSSceneLoader.lua
│ │ │ ├── CCSUILoader.lua
│ │ │ ├── UILoaderUtilitys.lua
│ │ │ ├── init.lua
│ │ │ └── uiloader.lua
│ │ └── utils/
│ │ ├── ByteArray.lua
│ │ ├── ByteArrayVarint.lua
│ │ ├── GameState.lua
│ │ ├── Gettext.lua
│ │ ├── Localize.lua
│ │ ├── Timer.lua
│ │ ├── bit.lua
│ │ └── init.lua
│ ├── cocos2dx/
│ │ ├── ActionEx.lua
│ │ ├── Cocos2d.lua
│ │ ├── Cocos2dConstants.lua
│ │ ├── DrawNodeEx.lua
│ │ ├── Event.lua
│ │ ├── NodeEx.lua
│ │ ├── OpenglConstants.lua
│ │ ├── SceneEx.lua
│ │ ├── SpriteEx.lua
│ │ └── StudioConstants.lua
│ ├── cocos2dx.lua
│ ├── crypto.lua
│ ├── debug.lua
│ ├── deprecated/
│ │ └── deprecated_functions.lua
│ ├── device.lua
│ ├── display.lua
│ ├── filter.lua
│ ├── functions.lua
│ ├── global.lua
│ ├── init.lua
│ ├── json.lua
│ ├── luaj.lua
│ ├── luaoc.lua
│ ├── network.lua
│ ├── platform/
│ │ ├── android.lua
│ │ ├── ios.lua
│ │ └── mac.lua
│ ├── scheduler.lua
│ ├── shortcodes.lua
│ ├── transition.lua
│ └── ui.lua
└── main.lua
================================================
FILE CONTENTS
================================================
================================================
FILE: README.md
================================================
mir9-lua
================
mir9——《热血沙城》,是9秒论坛开源的一个使用Cocos2d-x-2.2.1引擎开发的45度ARPG手游Demo,源代码为c++。mir9-lua是mir9的Lua移植版,使用Quick-Cocos2d-x-3.3 Final引擎开发。由于移植得比较匆忙,代码写得可能比较混乱,请见谅。
已知Bug:
1、怪物在不可见范围时,自动攻击选中怪物会发现怪物选中图片位置不对
2、停止自动攻击后,还会跑去攻击一次
3、A*寻路会有死循环问题,在小地图上寻路有时会有卡顿的现象
界面截图:








资源下载地址:
http://pan.baidu.com/s/1kTqqhin
Win32安装包下载地址:
http://pan.baidu.com/s/1gd5ruaJ
Android安装包下载地址:
http://pan.baidu.com/s/1i3GcL6X
Cocos2d-x2.2.1 C++原版下载地址:
http://pan.baidu.com/s/1jGl8042
Cocos2d-x2.2.5 C++修改版下载地址:
http://pan.baidu.com/s/1bnfHdzL
开发环境:
Quick-Cocos2d-x-3.3 Final
Cocos Code IDE
注意:
在Windows下面运行不能将程序放在中文目录下,否则会播放不了声音,这是引擎的Bug。另资源文件下载完后,请解压缩至项目工程的res目录下。
项目地址:
[https://github.com/zym2014/mir9-lua](https://github.com/zym2014/mir9-lua)
作者Blog:
[http://zym.cnblogs.com](http://zym.cnblogs.com)
[http://blog.csdn.net/zym_123456](http://blog.csdn.net/zym_123456)
================================================
FILE: 发布说明.txt
================================================
mir9-lua
mir9——《热血沙城》,是9秒论坛开源的一个使用Cocos2d-x-2.2.1引擎开发的45度ARPG手游Demo,源代码为c++。mir9-lua是mir9的Lua移植版,使用Quick-Cocos2d-x-3.3 Final引擎开发。由于移植得比较匆忙,代码写得可能比较混乱,请见谅。
已知Bug:
1、怪物在不可见范围时,自动攻击选中怪物会发现怪物选中图片位置不对
2、停止自动攻击后,还会跑去攻击一次
3、A*寻路会有死循环问题,在小地图上寻路有时会有卡顿的现象
资源下载地址:
http://pan.baidu.com/s/1kTqqhin
Win32安装包下载地址:
http://pan.baidu.com/s/1gd5ruaJ
Android安装包下载地址:
http://pan.baidu.com/s/1i3GcL6X
Cocos2d-x2.2.1 C++原版下载地址:
http://pan.baidu.com/s/1jGl8042
Cocos2d-x2.2.5 C++修改版下载地址:
http://pan.baidu.com/s/1bnfHdzL
开发环境:
Quick-Cocos2d-x-3.3 Final
Cocos Code IDE
注意:
在Windows下面运行不能将程序放在中文目录下,否则会播放不了声音,这是引擎的Bug。另资源文件下载完后,请解压缩至项目工程的res目录下。
项目地址:
https://github.com/zym2014/mir9-lua
作者Blog:
http://zym.cnblogs.com
http://blog.csdn.net/zym_123456
================================================
FILE: 源代码/2.2.5/mir9/.buildpath
================================================
================================================
FILE: 源代码/2.2.5/mir9/.cocos-project.json
================================================
{
"has_native": false,
"project_type": "lua"
}
================================================
FILE: 源代码/2.2.5/mir9/.project
================================================
mir9
org.ccdt.cocosproject
org.eclipse.koneki.ldt.nature
================================================
FILE: 源代码/2.2.5/mir9/.settings/org.eclipse.core.resources.prefs
================================================
eclipse.preferences.version=1
encoding/=UTF-8
================================================
FILE: 源代码/2.2.5/mir9/.settings/version.json
================================================
{
"ideVersion": "1.0.1",
"templateVersion": "1.3",
"runtimeVersion": "1.3",
"engineVersion": "cocos2d-x 3.2"
}
================================================
FILE: 源代码/2.2.5/mir9/config.json
================================================
{
"init_cfg": {
"isLandscape": true,
"name": "mir9",
"width": 960,
"height": 640,
"entry": "scripts/main.lua",
"consolePort": 6010,
"forwardConsolePort": 10089,
"forwardUploadPort": 10091
},
"simulator_screen_size": [
{
"title": "iPhone 3Gs (480x320)",
"width": 480,
"height": 320
},
{
"title": "iPhone 4 (960x640)",
"width": 960,
"height": 640
},
{
"title": "iPhone 5 (1136x640)",
"width": 1136,
"height": 640
},
{
"title": "iPad (1024x768)",
"width": 1024,
"height": 768
},
{
"title": "iPad Retina (2048x1536)",
"width": 2048,
"height": 1536
},
{
"title": "Android (800x480)",
"width": 800,
"height": 480
},
{
"title": "Android (854x480)",
"width": 854,
"height": 480
},
{
"title": "Android (1280x720)",
"width": 1280,
"height": 720
},
{
"title": "Android (1920x1080)",
"width": 1920,
"height": 1080
}
]
}
================================================
FILE: 源代码/2.2.5/mir9/proj.android/.classpath
================================================
================================================
FILE: 源代码/2.2.5/mir9/proj.android/.project
================================================
Mir9
com.android.ide.eclipse.adt.ResourceManagerBuilder
com.android.ide.eclipse.adt.PreCompilerBuilder
org.eclipse.jdt.core.javabuilder
com.android.ide.eclipse.adt.ApkBuilder
com.android.ide.eclipse.adt.AndroidNature
org.eclipse.jdt.core.javanature
================================================
FILE: 源代码/2.2.5/mir9/proj.android/.settings/org.eclipse.jdt.core.prefs
================================================
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.source=1.6
================================================
FILE: 源代码/2.2.5/mir9/proj.android/AndroidManifest.xml
================================================
================================================
FILE: 源代码/2.2.5/mir9/proj.android/build_native.bat
================================================
@echo off
set DIR=%~dp0
set APP_ROOT=%DIR%..\
set APP_ANDROID_ROOT=%DIR%
set COCOS2DX_ROOT=%QUICK_COCOS2DX_ROOT%\lib\cocos2d-x
echo - config:
echo ANDROID_NDK_ROOT = %ANDROID_NDK_ROOT%
echo QUICK_COCOS2DX_ROOT = %QUICK_COCOS2DX_ROOT%
echo COCOS2DX_ROOT = %COCOS2DX_ROOT%
echo APP_ROOT = %APP_ROOT%
echo APP_ANDROID_ROOT = %APP_ANDROID_ROOT%
rem if dont use DEBUG, comments out two lines below
set NDK_DEBUG=1
set NDK_BUILD_FLAGS=CPPFLAGS="-DCOCOS2D_DEBUG=1"
echo - cleanup
if exist "%APP_ANDROID_ROOT%bin" rmdir /s /q "%APP_ANDROID_ROOT%bin"
mkdir "%APP_ANDROID_ROOT%bin"
if exist "%APP_ANDROID_ROOT%assets" rmdir /s /q "%APP_ANDROID_ROOT%assets"
mkdir "%APP_ANDROID_ROOT%assets"
echo - copy scripts
mkdir "%APP_ANDROID_ROOT%assets\scripts"
xcopy /s /q "%APP_ROOT%scripts\*.*" "%APP_ANDROID_ROOT%assets\scripts\"
echo - copy resources
mkdir "%APP_ANDROID_ROOT%assets\res"
xcopy /s /q "%APP_ROOT%res\*.*" "%APP_ANDROID_ROOT%assets\res\"
echo Using prebuilt externals
"%ANDROID_NDK_ROOT%\ndk-build" %ANDROID_NDK_BUILD_FLAGS% NDK_DEBUG=%NDK_DEBUG% %NDK_BUILD_FLAGS% -C %APP_ANDROID_ROOT% NDK_MODULE_PATH=%QUICK_COCOS2DX_ROOT%;%COCOS2DX_ROOT%;%COCOS2DX_ROOT%\cocos2dx\platform\third_party\android\prebuilt
================================================
FILE: 源代码/2.2.5/mir9/proj.android/build_native.sh
================================================
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
APP_ROOT="$DIR/.."
APP_ANDROID_ROOT="$DIR"
COCOS2DX_ROOT=$QUICK_COCOS2DX_ROOT/lib/cocos2d-x
echo "- config:"
echo " ANDROID_NDK_ROOT = $ANDROID_NDK_ROOT"
echo " QUICK_COCOS2DX_ROOT = $QUICK_COCOS2DX_ROOT"
echo " COCOS2DX_ROOT = $COCOS2DX_ROOT"
echo " APP_ROOT = $APP_ROOT"
echo " APP_ANDROID_ROOT = $APP_ANDROID_ROOT"
# if dont use DEBUG, comments out two lines below
NDK_DEBUG=1
NDK_BUILD_FLAGS="CPPFLAGS=\"-DCOCOS2D_DEBUG=1\""
echo "- cleanup"
find "$APP_ANDROID_ROOT" -type d | xargs chmod 755 $1
if [ -d "$APP_ANDROID_ROOT"/bin ]; then
rm -rf "$APP_ANDROID_ROOT"/bin/*.apk
fi
mkdir -p "$APP_ANDROID_ROOT"/bin
chmod 755 "$APP_ANDROID_ROOT"/bin
if [ -d "$APP_ANDROID_ROOT"/assets ]; then
rm -rf "$APP_ANDROID_ROOT"/assets/*
fi
mkdir -p "$APP_ANDROID_ROOT"/assets
chmod 755 "$APP_ANDROID_ROOT"/assets
echo "- copy scripts"
cp -rf "$APP_ROOT"/scripts "$APP_ANDROID_ROOT"/assets/
echo "- copy resources"
cp -rf "$APP_ROOT"/res "$APP_ANDROID_ROOT"/assets/
# build
echo "Using prebuilt externals"
"$ANDROID_NDK_ROOT"/ndk-build $ANDROID_NDK_BUILD_FLAGS NDK_DEBUG=$NDK_DEBUG $NDK_BUILD_FLAGS -C "$APP_ANDROID_ROOT" $* \
"NDK_MODULE_PATH=${QUICK_COCOS2DX_ROOT}:${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt"
================================================
FILE: 源代码/2.2.5/mir9/proj.android/clean.bat
================================================
@echo off
set DIR=%~dp0
rmdir /s/q %DIR%obj
rmdir /s/q %DIR%libs\armeabi
rmdir /s/q %DIR%assets
================================================
FILE: 源代码/2.2.5/mir9/proj.android/clean.sh
================================================
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
rm -fr $DIR/obj/*
rm -fr $DIR/libs/armeabi/*.so
rm -fr $DIR/assets/*
================================================
FILE: 源代码/2.2.5/mir9/proj.android/gen/com/zym/mir9/BuildConfig.java
================================================
/** Automatically generated file. DO NOT MODIFY */
package com.zym.mir9;
public final class BuildConfig {
public final static boolean DEBUG = true;
}
================================================
FILE: 源代码/2.2.5/mir9/proj.android/gen/com/zym/mir9/R.java
================================================
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package com.zym.mir9;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class string {
public static final int app_name=0x7f030000;
}
}
================================================
FILE: 源代码/2.2.5/mir9/proj.android/jni/Android.mk
================================================
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := game_shared
LOCAL_MODULE_FILENAME := libgame
LOCAL_SRC_FILES := hellocpp/main.cpp \
../../sources/AppDelegate.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../sources
LOCAL_CFLAGS += -D__GXX_EXPERIMENTAL_CXX0X__ -std=gnu++11 -Wno-psabi -DCC_LUA_ENGINE_ENABLED=1 $(ANDROID_COCOS2D_BUILD_FLAGS)
LOCAL_WHOLE_STATIC_LIBRARIES := quickcocos2dx
include $(BUILD_SHARED_LIBRARY)
$(call import-module,lib/proj.android)
================================================
FILE: 源代码/2.2.5/mir9/proj.android/jni/Application.mk
================================================
APP_STL := gnustl_static
APP_CPPFLAGS := -D__GXX_EXPERIMENTAL_CXX0X__ -std=gnu++11 -frtti -Wno-error=format-security -fsigned-char -Os $(CPPFLAGS)
APP_ABI := armeabi
================================================
FILE: 源代码/2.2.5/mir9/proj.android/jni/hellocpp/main.cpp
================================================
#include "cocos2d.h"
#include "AppDelegate.h"
#include "platform/android/jni/JniHelper.h"
#include
#include
#define LOG_TAG "main"
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
using namespace cocos2d;
extern "C"
{
jint JNI_OnLoad(JavaVM *vm, void *reserved)
{
JniHelper::setJavaVM(vm);
return JNI_VERSION_1_4;
}
void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h)
{
if (!CCDirector::sharedDirector()->getOpenGLView())
{
CCEGLView *view = CCEGLView::sharedOpenGLView();
view->setFrameSize(w, h);
AppDelegate *pAppDelegate = new AppDelegate();
CCApplication::sharedApplication()->run();
}
else
{
ccGLInvalidateStateCache();
CCShaderCache::sharedShaderCache()->reloadDefaultShaders();
ccDrawInit();
CCTextureCache::reloadAllTextures();
CCNotificationCenter::sharedNotificationCenter()->postNotification(EVENT_COME_TO_FOREGROUND, NULL);
CCDirector::sharedDirector()->setGLDefaultValues();
}
}
}
================================================
FILE: 源代码/2.2.5/mir9/proj.android/jni/list.sh
================================================
#!/bin/bash
append_str=' \'
list_alldir()
{
for file in $1/*
do
if [ -f $file ]; then
echo $file$append_str | grep .cpp
fi
if [ -d $file ]; then
list_alldir $file
fi
done
}
if [ $# -gt 0 ]; then
list_alldir "$1"
else
list_alldir "."
fi
================================================
FILE: 源代码/2.2.5/mir9/proj.android/project.properties
================================================
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=Google Inc.:Google APIs (x86 System Image):19
android.library=false
android.library.reference.1=../../../lib/cocos2d-x/cocos2dx/platform/android/java
================================================
FILE: 源代码/2.2.5/mir9/proj.android/res/values/strings.xml
================================================
热血沙城
================================================
FILE: 源代码/2.2.5/mir9/proj.android/src/com/zym/mir9/Mir9.java
================================================
/****************************************************************************
Copyright (c) 2010-2012 cocos2d-x.org
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 com.zym.mir9;
import org.cocos2dx.lib.Cocos2dxActivity;
import android.os.Bundle;
public class Mir9 extends Cocos2dxActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
static {
System.loadLibrary("game");
}
}
================================================
FILE: 源代码/2.2.5/mir9/proj.ios/AppController.h
================================================
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
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.
****************************************************************************/
@class RootViewController;
#define kOpenGameImmediately 0
#define kOpenGameWaitForAlert 1
#define kOpenGameExit 2
@interface AppController : NSObject {
UIWindow *window;
@public RootViewController *viewController;
int openGame;
int appUpdateCheckResult;
}
@end
================================================
FILE: 源代码/2.2.5/mir9/proj.ios/AppController.mm
================================================
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
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
#import
#import "AppController.h"
#import "cocos2d.h"
#import "EAGLView.h"
#import "AppDelegate.h"
#import "RootViewController.h"
@implementation AppController
#pragma mark -
#pragma mark Application lifecycle
// cocos2d application instance
static AppDelegate s_sharedApplication;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// 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]];
EAGLView *__glView = [EAGLView viewWithFrame: [window bounds]
pixelFormat: kEAGLColorFormatRGBA8
depthFormat: GL_DEPTH24_STENCIL8_OES
preserveBackbuffer: NO
sharegroup: nil
multiSampling: NO
numberOfSamples: 0];
// Enable multi-touches
// [__glView setMultipleTouchEnabled:YES];
// Use RootViewController manage EAGLView
viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
viewController.wantsFullScreenLayout = YES;
viewController.view = __glView;
// Set RootViewController to window
if ([[UIDevice currentDevice].systemVersion floatValue] < 6.0)
{
[window addSubview: viewController.view];
}
[window setRootViewController:viewController];
[window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden: YES];
cocos2d::CCApplication::sharedApplication()->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.
*/
cocos2d::CCDirector::sharedDirector()->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.
*/
cocos2d::CCDirector::sharedDirector()->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::CCApplication::sharedApplication()->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.
*/
NSError *err;
[[AVAudioSession sharedInstance] setActive:true error:&err];
cocos2d::CCApplication::sharedApplication()->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.
*/
}
- (void)dealloc {
[super dealloc];
}
@end
================================================
FILE: 源代码/2.2.5/mir9/proj.ios/Resources/Info.plist
================================================
CFBundleDisplayName
${PRODUCT_NAME}
CFBundleExecutable
${EXECUTABLE_NAME}
CFBundleIconFile
CFBundleIconFiles
Icon.png
Icon@2x.png
Icon-72.png
CFBundleIdentifier
com.zym.${PRODUCT_NAME:rfc1034identifier}
CFBundleInfoDictionaryVersion
6.0
CFBundleName
${PRODUCT_NAME}
CFBundlePackageType
APPL
CFBundleShortVersionString
1.0
CFBundleSignature
????
CFBundleVersion
1.0
LSRequiresIPhoneOS
UIPrerenderedIcon
UIRequiredDeviceCapabilities
accelerometer
opengles-1
UIStatusBarHidden
UISupportedInterfaceOrientations
UIInterfaceOrientationPortrait
UIViewControllerBasedStatusBarAppearance
================================================
FILE: 源代码/2.2.5/mir9/proj.ios/RootViewController.h
================================================
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2010 Ricardo Quesada
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
#import
@interface RootViewController : UIViewController
- (BOOL) prefersStatusBarHidden;
@end
================================================
FILE: 源代码/2.2.5/mir9/proj.ios/RootViewController.mm
================================================
/****************************************************************************
Copyright (c) 2010-2011 cocos2d-x.org
Copyright (c) 2010 Ricardo Quesada
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"
@implementation RootViewController
// GKLeaderboardViewControllerのDelegate
-(void)leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)viewController
{
[self dismissViewControllerAnimated:YES completion:nil];
}
// GKAchievementViewControllerのDelegate
-(void)achievementViewControllerDidFinish:(GKAchievementViewController *)viewController
{
[self dismissViewControllerAnimated:YES completion:nil];
}
// Override to allow orientations other than the default portrait orientation.
// This method is deprecated on ios6
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}
// For ios6.0 and higher, use supportedInterfaceOrientations & shouldAutorotate instead
- (NSUInteger) supportedInterfaceOrientations
{
#ifdef __IPHONE_6_0
return UIInterfaceOrientationMaskPortrait;
#endif
}
- (BOOL) shouldAutorotate {
return YES;
}
//fix not hide status on ios7
- (BOOL) prefersStatusBarHidden {
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.
}
- (void)viewDidUnload {
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
@end
================================================
FILE: 源代码/2.2.5/mir9/proj.ios/main.m
================================================
#import
int main(int argc, char *argv[]) {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
int retVal = UIApplicationMain(argc, argv, nil, @"AppController");
[pool release];
return retVal;
}
================================================
FILE: 源代码/2.2.5/mir9/proj.ios/mir9.xcodeproj/project.pbxproj
================================================
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
2EDD276C191B6258004F9539 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2EDD276A191B6258004F9539 /* AppDelegate.cpp */; };
2EDD2787191B62CA004F9539 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 2EDD2780191B62CA004F9539 /* Default-568h@2x.png */; };
2EDD2788191B62CA004F9539 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 2EDD2781191B62CA004F9539 /* Default.png */; };
2EDD2789191B62CA004F9539 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 2EDD2782191B62CA004F9539 /* Default@2x.png */; };
2EDD278A191B62CA004F9539 /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = 2EDD2783191B62CA004F9539 /* Icon-72.png */; };
2EDD278B191B62CA004F9539 /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 2EDD2784191B62CA004F9539 /* Icon.png */; };
2EDD278C191B62CA004F9539 /* Icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 2EDD2785191B62CA004F9539 /* Icon@2x.png */; };
2EDD2790191B62D6004F9539 /* res in Resources */ = {isa = PBXBuildFile; fileRef = 2EDD278E191B62D6004F9539 /* res */; };
2EDD2791191B62D6004F9539 /* scripts in Resources */ = {isa = PBXBuildFile; fileRef = 2EDD278F191B62D6004F9539 /* scripts */; };
2EDD2799191B639C004F9539 /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2EDD2794191B639C004F9539 /* AppController.mm */; };
2EDD279A191B639C004F9539 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 2EDD2795191B639C004F9539 /* main.m */; };
2EDD279B191B639C004F9539 /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2EDD2798191B639C004F9539 /* RootViewController.mm */; };
F4323CF716D3298E0072B773 /* libquickcocos2dx.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F48F590816D21F8C000651BE /* libquickcocos2dx.a */; };
F452BFC51687EEF900DC5BCC /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F452BFC41687EEF900DC5BCC /* CoreText.framework */; };
F452BFD01687F0F200DC5BCC /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F452BFCF1687F0F200DC5BCC /* UIKit.framework */; };
F456ECC615EE018E00FCF3E2 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F456ECC515EE018E00FCF3E2 /* QuartzCore.framework */; };
F456ECC815EE018E00FCF3E2 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F456ECC715EE018E00FCF3E2 /* OpenGLES.framework */; };
F456ECCA15EE018E00FCF3E2 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F456ECC915EE018E00FCF3E2 /* OpenAL.framework */; };
F456ECCC15EE018E00FCF3E2 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F456ECCB15EE018E00FCF3E2 /* AudioToolbox.framework */; };
F456ECCE15EE018E00FCF3E2 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F456ECCD15EE018E00FCF3E2 /* AVFoundation.framework */; };
F456ECD215EE018E00FCF3E2 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F456ECD115EE018E00FCF3E2 /* Foundation.framework */; };
F456ECD415EE018E00FCF3E2 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F456ECD315EE018E00FCF3E2 /* CoreGraphics.framework */; };
F456F0F915EE0CDB00FCF3E2 /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F456F0F815EE0CDB00FCF3E2 /* CFNetwork.framework */; };
F456F0FD15EE0CF600FCF3E2 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F456F0FC15EE0CF600FCF3E2 /* SystemConfiguration.framework */; };
F456F10515EE0D2D00FCF3E2 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F456F10415EE0D2D00FCF3E2 /* MobileCoreServices.framework */; };
F4949C791699553B00DB561E /* AddressBook.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F4949C781699553B00DB561E /* AddressBook.framework */; };
F4949C7B1699554600DB561E /* CoreTelephony.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F4949C7A1699554600DB561E /* CoreTelephony.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
F4F40D1B16573CE0007937AD /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F4F40D1A16573CE0007937AD /* StoreKit.framework */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
F48F590716D21F8C000651BE /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = F4499C7116C7CDE20059FF37 /* quickcocos2dx.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = F45A2B9D166B07B600760194;
remoteInfo = quickcocos2dx;
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
2EDD276A191B6258004F9539 /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppDelegate.cpp; sourceTree = ""; };
2EDD276B191B6258004F9539 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
2EDD2780191B62CA004F9539 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; };
2EDD2781191B62CA004F9539 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; };
2EDD2782191B62CA004F9539 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; };
2EDD2783191B62CA004F9539 /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-72.png"; sourceTree = ""; };
2EDD2784191B62CA004F9539 /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon.png; sourceTree = ""; };
2EDD2785191B62CA004F9539 /* Icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon@2x.png"; sourceTree = ""; };
2EDD2786191B62CA004F9539 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
2EDD278E191B62D6004F9539 /* res */ = {isa = PBXFileReference; lastKnownFileType = folder; name = res; path = ../../res; sourceTree = ""; };
2EDD278F191B62D6004F9539 /* scripts */ = {isa = PBXFileReference; lastKnownFileType = folder; name = scripts; path = ../../scripts; sourceTree = ""; };
2EDD2793191B639C004F9539 /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = ""; };
2EDD2794191B639C004F9539 /* AppController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppController.mm; sourceTree = ""; };
2EDD2795191B639C004F9539 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
2EDD2796191B639C004F9539 /* Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = ""; };
2EDD2797191B639C004F9539 /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; };
2EDD2798191B639C004F9539 /* RootViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RootViewController.mm; sourceTree = ""; };
F4499C7116C7CDE20059FF37 /* quickcocos2dx.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = quickcocos2dx.xcodeproj; path = lib/proj.ios/quickcocos2dx.xcodeproj; sourceTree = QUICK_COCOS2DX_ROOT; };
F452BFC41687EEF900DC5BCC /* CoreText.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreText.framework; path = System/Library/Frameworks/CoreText.framework; sourceTree = SDKROOT; };
F452BFCF1687F0F200DC5BCC /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
F456ECC115EE018E00FCF3E2 /* mir9.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = mir9.app; sourceTree = BUILT_PRODUCTS_DIR; };
F456ECC515EE018E00FCF3E2 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
F456ECC715EE018E00FCF3E2 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; };
F456ECC915EE018E00FCF3E2 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; };
F456ECCB15EE018E00FCF3E2 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
F456ECCD15EE018E00FCF3E2 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
F456ECD115EE018E00FCF3E2 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
F456ECD315EE018E00FCF3E2 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
F456F0F815EE0CDB00FCF3E2 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; };
F456F0FA15EE0CEB00FCF3E2 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; };
F456F0FC15EE0CF600FCF3E2 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
F456F10415EE0D2D00FCF3E2 /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; };
F456F10615EE0D3500FCF3E2 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
F4949C781699553B00DB561E /* AddressBook.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AddressBook.framework; path = System/Library/Frameworks/AddressBook.framework; sourceTree = SDKROOT; };
F4949C7A1699554600DB561E /* CoreTelephony.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreTelephony.framework; path = System/Library/Frameworks/CoreTelephony.framework; sourceTree = SDKROOT; };
F4F40D1A16573CE0007937AD /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
F456ECBE15EE018E00FCF3E2 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
F4323CF716D3298E0072B773 /* libquickcocos2dx.a in Frameworks */,
F452BFD01687F0F200DC5BCC /* UIKit.framework in Frameworks */,
F456F0FD15EE0CF600FCF3E2 /* SystemConfiguration.framework in Frameworks */,
F456ECC615EE018E00FCF3E2 /* QuartzCore.framework in Frameworks */,
F4949C7B1699554600DB561E /* CoreTelephony.framework in Frameworks */,
F456ECD415EE018E00FCF3E2 /* CoreGraphics.framework in Frameworks */,
F4949C791699553B00DB561E /* AddressBook.framework in Frameworks */,
F456ECC815EE018E00FCF3E2 /* OpenGLES.framework in Frameworks */,
F452BFC51687EEF900DC5BCC /* CoreText.framework in Frameworks */,
F4F40D1B16573CE0007937AD /* StoreKit.framework in Frameworks */,
F456F10515EE0D2D00FCF3E2 /* MobileCoreServices.framework in Frameworks */,
F456F0F915EE0CDB00FCF3E2 /* CFNetwork.framework in Frameworks */,
F456ECCA15EE018E00FCF3E2 /* OpenAL.framework in Frameworks */,
F456ECCC15EE018E00FCF3E2 /* AudioToolbox.framework in Frameworks */,
F456ECCE15EE018E00FCF3E2 /* AVFoundation.framework in Frameworks */,
F456ECD215EE018E00FCF3E2 /* Foundation.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
2EDD2769191B6258004F9539 /* sources */ = {
isa = PBXGroup;
children = (
2EDD276A191B6258004F9539 /* AppDelegate.cpp */,
2EDD276B191B6258004F9539 /* AppDelegate.h */,
);
name = sources;
path = ../sources;
sourceTree = "";
};
2EDD277F191B62CA004F9539 /* Resources */ = {
isa = PBXGroup;
children = (
2EDD278E191B62D6004F9539 /* res */,
2EDD278F191B62D6004F9539 /* scripts */,
2EDD279C191B641B004F9539 /* ios */,
);
path = Resources;
sourceTree = "";
};
2EDD2792191B6392004F9539 /* ios */ = {
isa = PBXGroup;
children = (
2EDD2793191B639C004F9539 /* AppController.h */,
2EDD2794191B639C004F9539 /* AppController.mm */,
2EDD2795191B639C004F9539 /* main.m */,
2EDD2796191B639C004F9539 /* Prefix.pch */,
2EDD2797191B639C004F9539 /* RootViewController.h */,
2EDD2798191B639C004F9539 /* RootViewController.mm */,
);
name = ios;
sourceTree = "";
};
2EDD279C191B641B004F9539 /* ios */ = {
isa = PBXGroup;
children = (
2EDD2780191B62CA004F9539 /* Default-568h@2x.png */,
2EDD2781191B62CA004F9539 /* Default.png */,
2EDD2782191B62CA004F9539 /* Default@2x.png */,
2EDD2783191B62CA004F9539 /* Icon-72.png */,
2EDD2784191B62CA004F9539 /* Icon.png */,
2EDD2785191B62CA004F9539 /* Icon@2x.png */,
2EDD2786191B62CA004F9539 /* Info.plist */,
);
name = ios;
sourceTree = "";
};
F456ECB615EE018E00FCF3E2 = {
isa = PBXGroup;
children = (
F4499C7116C7CDE20059FF37 /* quickcocos2dx.xcodeproj */,
2EDD2792191B6392004F9539 /* ios */,
2EDD2769191B6258004F9539 /* sources */,
2EDD277F191B62CA004F9539 /* Resources */,
F456ECC415EE018E00FCF3E2 /* Frameworks */,
F456ECC215EE018E00FCF3E2 /* Products */,
);
sourceTree = "";
};
F456ECC215EE018E00FCF3E2 /* Products */ = {
isa = PBXGroup;
children = (
F456ECC115EE018E00FCF3E2 /* mir9.app */,
);
name = Products;
sourceTree = "";
};
F456ECC415EE018E00FCF3E2 /* Frameworks */ = {
isa = PBXGroup;
children = (
F4949C781699553B00DB561E /* AddressBook.framework */,
F456ECCB15EE018E00FCF3E2 /* AudioToolbox.framework */,
F456ECCD15EE018E00FCF3E2 /* AVFoundation.framework */,
F456F0F815EE0CDB00FCF3E2 /* CFNetwork.framework */,
F456F0FA15EE0CEB00FCF3E2 /* CoreFoundation.framework */,
F456ECD315EE018E00FCF3E2 /* CoreGraphics.framework */,
F4949C7A1699554600DB561E /* CoreTelephony.framework */,
F452BFC41687EEF900DC5BCC /* CoreText.framework */,
F456ECD115EE018E00FCF3E2 /* Foundation.framework */,
F456F10415EE0D2D00FCF3E2 /* MobileCoreServices.framework */,
F456ECC915EE018E00FCF3E2 /* OpenAL.framework */,
F456ECC715EE018E00FCF3E2 /* OpenGLES.framework */,
F456ECC515EE018E00FCF3E2 /* QuartzCore.framework */,
F456F10615EE0D3500FCF3E2 /* Security.framework */,
F4F40D1A16573CE0007937AD /* StoreKit.framework */,
F456F0FC15EE0CF600FCF3E2 /* SystemConfiguration.framework */,
F452BFCF1687F0F200DC5BCC /* UIKit.framework */,
);
name = Frameworks;
sourceTree = "";
};
F48F590416D21F8C000651BE /* Products */ = {
isa = PBXGroup;
children = (
F48F590816D21F8C000651BE /* libquickcocos2dx.a */,
);
name = Products;
sourceTree = "";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
F456ECC015EE018E00FCF3E2 /* mir9 */ = {
isa = PBXNativeTarget;
buildConfigurationList = F456EFBD15EE019300FCF3E2 /* Build configuration list for PBXNativeTarget "mir9" */;
buildPhases = (
F456ECBD15EE018E00FCF3E2 /* Sources */,
F456ECBE15EE018E00FCF3E2 /* Frameworks */,
F456ECBF15EE018E00FCF3E2 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = mir9;
productName = mir9;
productReference = F456ECC115EE018E00FCF3E2 /* mir9.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
F456ECB815EE018E00FCF3E2 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0440;
};
buildConfigurationList = F456ECBB15EE018E00FCF3E2 /* Build configuration list for PBXProject "mir9" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
"zh-Hans",
);
mainGroup = F456ECB615EE018E00FCF3E2;
productRefGroup = F456ECC215EE018E00FCF3E2 /* Products */;
projectDirPath = "";
projectReferences = (
{
ProductGroup = F48F590416D21F8C000651BE /* Products */;
ProjectRef = F4499C7116C7CDE20059FF37 /* quickcocos2dx.xcodeproj */;
},
);
projectRoot = "";
targets = (
F456ECC015EE018E00FCF3E2 /* mir9 */,
);
};
/* End PBXProject section */
/* Begin PBXReferenceProxy section */
F48F590816D21F8C000651BE /* libquickcocos2dx.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libquickcocos2dx.a;
remoteRef = F48F590716D21F8C000651BE /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */
/* Begin PBXResourcesBuildPhase section */
F456ECBF15EE018E00FCF3E2 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
2EDD2789191B62CA004F9539 /* Default@2x.png in Resources */,
2EDD278C191B62CA004F9539 /* Icon@2x.png in Resources */,
2EDD278A191B62CA004F9539 /* Icon-72.png in Resources */,
2EDD278B191B62CA004F9539 /* Icon.png in Resources */,
2EDD2790191B62D6004F9539 /* res in Resources */,
2EDD2787191B62CA004F9539 /* Default-568h@2x.png in Resources */,
2EDD2788191B62CA004F9539 /* Default.png in Resources */,
2EDD2791191B62D6004F9539 /* scripts in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
F456ECBD15EE018E00FCF3E2 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
2EDD279B191B639C004F9539 /* RootViewController.mm in Sources */,
2EDD276C191B6258004F9539 /* AppDelegate.cpp in Sources */,
2EDD279A191B639C004F9539 /* main.m in Sources */,
2EDD2799191B639C004F9539 /* AppController.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
F456EFBB15EE019300FCF3E2 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = armv7;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
DEBUG,
"COCOS2D_DEBUG=1",
USE_FILE32API,
TARGET_OS_IPHONE,
"CC_LUA_ENGINE_ENABLED=1",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx/include\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx/platform\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx/platform/ios\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx/platform/third_party/ios\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx/kazmath/include\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/CocosDenshion/include\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/CocosDenshion/ios\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/extensions\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/extensions/GUI/CCControlExtension\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/extensions/GUI/CCEditBox\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/scripting/lua/cocos2dx_support\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/scripting/lua/tolua\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/scripting/lua/luajit/include\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2dx_extensions_luabinding\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2dx_extra/extra\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2dx_extra/extra/luabinding\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/lua_extensions\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/lua_extensions/cjson\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/lua_extensions/zlib\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/third_party/chipmunk/include\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/third_party/chipmunk/luabinding\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/third_party/CSArmature\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/third_party\"",
);
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
SDKROOT = iphoneos;
VALID_ARCHS = armv7;
};
name = Debug;
};
F456EFBC15EE019300FCF3E2 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = armv7;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_PREPROCESSOR_DEFINITIONS = (
NDEBUG,
USE_FILE32API,
TARGET_OS_IPHONE,
"CC_LUA_ENGINE_ENABLED=1",
);
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = (
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx/include\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx/platform\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx/platform/ios\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx/platform/third_party/ios\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx/kazmath/include\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/CocosDenshion/include\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/CocosDenshion/ios\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/extensions\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/extensions/GUI/CCControlExtension\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/extensions/GUI/CCEditBox\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/scripting/lua/cocos2dx_support\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/scripting/lua/tolua\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/scripting/lua/luajit/include\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2dx_extensions_luabinding\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2dx_extra/extra\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2dx_extra/extra/luabinding\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/lua_extensions\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/lua_extensions/cjson\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/lua_extensions/zlib\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/third_party/chipmunk/include\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/third_party/chipmunk/luabinding\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/third_party/CSArmature\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/third_party\"",
);
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
SDKROOT = iphoneos;
VALID_ARCHS = armv7;
};
name = Release;
};
F456EFBE15EE019300FCF3E2 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = armv7;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Prefix.pch;
GCC_PREPROCESSOR_DEFINITIONS = (
DEBUG,
"COCOS2D_DEBUG=1",
USE_FILE32API,
CC_TARGET_OS_IPHONE,
"CC_LUA_ENGINE_ENABLED=1",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
"GCC_THUMB_SUPPORT[arch=armv6]" = "";
HEADER_SEARCH_PATHS = (
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx/include\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx/platform\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx/platform/ios\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx/platform/third_party/ios\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx/kazmath/include\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/CocosDenshion/include\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/CocosDenshion/ios\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/extensions\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/extensions/GUI/CCControlExtension\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/extensions/GUI/CCEditBox\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/scripting/lua/cocos2dx_support\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/scripting/lua/tolua\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/scripting/lua/luajit/include\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2dx_extensions_luabinding\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2dx_extra/extra\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2dx_extra/extra/luabinding\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/lua_extensions\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/lua_extensions/cjson\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/lua_extensions/zlib\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/third_party/chipmunk/include\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/third_party/chipmunk/luabinding\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/third_party/CSArmature\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/third_party\"",
);
INFOPLIST_FILE = "$(SRCROOT)/Resources/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
LIBRARY_SEARCH_PATHS = (
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx/platform/third_party/ios/libraries\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/scripting/lua/luajit/ios\"",
);
OTHER_LDFLAGS = (
"-lxml2",
"-lz",
"-ObjC",
);
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
TARGETED_DEVICE_FAMILY = "1,2";
VALID_ARCHS = armv7;
WRAPPER_EXTENSION = app;
};
name = Debug;
};
F456EFBF15EE019300FCF3E2 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = armv7;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_INLINES_ARE_PRIVATE_EXTERN = NO;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Prefix.pch;
GCC_PREPROCESSOR_DEFINITIONS = (
NDEBUG,
USE_FILE32API,
CC_TARGET_OS_IPHONE,
"CC_LUA_ENGINE_ENABLED=1",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
"GCC_THUMB_SUPPORT[arch=armv6]" = "";
HEADER_SEARCH_PATHS = (
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx/include\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx/platform\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx/platform/ios\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx/platform/third_party/ios\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx/kazmath/include\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/CocosDenshion/include\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/CocosDenshion/ios\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/extensions\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/extensions/GUI/CCControlExtension\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/extensions/GUI/CCEditBox\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/scripting/lua/cocos2dx_support\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/scripting/lua/tolua\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/scripting/lua/luajit/include\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2dx_extensions_luabinding\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2dx_extra/extra\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2dx_extra/extra/luabinding\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/lua_extensions\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/lua_extensions/cjson\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/lua_extensions/zlib\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/third_party/chipmunk/include\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/third_party/chipmunk/luabinding\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/third_party/CSArmature\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/third_party\"",
);
INFOPLIST_FILE = "$(SRCROOT)/Resources/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
LIBRARY_SEARCH_PATHS = (
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx/platform/third_party/ios/libraries\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/scripting/lua/luajit/ios\"",
);
OTHER_LDFLAGS = (
"-lxml2",
"-lz",
"-ObjC",
);
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VALID_ARCHS = armv7;
WRAPPER_EXTENSION = app;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
F456ECBB15EE018E00FCF3E2 /* Build configuration list for PBXProject "mir9" */ = {
isa = XCConfigurationList;
buildConfigurations = (
F456EFBB15EE019300FCF3E2 /* Debug */,
F456EFBC15EE019300FCF3E2 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
F456EFBD15EE019300FCF3E2 /* Build configuration list for PBXNativeTarget "mir9" */ = {
isa = XCConfigurationList;
buildConfigurations = (
F456EFBE15EE019300FCF3E2 /* Debug */,
F456EFBF15EE019300FCF3E2 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = F456ECB815EE018E00FCF3E2 /* Project object */;
}
================================================
FILE: 源代码/2.2.5/mir9/proj.mac/AppController.h
================================================
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
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 "EAGLView.h"
#include
#include "ProjectConfig/SimulatorConfig.h"
#include "AppDelegate.h"
@interface AppController : NSObject
{
NSWindow *window;
EAGLView *glView;
NSMenu *menu;
BOOL isAlwaysOnTop;
AppDelegate *app;
ProjectConfig projectConfig;
}
@property (nonatomic, assign) IBOutlet NSMenu* menu;
- (IBAction) onFileRelaunch:(id)sender;
- (IBAction) onScreenPortait:(id)sender;
- (IBAction) onScreenLandscape:(id)sender;
- (IBAction) onScreenZoomOut:(id)sender;
- (IBAction) onWindowAlwaysOnTop:(id)sender;
@end
================================================
FILE: 源代码/2.2.5/mir9/proj.mac/AppController.mm
================================================
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
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"
#include
#include
#include
#include
#include
#include "AppDelegate.h"
#include "CCDirector.h"
#include "SimpleAudioEngine.h"
#include "platform/CCFileUtils.h"
#include "native/CCNative.h"
using namespace std;
using namespace cocos2d;
using namespace cocos2d::extra;
@implementation AppController
@synthesize menu;
-(void) dealloc
{
CCDirector::sharedDirector()->end();
[super dealloc];
}
#pragma mark -
#pragma delegates
- (void) applicationDidFinishLaunching:(NSNotification *)aNotification
{
isAlwaysOnTop = NO;
[self updateProjectConfigFromCommandLineArgs:&projectConfig];
[self createWindowAndGLView];
[self startup];
[self initUI];
[self updateUI];
[window orderFrontRegardless];
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
}
- (BOOL) applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)theApplication
{
return YES;
}
- (BOOL) applicationShouldHandleReopen:(NSApplication *)sender hasVisibleWindows:(BOOL)flag
{
return NO;
}
- (void) windowWillClose:(NSNotification *)notification
{
CCDirector::sharedDirector()->end();
[[NSApplication sharedApplication] terminate:self];
}
#pragma mark -
#pragma mark functions
- (void) createWindowAndGLView
{
const CCSize frameSize = projectConfig.getFrameSize();
float left = 10;
float bottom = NSHeight([[NSScreen mainScreen] visibleFrame]) - frameSize.height;
bottom -= [[[NSApplication sharedApplication] menu] menuBarHeight] + 10;
NSDictionary *state = [[NSUserDefaults standardUserDefaults] objectForKey:@"last-state"];
if (state)
{
NSNumber *x = [state objectForKey:@"x"];
NSNumber *y = [state objectForKey:@"y"];
if (x && y)
{
projectConfig.setWindowOffset(CCPoint([x floatValue], [y floatValue]));
}
NSNumber *scale = [state objectForKey:@"scale"];
if (scale)
{
projectConfig.setFrameScale([scale floatValue]);
}
}
// create the window
// note that using NSResizableWindowMask causes the window to be a little
// smaller and therefore ipad graphics are not loaded
NSRect rect = NSMakeRect(left, bottom, frameSize.width, frameSize.height);
NSInteger mask = NSClosableWindowMask | NSTitledWindowMask | NSMiniaturizableWindowMask;
window = [[NSWindow alloc] initWithContentRect:rect
styleMask:mask
backing:NSBackingStoreBuffered
defer:YES];
window.delegate = self;
// allocate our GL view
// (isn't there already a shared EAGLView?)
glView = [[EAGLView alloc] initWithFrame:rect];
// set window parameters
[window setContentView:glView];
[window setTitle:@"mir9"];
[window center];
if (projectConfig.getProjectDir().length())
{
[self setZoom:projectConfig.getFrameScale()];
CCPoint pos = projectConfig.getWindowOffset();
if (pos.x != 0 && pos.y != 0)
{
[window setFrameOrigin:NSMakePoint(pos.x, pos.y)];
}
}
[window becomeFirstResponder];
[window makeKeyAndOrderFront:self];
[window setAcceptsMouseMovedEvents:NO];
}
- (void) startup
{
const string projectDir = projectConfig.getProjectDir();
if (projectDir.length())
{
CCFileUtils::sharedFileUtils()->setSearchRootPath(projectDir.c_str());
}
const string writablePath = projectConfig.getWritableRealPath();
if (writablePath.length())
{
CCFileUtils::sharedFileUtils()->setWritablePath(writablePath.c_str());
}
app = new AppDelegate();
app->setProjectConfig(projectConfig);
app->run();
}
- (void) initUI
{
NSMenu *submenu = [[[window menu] itemWithTitle:@"Screen"] submenu];
SimulatorConfig *config = SimulatorConfig::sharedDefaults();
int current = config->checkScreenSize(projectConfig.getFrameSize());
for (int i = config->getScreenSizeCount() - 1; i >= 0; --i)
{
SimulatorScreenSize size = config->getScreenSize(i);
NSMenuItem *item = [[[NSMenuItem alloc] initWithTitle:[NSString stringWithCString:size.title.c_str() encoding:NSUTF8StringEncoding]
action:@selector(onScreenChangeFrameSize:)
keyEquivalent:@""] autorelease];
[item setTag:i];
if (i == current)
{
[item setState:NSOnState];
}
[submenu insertItem:item atIndex:0];
}
}
- (void) updateUI
{
NSMenu *menuScreen = [[[window menu] itemWithTitle:@"Screen"] submenu];
NSMenuItem *itemPortait = [menuScreen itemWithTitle:@"Portait"];
NSMenuItem *itemLandscape = [menuScreen itemWithTitle:@"Landscape"];
if (projectConfig.isLandscapeFrame())
{
[itemPortait setState:NSOffState];
[itemLandscape setState:NSOnState];
}
else
{
[itemPortait setState:NSOnState];
[itemLandscape setState:NSOffState];
}
int scale = projectConfig.getFrameScale() * 100;
NSMenuItem *itemZoom100 = [menuScreen itemWithTitle:@"Actual (100%)"];
NSMenuItem *itemZoom75 = [menuScreen itemWithTitle:@"Zoom Out (75%)"];
NSMenuItem *itemZoom50 = [menuScreen itemWithTitle:@"Zoom Out (50%)"];
NSMenuItem *itemZoom25 = [menuScreen itemWithTitle:@"Zoom Out (25%)"];
[itemZoom100 setState:NSOffState];
[itemZoom75 setState:NSOffState];
[itemZoom50 setState:NSOffState];
[itemZoom25 setState:NSOffState];
if (scale == 100)
{
[itemZoom100 setState:NSOnState];
}
else if (scale == 75)
{
[itemZoom75 setState:NSOnState];
}
else if (scale == 50)
{
[itemZoom50 setState:NSOnState];
}
else if (scale == 25)
{
[itemZoom25 setState:NSOnState];
}
[window setTitle:[NSString stringWithFormat:@"mir9 (%0.0f%%)", projectConfig.getFrameScale() * 100]];
}
- (NSMutableArray*) makeCommandLineArgsFromProjectConfig
{
return [self makeCommandLineArgsFromProjectConfig:kProjectConfigAll];
}
- (NSMutableArray*) makeCommandLineArgsFromProjectConfig:(unsigned int)mask
{
projectConfig.setWindowOffset(CCPoint(window.frame.origin.x, window.frame.origin.y));
NSString *commandLine = [NSString stringWithCString:projectConfig.makeCommandLine(mask).c_str()
encoding:NSUTF8StringEncoding];
return [NSMutableArray arrayWithArray:[commandLine componentsSeparatedByString:@" "]];
}
- (void) updateProjectConfigFromCommandLineArgs:(ProjectConfig *)config
{
NSArray *nsargs = [[NSProcessInfo processInfo] arguments];
vector args;
for (int i = 0; i < [nsargs count]; ++i)
{
args.push_back([[nsargs objectAtIndex:i] cStringUsingEncoding:NSUTF8StringEncoding]);
}
config->parseCommandLine(args);
config->dump();
}
- (void) launch:(NSArray*)args
{
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]];
NSMutableDictionary *configuration = [NSMutableDictionary dictionaryWithObject:args
forKey:NSWorkspaceLaunchConfigurationArguments];
NSError *error = [[[NSError alloc] init] autorelease];
[[NSWorkspace sharedWorkspace] launchApplicationAtURL:url
options:NSWorkspaceLaunchNewInstance
configuration:configuration error:&error];
}
- (void) relaunch:(NSArray*)args
{
[self saveLastState];
if (projectConfig.isExitWhenRelaunch())
{
exit(99);
}
else
{
[self launch:args];
[[NSApplication sharedApplication] terminate:self];
}
}
- (void) relaunch
{
[self relaunch:[self makeCommandLineArgsFromProjectConfig]];
}
- (void) showAlertWithoutSheet:(NSString*)message withTitle:(NSString*)title
{
NSAlert *alert = [[[NSAlert alloc] init] autorelease];
[alert addButtonWithTitle:@"OK"];
[alert setMessageText:message];
[alert setInformativeText:title];
[alert setAlertStyle:NSWarningAlertStyle];
[alert runModal];
}
- (void) setZoom:(float)scale
{
[glView setFrameZoomFactor:scale];
projectConfig.setFrameScale(scale);
}
-(void) setAlwaysOnTop:(BOOL)alwaysOnTop
{
NSMenuItem *windowMenu = [[window menu] itemWithTitle:@"Window"];
NSMenuItem *menuItem = [[windowMenu submenu] itemWithTitle:@"Always On Top"];
if (alwaysOnTop)
{
[window setLevel:NSFloatingWindowLevel];
[menuItem setState:NSOnState];
}
else
{
[window setLevel:NSNormalWindowLevel];
[menuItem setState:NSOffState];
}
isAlwaysOnTop = alwaysOnTop;
}
-(void) saveLastState
{
NSMutableDictionary *state = [NSMutableDictionary dictionary];
[state setObject:[NSNumber numberWithInt:window.frame.origin.x] forKey:@"x"];
[state setObject:[NSNumber numberWithInt:window.frame.origin.y] forKey:@"y"];
[state setObject:[NSNumber numberWithFloat:projectConfig.getFrameScale()] forKey:@"scale"];
[[NSUserDefaults standardUserDefaults] setObject:state forKey:@"last-state"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
#pragma mark -
#pragma mark IB Actions
- (IBAction) onFileRelaunch:(id)sender
{
[self relaunch];
}
- (IBAction) onScreenChangeFrameSize:(id)sender
{
NSInteger i = [sender tag];
if (i >= 0 && i < SimulatorConfig::sharedDefaults()->getScreenSizeCount())
{
SimulatorScreenSize size = SimulatorConfig::sharedDefaults()->getScreenSize((int)i);
projectConfig.setFrameSize(projectConfig.isLandscapeFrame() ? CCSize(size.height, size.width) : CCSize(size.width, size.height));
projectConfig.setFrameScale(1.0f);
[self relaunch];
}
}
- (IBAction) onScreenPortait:(id)sender
{
if ([sender state] == NSOnState) return;
[sender setState:NSOnState];
[[[[[window menu] itemWithTitle:@"Screen"] submenu] itemWithTitle:@"Landscape"] setState:NSOffState];
projectConfig.changeFrameOrientationToPortait();
[self relaunch];
}
- (IBAction) onScreenLandscape:(id)sender
{
if ([sender state] == NSOnState) return;
[sender setState:NSOnState];
[[[[[window menu] itemWithTitle:@"Screen"] submenu] itemWithTitle:@"Portait"] setState:NSOffState];
projectConfig.changeFrameOrientationToLandscape();
[self relaunch];
}
- (IBAction) onScreenZoomOut:(id)sender
{
if ([sender state] == NSOnState) return;
float scale = (float)[sender tag] / 100.0f;
[self setZoom:scale];
[self updateUI];
}
-(IBAction) onWindowAlwaysOnTop:(id)sender
{
[self setAlwaysOnTop:!isAlwaysOnTop];
}
@end
================================================
FILE: 源代码/2.2.5/mir9/proj.mac/Info.plist
================================================
CFBundleDevelopmentRegion
en
CFBundleExecutable
${EXECUTABLE_NAME}
CFBundleIconFile
Icon
CFBundleIdentifier
com.qeeplay.apps.${PRODUCT_NAME:rfc1034identifier}
CFBundleInfoDictionaryVersion
6.0
CFBundleName
${PRODUCT_NAME}
CFBundlePackageType
APPL
CFBundleShortVersionString
1.2
CFBundleSignature
????
CFBundleVersion
20131001
LSApplicationCategoryType
public.app-category.developer-tools
LSMinimumSystemVersion
${MACOSX_DEPLOYMENT_TARGET}
NSHumanReadableCopyright
Copyright © 2012 qeeplay.com. All rights reserved.
NSMainNibFile
MainMenu
NSPrincipalClass
NSApplication
================================================
FILE: 源代码/2.2.5/mir9/proj.mac/MainMenu.xib
================================================
================================================
FILE: 源代码/2.2.5/mir9/proj.mac/main.m
================================================
#import
int main(int argc, char *argv[])
{
return NSApplicationMain(argc, (const char **)argv);
}
================================================
FILE: 源代码/2.2.5/mir9/proj.mac/mir9.xcodeproj/project.pbxproj
================================================
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
F40EE898163F83E000090121 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F44C957915F49004004D4151 /* AppKit.framework */; };
F44C957715F49004004D4151 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F44C957615F49004004D4151 /* Cocoa.framework */; };
F4703CBE177955E200A8A9E9 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = F4703CBC177955E100A8A9E9 /* MainMenu.xib */; };
F4A5C15E16B7A35700A12606 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F4A5C15816B7A35700A12606 /* AudioToolbox.framework */; };
F4A5C15F16B7A35700A12606 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F4A5C15916B7A35700A12606 /* OpenAL.framework */; };
F4A5C16016B7A35700A12606 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F4A5C15A16B7A35700A12606 /* OpenGL.framework */; };
F4A5C16E16B7A3EC00A12606 /* libcurl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = F4A5C16B16B7A3EC00A12606 /* libcurl.dylib */; };
F4A5C16F16B7A3EC00A12606 /* libxml2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = F4A5C16C16B7A3EC00A12606 /* libxml2.dylib */; };
F4A5C17016B7A3EC00A12606 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = F4A5C16D16B7A3EC00A12606 /* libz.dylib */; };
F4B0814A175C89050029F472 /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4B08140175C89050029F472 /* AppController.mm */; };
F4B0814D175C89050029F472 /* Icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = F4B08146175C89050029F472 /* Icon.icns */; };
F4B0814F175C89050029F472 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F4B08148175C89050029F472 /* main.m */; };
F4B08157175C89E90029F472 /* libquickcocos2dx.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F4B08156175C89E30029F472 /* libquickcocos2dx.a */; };
F4B0815E175C8A1E0029F472 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4B0815A175C8A1E0029F472 /* AppDelegate.cpp */; };
F4B4EF6616CA2A8B00736FFE /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F4B4EF6516CA2A8B00736FFE /* SystemConfiguration.framework */; };
F4BA6EB315F499A300CE7A10 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F4BA6EB215F499A300CE7A10 /* QuartzCore.framework */; };
F4BA6EBD15F499EE00CE7A10 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F4BA6EBC15F499EE00CE7A10 /* Security.framework */; };
F4DDD22D1926533C00D37F83 /* mir9.app in CopyFiles */ = {isa = PBXBuildFile; fileRef = F44C957215F49004004D4151 /* mir9.app */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
F4B08155175C89E30029F472 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = F4B08151175C89E30029F472 /* quickcocos2dx.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = F4DE082016800061005DB2DB;
remoteInfo = quickcocos2dx;
};
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
F4DDD22C1926532400D37F83 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "$(SRCROOT)/bin";
dstSubfolderSpec = 0;
files = (
F4DDD22D1926533C00D37F83 /* mir9.app in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
F44C957215F49004004D4151 /* mir9.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "mir9.app"; sourceTree = BUILT_PRODUCTS_DIR; };
F44C957615F49004004D4151 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
F44C957915F49004004D4151 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
F44C957A15F49004004D4151 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; };
F44C957B15F49004004D4151 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
F4703CBC177955E100A8A9E9 /* MainMenu.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainMenu.xib; sourceTree = ""; };
F4A5C15816B7A35700A12606 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/AudioToolbox.framework; sourceTree = ""; };
F4A5C15916B7A35700A12606 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/OpenAL.framework; sourceTree = ""; };
F4A5C15A16B7A35700A12606 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/OpenGL.framework; sourceTree = ""; };
F4A5C16B16B7A3EC00A12606 /* libcurl.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcurl.dylib; path = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/lib/libcurl.dylib; sourceTree = ""; };
F4A5C16C16B7A3EC00A12606 /* libxml2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libxml2.dylib; path = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/lib/libxml2.dylib; sourceTree = ""; };
F4A5C16D16B7A3EC00A12606 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/lib/libz.dylib; sourceTree = ""; };
F4B0813F175C89050029F472 /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = SOURCE_ROOT; };
F4B08140175C89050029F472 /* AppController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppController.mm; sourceTree = SOURCE_ROOT; };
F4B08146175C89050029F472 /* Icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Icon.icns; sourceTree = SOURCE_ROOT; };
F4B08147175C89050029F472 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = SOURCE_ROOT; };
F4B08148175C89050029F472 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = SOURCE_ROOT; };
F4B08149175C89050029F472 /* Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = SOURCE_ROOT; };
F4B08151175C89E30029F472 /* quickcocos2dx.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = quickcocos2dx.xcodeproj; path = lib/proj.mac/quickcocos2dx.xcodeproj; sourceTree = QUICK_COCOS2DX_ROOT; };
F4B0815A175C8A1E0029F472 /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppDelegate.cpp; sourceTree = ""; };
F4B0815B175C8A1E0029F472 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
F4B4EF6516CA2A8B00736FFE /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
F4BA6EB215F499A300CE7A10 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
F4BA6EBA15F499CC00CE7A10 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; };
F4BA6EBC15F499EE00CE7A10 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
F44C956F15F49004004D4151 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
F4B08157175C89E90029F472 /* libquickcocos2dx.a in Frameworks */,
F4B4EF6616CA2A8B00736FFE /* SystemConfiguration.framework in Frameworks */,
F40EE898163F83E000090121 /* AppKit.framework in Frameworks */,
F4BA6EBD15F499EE00CE7A10 /* Security.framework in Frameworks */,
F4BA6EB315F499A300CE7A10 /* QuartzCore.framework in Frameworks */,
F44C957715F49004004D4151 /* Cocoa.framework in Frameworks */,
F4A5C15E16B7A35700A12606 /* AudioToolbox.framework in Frameworks */,
F4A5C15F16B7A35700A12606 /* OpenAL.framework in Frameworks */,
F4A5C16016B7A35700A12606 /* OpenGL.framework in Frameworks */,
F4A5C16E16B7A3EC00A12606 /* libcurl.dylib in Frameworks */,
F4A5C16F16B7A3EC00A12606 /* libxml2.dylib in Frameworks */,
F4A5C17016B7A3EC00A12606 /* libz.dylib in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
F44C956715F49004004D4151 = {
isa = PBXGroup;
children = (
F4B08151175C89E30029F472 /* quickcocos2dx.xcodeproj */,
F44C957C15F49004004D4151 /* mir9 */,
F44C957515F49004004D4151 /* Frameworks */,
F44C957315F49004004D4151 /* Products */,
);
sourceTree = "";
};
F44C957315F49004004D4151 /* Products */ = {
isa = PBXGroup;
children = (
F44C957215F49004004D4151 /* mir9.app */,
);
name = Products;
sourceTree = "";
};
F44C957515F49004004D4151 /* Frameworks */ = {
isa = PBXGroup;
children = (
F44C957915F49004004D4151 /* AppKit.framework */,
F4A5C15816B7A35700A12606 /* AudioToolbox.framework */,
F44C957615F49004004D4151 /* Cocoa.framework */,
F44C957A15F49004004D4151 /* CoreData.framework */,
F4BA6EBA15F499CC00CE7A10 /* CoreFoundation.framework */,
F44C957B15F49004004D4151 /* Foundation.framework */,
F4A5C16B16B7A3EC00A12606 /* libcurl.dylib */,
F4A5C16C16B7A3EC00A12606 /* libxml2.dylib */,
F4A5C16D16B7A3EC00A12606 /* libz.dylib */,
F4A5C15916B7A35700A12606 /* OpenAL.framework */,
F4A5C15A16B7A35700A12606 /* OpenGL.framework */,
F4BA6EB215F499A300CE7A10 /* QuartzCore.framework */,
F4BA6EBC15F499EE00CE7A10 /* Security.framework */,
F4B4EF6516CA2A8B00736FFE /* SystemConfiguration.framework */,
);
name = Frameworks;
sourceTree = "";
};
F44C957C15F49004004D4151 /* mir9 */ = {
isa = PBXGroup;
children = (
F4B08159175C8A1E0029F472 /* sources */,
F4B08158175C8A100029F472 /* mac */,
);
name = "mir9";
sourceTree = "";
};
F4B08152175C89E30029F472 /* Products */ = {
isa = PBXGroup;
children = (
F4B08156175C89E30029F472 /* libquickcocos2dx.a */,
);
name = Products;
sourceTree = "";
};
F4B08158175C8A100029F472 /* mac */ = {
isa = PBXGroup;
children = (
F4B0813F175C89050029F472 /* AppController.h */,
F4B08140175C89050029F472 /* AppController.mm */,
F4B08146175C89050029F472 /* Icon.icns */,
F4B08147175C89050029F472 /* Info.plist */,
F4B08148175C89050029F472 /* main.m */,
F4703CBC177955E100A8A9E9 /* MainMenu.xib */,
F4B08149175C89050029F472 /* Prefix.pch */,
);
name = mac;
sourceTree = "";
};
F4B08159175C8A1E0029F472 /* sources */ = {
isa = PBXGroup;
children = (
F4B0815A175C8A1E0029F472 /* AppDelegate.cpp */,
F4B0815B175C8A1E0029F472 /* AppDelegate.h */,
);
name = sources;
path = ../sources;
sourceTree = "";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
F44C957115F49004004D4151 /* mir9 */ = {
isa = PBXNativeTarget;
buildConfigurationList = F44C959015F49004004D4151 /* Build configuration list for PBXNativeTarget "mir9" */;
buildPhases = (
F44C956E15F49004004D4151 /* Sources */,
F44C956F15F49004004D4151 /* Frameworks */,
F44C957015F49004004D4151 /* Resources */,
F4DDD22C1926532400D37F83 /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = "mir9";
productName = "mir9";
productReference = F44C957215F49004004D4151 /* mir9.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
F44C956915F49004004D4151 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0500;
ORGANIZATIONNAME = qeeplay.com;
};
buildConfigurationList = F44C956C15F49004004D4151 /* Build configuration list for PBXProject "mir9" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = F44C956715F49004004D4151;
productRefGroup = F44C957315F49004004D4151 /* Products */;
projectDirPath = "";
projectReferences = (
{
ProductGroup = F4B08152175C89E30029F472 /* Products */;
ProjectRef = F4B08151175C89E30029F472 /* quickcocos2dx.xcodeproj */;
},
);
projectRoot = "";
targets = (
F44C957115F49004004D4151 /* mir9 */,
);
};
/* End PBXProject section */
/* Begin PBXReferenceProxy section */
F4B08156175C89E30029F472 /* libquickcocos2dx.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libquickcocos2dx.a;
remoteRef = F4B08155175C89E30029F472 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */
/* Begin PBXResourcesBuildPhase section */
F44C957015F49004004D4151 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
F4B0814D175C89050029F472 /* Icon.icns in Resources */,
F4703CBE177955E200A8A9E9 /* MainMenu.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
F44C956E15F49004004D4151 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
F4B0814A175C89050029F472 /* AppController.mm in Sources */,
F4B0814F175C89050029F472 /* main.m in Sources */,
F4B0815E175C8A1E0029F472 /* AppDelegate.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
F44C958E15F49004004D4151 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
TARGET_OS_MAC,
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.7;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = (
"-pagezero_size",
10000,
"-image_base",
100000000,
);
SDKROOT = macosx;
VALID_ARCHS = "$(ARCHS_STANDARD)";
};
name = Debug;
};
F44C958F15F49004004D4151 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ARCHS = "$(ARCHS_STANDARD)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_PREPROCESSOR_DEFINITIONS = TARGET_OS_MAC;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.7;
OTHER_LDFLAGS = (
"-pagezero_size",
10000,
"-image_base",
100000000,
);
SDKROOT = macosx;
VALID_ARCHS = "$(ARCHS_STANDARD)";
};
name = Release;
};
F44C959115F49004004D4151 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
COMBINE_HIDPI_IMAGES = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_INLINES_ARE_PRIVATE_EXTERN = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Prefix.pch;
GCC_PREPROCESSOR_DEFINITIONS = (
CC_TARGET_OS_MAC,
"DEBUG=1",
USE_FILE32API,
"CC_LUA_ENGINE_ENABLED=1",
"COCOS2D_DEBUG=1",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
HEADER_SEARCH_PATHS = (
"\"$(SDKROOT)/usr/include/libxml2\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx/include\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx/platform\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx/platform/mac\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx/platform/third_party/mac\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx/kazmath/include\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/CocosDenshion/include\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/CocosDenshion/mac\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/extensions\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/extensions/GUI/CCControlExtension\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/extensions/GUI/CCEditBox\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/external/chipmunk/include\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/external/chipmunk/luabinding\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/external/extra\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/external/extra/luabinding\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/scripting/lua/cocos2dx_support\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/scripting/lua/tolua\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/scripting/lua/luajit/include\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/scripting/lua/lua_extensions\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/scripting/lua/lua_extensions/cjson\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/scripting/lua/lua_extensions/zlib\"",
);
INFOPLIST_FILE = "$(SRCROOT)/Info.plist";
INFOPLIST_OUTPUT_FORMAT = binary;
LIBRARY_SEARCH_PATHS = "$(inherited)";
MACOSX_DEPLOYMENT_TARGET = 10.7;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
VALID_ARCHS = "$(ARCHS_STANDARD)";
WRAPPER_EXTENSION = app;
};
name = Debug;
};
F44C959215F49004004D4151 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
COMBINE_HIDPI_IMAGES = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_INLINES_ARE_PRIVATE_EXTERN = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = Prefix.pch;
GCC_PREPROCESSOR_DEFINITIONS = (
CC_TARGET_OS_MAC,
USE_FILE32API,
"CC_LUA_ENGINE_ENABLED=1",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
HEADER_SEARCH_PATHS = (
"\"$(SDKROOT)/usr/include/libxml2\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx/include\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx/platform\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx/platform/mac\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx/platform/third_party/mac\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/cocos2dx/kazmath/include\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/CocosDenshion/include\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/CocosDenshion/mac\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/extensions\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/extensions/GUI/CCControlExtension\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/extensions/GUI/CCEditBox\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/external/chipmunk/include\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/external/chipmunk/luabinding\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/external/extra\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/external/extra/luabinding\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/scripting/lua/cocos2dx_support\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/scripting/lua/tolua\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/scripting/lua/luajit/include\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/scripting/lua/lua_extensions\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/scripting/lua/lua_extensions/cjson\"",
"\"$(QUICK_COCOS2DX_ROOT)/lib/cocos2d-x/scripting/lua/lua_extensions/zlib\"",
);
INFOPLIST_FILE = "$(SRCROOT)/Info.plist";
INFOPLIST_OUTPUT_FORMAT = binary;
LIBRARY_SEARCH_PATHS = "$(inherited)";
MACOSX_DEPLOYMENT_TARGET = 10.7;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
VALID_ARCHS = "$(ARCHS_STANDARD)";
WRAPPER_EXTENSION = app;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
F44C956C15F49004004D4151 /* Build configuration list for PBXProject "mir9" */ = {
isa = XCConfigurationList;
buildConfigurations = (
F44C958E15F49004004D4151 /* Debug */,
F44C958F15F49004004D4151 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
F44C959015F49004004D4151 /* Build configuration list for PBXNativeTarget "mir9" */ = {
isa = XCConfigurationList;
buildConfigurations = (
F44C959115F49004004D4151 /* Debug */,
F44C959215F49004004D4151 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = F44C956915F49004004D4151 /* Project object */;
}
================================================
FILE: 源代码/2.2.5/mir9/proj.win32/app.cpp
================================================
#pragma comment(lib, "comctl32.lib")
#pragma comment(linker, "\"/manifestdependency:type='Win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='X86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#include "stdafx.h"
#include "app.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "CCEGLView.h"
#include "CCLuaEngine.h"
#include "CCLuaStack.h"
#include "SimpleAudioEngine.h"
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
return App::createAndRun();
}
int App::createAndRun(void)
{
App *host = App::sharedInstance();
int ret = host->run();
App::purgeSharedInstance();
return ret;
}
App *App::s_sharedInstance = NULL;
App *App::sharedInstance(void)
{
if (!s_sharedInstance)
{
s_sharedInstance = new App();
}
return s_sharedInstance;
}
void App::purgeSharedInstance(void)
{
if (s_sharedInstance)
{
delete s_sharedInstance;
s_sharedInstance = NULL;
}
}
App::App(void)
: m_app(NULL)
, m_hwnd(NULL)
, m_exit(TRUE)
, m_writeDebugLogFile(NULL)
{
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
}
int App::run(void)
{
const char *QUICK_COCOS2DX_ROOT = getenv("QUICK_COCOS2DX_ROOT");
SimulatorConfig::sharedDefaults()->setQuickCocos2dxRootPath(QUICK_COCOS2DX_ROOT);
loadProjectConfig();
HWND hwndConsole = NULL;
if (m_project.isShowConsole())
{
AllocConsole();
freopen("CONOUT$", "wt", stdout);
freopen("CONOUT$", "wt", stderr);
// disable close console
hwndConsole = GetConsoleWindow();
if (hwndConsole != NULL)
{
HMENU hMenu = GetSystemMenu(hwndConsole, FALSE);
if (hMenu != NULL) DeleteMenu(hMenu, SC_CLOSE, MF_BYCOMMAND);
ShowWindow(hwndConsole, SW_SHOW);
BringWindowToTop(hwndConsole);
}
}
m_project.dump();
if (m_project.isWriteDebugLogToFile())
{
const string debugLogFilePath = m_project.getDebugLogFilePath();
m_writeDebugLogFile = fopen(debugLogFilePath.c_str(), "w");
if (!m_writeDebugLogFile)
{
CCLOG("Cannot create debug log file %s", debugLogFilePath.c_str());
}
}
do
{
m_exit = TRUE;
// create the application instance
m_app = new AppDelegate();
m_app->setProjectConfig(m_project);
// set environments
SetCurrentDirectoryA(m_project.getProjectDir().c_str());
CCFileUtils::sharedFileUtils()->setSearchRootPath(m_project.getProjectDir().c_str());
CCFileUtils::sharedFileUtils()->setWritablePath(m_project.getWritableRealPath().c_str());
// create opengl view
CCEGLView* eglView = CCEGLView::sharedOpenGLView();
eglView->setMenuResource(MAKEINTRESOURCE(IDC_LUAHOSTWIN32));
eglView->setWndProc(WindowProc);
eglView->setFrameSize(m_project.getFrameSize().width, m_project.getFrameSize().height);
eglView->setFrameZoomFactor(m_project.getFrameScale());
// make window actived
m_hwnd = eglView->getHWnd();
BringWindowToTop(m_hwnd);
SetWindowTextA(m_hwnd, "mir9");
// restore window position
const CCPoint windowOffset = m_project.getWindowOffset();
if (windowOffset.x != 0 || windowOffset.y != 0)
{
eglView->moveWindow(windowOffset.x, windowOffset.y);
}
// set icon
HICON icon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_LUAHOSTWIN32));
SendMessage(m_hwnd, WM_SETICON, ICON_BIG, (LPARAM)icon);
if (hwndConsole)
{
SendMessage(hwndConsole, WM_SETICON, ICON_BIG, (LPARAM)icon);
}
// update menu
createViewMenu();
updateMenu();
// run game
CCLuaStack *stack = CCLuaEngine::defaultEngine()->getLuaStack();
const vector arr = m_project.getPackagePathArray();
for (vector::const_iterator it = arr.begin(); it != arr.end(); ++it)
{
stack->addSearchPath(it->c_str());
}
m_app->run();
// cleanup
CCScriptEngineManager::sharedManager()->removeScriptEngine();
CCScriptEngineManager::purgeSharedManager();
CocosDenshion::SimpleAudioEngine::end();
delete m_app;
m_app = NULL;
} while (!m_exit);
FreeConsole();
if (m_writeDebugLogFile) fclose(m_writeDebugLogFile);
return 0;
}
void App::loadProjectConfig(void)
{
vector args;
for (int i = 0; i < __argc; ++i)
{
wstring ws(__wargv[i]);
string s;
s.assign(ws.begin(), ws.end());
args.push_back(s);
}
if (args.size() <= 1)
{
args.push_back("-workdir");
#ifdef DEBUG
args.push_back(DEBUG_WORK_DIR);
#else
char szPath[MAX_PATH] = {0};
::GetModuleFileNameA(NULL, szPath, MAX_PATH);
string strPath(szPath);
for (int nPos = (int)strPath.size()-1; nPos >= 0; --nPos)
{
char cChar = strPath[nPos];
if (_T('\\') == cChar || _T('/') == cChar)
{
strPath = strPath.substr(0, nPos+1);
break;
}
}
args.push_back(strPath);
args.push_back("-disable-console");
#endif
#ifndef ENCRYPT_LUA
args.push_back("-file");
args.push_back("scripts/main.lua");
#endif
args.push_back("-size");
args.push_back("960x640");
}
m_project.parseCommandLine(args);
}
void App::createViewMenu(void)
{
HMENU menu = GetMenu(m_hwnd);
HMENU viewMenu = GetSubMenu(menu, 1);
for (int i = SimulatorConfig::sharedDefaults()->getScreenSizeCount() - 1; i >= 0; --i)
{
SimulatorScreenSize size = SimulatorConfig::sharedDefaults()->getScreenSize(i);
wstring menuName;
menuName.assign(size.title.begin(), size.title.end());
MENUITEMINFO item;
ZeroMemory(&item, sizeof(item));
item.cbSize = sizeof(item);
item.fMask = MIIM_FTYPE | MIIM_ID | MIIM_STRING;
item.fType = MFT_STRING;
item.wID = ID_VIEW_SIZE + i;
item.dwTypeData = (LPTSTR)menuName.c_str();
item.cch = menuName.length();
InsertMenuItem(viewMenu, 0, TRUE, &item);
}
}
void App::updateMenu(void)
{
HMENU menu = GetMenu(m_hwnd);
HMENU viewMenu = GetSubMenu(menu, 1);
if (m_project.isLandscapeFrame())
{
CheckMenuItem(viewMenu, ID_VIEW_PORTRAIT, MF_BYCOMMAND | MF_UNCHECKED);
CheckMenuItem(viewMenu, ID_VIEW_LANDSCAPE, MF_BYCOMMAND | MF_CHECKED);
}
else
{
CheckMenuItem(viewMenu, ID_VIEW_PORTRAIT, MF_BYCOMMAND | MF_CHECKED);
CheckMenuItem(viewMenu, ID_VIEW_LANDSCAPE, MF_BYCOMMAND | MF_UNCHECKED);
}
if (m_project.getFrameScale() < 1.0f)
{
CheckMenuItem(viewMenu, ID_VIEW_RESET_ZOOM, MF_BYCOMMAND | MF_UNCHECKED);
CheckMenuItem(viewMenu, ID_VIEW_ZOOM_OUT, MF_BYCOMMAND | MF_CHECKED);
}
else
{
CheckMenuItem(viewMenu, ID_VIEW_RESET_ZOOM, MF_BYCOMMAND | MF_CHECKED);
CheckMenuItem(viewMenu, ID_VIEW_ZOOM_OUT, MF_BYCOMMAND | MF_UNCHECKED);
}
int current = SimulatorConfig::sharedDefaults()->checkScreenSize(m_project.getFrameSize());
for (int i = SimulatorConfig::sharedDefaults()->getScreenSizeCount() - 1; i >= 0; --i)
{
CheckMenuItem(viewMenu, i, MF_BYPOSITION | (i == current ? MF_CHECKED : MF_UNCHECKED));
}
}
void App::relaunch(void)
{
string commandLine = m_project.makeCommandLine(kProjectConfigAll);
TCHAR moduleName[MAX_PATH];
ZeroMemory(moduleName, sizeof(moduleName));
GetModuleFileName(NULL, moduleName, MAX_PATH);
wstring ws;
ws.append(L"\"");
ws.append(moduleName);
ws.append(L"\" ");
ws.append(commandLine.begin(), commandLine.end());
STARTUPINFO si = {0};
PROCESS_INFORMATION pi = {0};
lstrcpyW(moduleName, ws.c_str());
if (CreateProcess(NULL, moduleName, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi))
{
ExitProcess(0);
}
}
void App::writeDebugLog(const char *log)
{
if (!m_writeDebugLogFile) return;
fputs(log, m_writeDebugLogFile);
fputc('\n', m_writeDebugLogFile);
fflush(m_writeDebugLogFile);
}
// menu callback
void App::onFileRelaunch(void)
{
relaunch();
}
void App::onFileExit(void)
{
DestroyWindow(m_hwnd);
}
void App::onViewChangeFrameSize(int viewMenuID)
{
int index = viewMenuID - ID_VIEW_SIZE;
if (index >= 0 && index < SimulatorConfig::sharedDefaults()->getScreenSizeCount())
{
SimulatorScreenSize size = SimulatorConfig::sharedDefaults()->getScreenSize(index);
bool isLandscape = m_project.isLandscapeFrame();
m_project.setFrameSize(CCSize(size.width, size.height));
if (isLandscape)
{
m_project.changeFrameOrientationToLandscape();
}
else
{
m_project.changeFrameOrientationToPortait();
}
m_project.setFrameScale(1.0f);
relaunch();
}
}
void App::onViewChangeOrientation(int viewMenuID)
{
bool isLandscape = m_project.isLandscapeFrame();
bool isNeedRelaunch = false;
if (viewMenuID == ID_VIEW_PORTRAIT && isLandscape)
{
m_project.changeFrameOrientationToPortait();
isNeedRelaunch = true;
}
else if (viewMenuID == ID_VIEW_LANDSCAPE && !isLandscape)
{
m_project.changeFrameOrientationToLandscape();
isNeedRelaunch = true;
}
if (isNeedRelaunch) relaunch();
}
void App::onViewChangeZoom(int scaleMode)
{
float scale = 1.0f;
if (scaleMode == ID_VIEW_ZOOM_OUT)
{
scale = 0.5f;
}
m_project.setFrameScale(scale);
CCEGLView::sharedOpenGLView()->setFrameZoomFactor(scale);
CCEGLView::sharedOpenGLView()->resize(m_project.getFrameSize().width * scale,
m_project.getFrameSize().height * scale);
updateMenu();
}
// windows callback
LRESULT App::WindowProc(UINT message, WPARAM wParam, LPARAM lParam, BOOL* pProcessed)
{
int wmId, wmEvent;
App *host = App::sharedInstance();
HWND hwnd = host->getWindowHandle();
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
switch (wmId)
{
case ID_FILE_RELAUNCH:
host->onFileRelaunch();
break;
case ID_FILE_EXIT:
host->onFileExit();
break;
case ID_VIEW_PORTRAIT:
case ID_VIEW_LANDSCAPE:
host->onViewChangeOrientation(wmId);
break;
case ID_VIEW_RESET_ZOOM:
case ID_VIEW_ZOOM_OUT:
host->onViewChangeZoom(wmId);
break;
default:
if (wmId >= ID_VIEW_SIZE && wmId <= ID_VIEW_SIZE + SimulatorConfig::sharedDefaults()->getScreenSizeCount() - 1)
{
host->onViewChangeFrameSize(wmId);
break;
}
return 0;
}
break;
case WM_KEYDOWN:
if (wParam == VK_F5)
{
host->onFileRelaunch();
}
break;
case WM_COPYDATA:
{
PCOPYDATASTRUCT pMyCDS = (PCOPYDATASTRUCT) lParam;
if (pMyCDS->dwData == CCLOG_STRING)
{
const char *szBuf = (const char*)(pMyCDS->lpData);
sharedInstance()->writeDebugLog(szBuf);
break;
}
}
default:
return 0;
}
*pProcessed = TRUE;
return 0;
}
================================================
FILE: 源代码/2.2.5/mir9/proj.win32/app.h
================================================
#pragma once
#include "resource.h"
// C RunTime Header Files
#include "CCStdC.h"
#include
#include "cocos2d.h"
#include "AppDelegate.h"
#include "ProjectConfig/SimulatorConfig.h"
using namespace std;
using namespace cocos2d;
class CC_DLL App : public CCObject
{
public:
static int createAndRun(void);
AppDelegate *getApp(void) {
return m_app;
}
HWND getWindowHandle(void) {
return m_hwnd;
}
private:
static App *s_sharedInstance;
static App *sharedInstance(void);
static void purgeSharedInstance(void);
App(void);
AppDelegate *m_app;
ProjectConfig m_project;
HWND m_hwnd;
BOOL m_exit;
FILE *m_writeDebugLogFile;
int run(void);
void loadProjectConfig(void);
void createViewMenu(void);
void updateMenu(void);
void relaunch(void);
// debug log
void writeDebugLog(const char *log);
// menu callback
void onFileRelaunch(void);
void onFileExit(void);
void onViewChangeFrameSize(int viewMenuID);
void onViewChangeOrientation(int viewMenuID);
void onViewChangeZoom(int scaleMode);
// windows callback
static LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam, BOOL *pProcessed);
};
================================================
FILE: 源代码/2.2.5/mir9/proj.win32/mir9.sln
================================================
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mir9", "mir9.vcxproj", "{71666DE3-D772-41E9-8624-8881686C7AED}"
ProjectSection(ProjectDependencies) = postProject
{9E05AA4B-1A09-433C-B1DF-BCE6675EC0D5} = {9E05AA4B-1A09-433C-B1DF-BCE6675EC0D5}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cocos2dx_2012", "%QUICK_COCOS2DX_ROOT%\lib\proj.win32\cocos2dx_2012.vcxproj", "{9E05AA4B-1A09-433C-B1DF-BCE6675EC0D5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{71666DE3-D772-41E9-8624-8881686C7AED}.Debug|Win32.ActiveCfg = Debug|Win32
{71666DE3-D772-41E9-8624-8881686C7AED}.Debug|Win32.Build.0 = Debug|Win32
{71666DE3-D772-41E9-8624-8881686C7AED}.Release|Win32.ActiveCfg = Release|Win32
{71666DE3-D772-41E9-8624-8881686C7AED}.Release|Win32.Build.0 = Release|Win32
{9E05AA4B-1A09-433C-B1DF-BCE6675EC0D5}.Debug|Win32.ActiveCfg = Debug|Win32
{9E05AA4B-1A09-433C-B1DF-BCE6675EC0D5}.Debug|Win32.Build.0 = Debug|Win32
{9E05AA4B-1A09-433C-B1DF-BCE6675EC0D5}.Release|Win32.ActiveCfg = Release|Win32
{9E05AA4B-1A09-433C-B1DF-BCE6675EC0D5}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
================================================
FILE: 源代码/2.2.5/mir9/proj.win32/mir9.vcxproj
================================================
Debug
Win32
Release
Win32
{71666DE3-D772-41E9-8624-8881686C7AED}
Win32Proj
mir9
Application
true
v110_xp
Unicode
false
false
Application
false
v110_xp
true
Unicode
true
mir9
false
mir9
Level3
Disabled
WIN32;_DEBUG;_WINDOWS;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;CC_LUA_ENGINE_ENABLED=1;%(PreprocessorDefinitions)
$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\include;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\kazmath\include;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\support;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\support\tinyxml2;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\platform;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\platform\win32;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\platform\third_party\win32;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\platform\third_party\win32\curl;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\platform\third_party\win32\iconv;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\platform\third_party\win32\libjpeg;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\platform\third_party\win32\libpng;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\platform\third_party\win32\libtiff;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\platform\third_party\win32\libwebp;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\platform\third_party\win32\OGLES;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\platform\third_party\win32\pthread;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\platform\third_party\win32\zlib;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\CocosDenshion\include;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\CocosDenshion\win32;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\scripting\lua\cocos2dx_support;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\scripting\lua\tolua;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\scripting\lua\luajit\include;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\scripting\lua\lua_extensions;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\scripting\lua\lua_extensions\cjson;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\scripting\lua\lua_extensions\filesystem;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\scripting\lua\lua_extensions\lpack;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\scripting\lua\lua_extensions\socket;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\scripting\lua\lua_extensions\zlib;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\GUI\CCControlExtension;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\GUI\CCEditBox;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\GUI\CCScrollView;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\AssetsManager;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\CCBReader;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\network;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\CocoStudio\Action;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\CocoStudio\Armature;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\CocoStudio\Armature\animation;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\CocoStudio\Armature\datas;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\CocoStudio\Armature\display;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\CocoStudio\Armature\external_tool;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\CocoStudio\Armature\utils;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\CocoStudio\Components;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\CocoStudio\GUI;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\CocoStudio\Json;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\CocoStudio\Reader;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\external\libwebsockets\win32\include;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\external\libwebsockets\win32\include\win32helpers;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\external\chipmunk\include;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\external\chipmunk\luabinding;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\external\chipmunk\cocos2dx_support;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\external\luaproxy;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\external\luaproxy\tolua;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\external\luaproxy\ui;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\external\extra;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\external\extra\crypto;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\external\extra\luabinding;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\external\extra\native;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\external\extra\network;$(ProjectDir)..\sources;%(AdditionalIncludeDirectories)
4068;4267;4251;4244;%(DisableSpecificWarnings)
true
false
MultiThreadedDebugDLL
Windows
true
cocos2dx.lib;opengl32.lib;ws2_32.lib;wsock32.lib;pthreadVCE2.lib;lua51.lib;winmm.lib;glew32.lib;libcurl_imp.lib;libiconv.lib;libjpeg.lib;libpng.lib;libtiff.lib;libzlib.lib;libwebp.lib;websockets.lib;%(AdditionalDependencies)
.\$(Configuration);$(QUICK_COCOS2DX_ROOT)\lib\luajit2\proj.win32;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\platform\third_party\win32\libraries;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\external\libwebsockets\win32\lib;%(AdditionalLibraryDirectories)
Level3
MaxSpeed
true
true
WIN32;NDEBUG;_WINDOWS;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;CC_LUA_ENGINE_ENABLED=1;%(PreprocessorDefinitions)
$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\include;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\kazmath\include;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\support;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\support\tinyxml2;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\platform;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\platform\win32;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\platform\third_party\win32;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\platform\third_party\win32\curl;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\platform\third_party\win32\iconv;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\platform\third_party\win32\libjpeg;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\platform\third_party\win32\libpng;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\platform\third_party\win32\libtiff;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\platform\third_party\win32\libwebp;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\platform\third_party\win32\OGLES;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\platform\third_party\win32\pthread;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\platform\third_party\win32\zlib;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\CocosDenshion\include;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\CocosDenshion\win32;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\scripting\lua\cocos2dx_support;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\scripting\lua\tolua;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\scripting\lua\luajit\include;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\scripting\lua\lua_extensions;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\scripting\lua\lua_extensions\cjson;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\scripting\lua\lua_extensions\filesystem;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\scripting\lua\lua_extensions\lpack;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\scripting\lua\lua_extensions\socket;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\scripting\lua\lua_extensions\zlib;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\GUI\CCControlExtension;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\GUI\CCEditBox;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\GUI\CCScrollView;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\AssetsManager;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\CCBReader;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\network;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\CocoStudio\Action;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\CocoStudio\Armature;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\CocoStudio\Armature\animation;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\CocoStudio\Armature\datas;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\CocoStudio\Armature\display;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\CocoStudio\Armature\external_tool;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\CocoStudio\Armature\utils;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\CocoStudio\Components;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\CocoStudio\GUI;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\CocoStudio\Json;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\extensions\CocoStudio\Reader;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\external\libwebsockets\win32\include;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\external\libwebsockets\win32\include\win32helpers;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\external\chipmunk\include;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\external\chipmunk\luabinding;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\external\chipmunk\cocos2dx_support;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\external\luaproxy;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\external\luaproxy\tolua;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\external\luaproxy\ui;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\external\extra;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\external\extra\crypto;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\external\extra\luabinding;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\external\extra\native;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\external\extra\network;$(ProjectDir)..\sources;%(AdditionalIncludeDirectories)
4068;4267;4251;4244;%(DisableSpecificWarnings)
true
Windows
true
true
true
cocos2dx.lib;opengl32.lib;ws2_32.lib;wsock32.lib;pthreadVCE2.lib;lua51.lib;winmm.lib;glew32.lib;libcurl_imp.lib;libiconv.lib;libjpeg.lib;libpng.lib;libtiff.lib;libzlib.lib;libwebp.lib;websockets.lib;%(AdditionalDependencies)
.\$(Configuration);$(QUICK_COCOS2DX_ROOT)\lib\luajit2\proj.win32;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\cocos2dx\platform\third_party\win32\libraries;$(QUICK_COCOS2DX_ROOT)\lib\cocos2d-x\external\libwebsockets\win32\lib;%(AdditionalLibraryDirectories)
================================================
FILE: 源代码/2.2.5/mir9/proj.win32/mir9.vcxproj.filters
================================================
{da35f943-2f62-4dbf-bd58-91a522b39592}
{54d36d2c-b373-4c65-962b-76ff1fedc28b}
win32
sources
win32
win32
win32
win32
sources
win32
win32
win32
================================================
FILE: 源代码/2.2.5/mir9/proj.win32/stdafx.cpp
================================================
#include "stdafx.h"
================================================
FILE: 源代码/2.2.5/mir9/proj.win32/stdafx.h
================================================
#pragma once
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files
#include
// C RunTime Header Files
#include
#include
#include
#include
================================================
FILE: 源代码/2.2.5/mir9/proj.win32/targetver.h
================================================
#pragma once
#include
================================================
FILE: 源代码/2.2.5/mir9/run-mac.sh
================================================
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
BIN="$DIR/proj.mac/bin/mir9.app/Contents/MacOS/mir9"
if [ ! -f $BIN ]; then
echo "PLEASE BUILD proj.mac/mir9.xcodeproj FIRST"
exit
fi
ARG="-relaunch-off -quick $QUICK_COCOS2DX_ROOT -workdir $DIR"
SIZE="-portrait"
CMD="$BIN $ARG $SIZE"
until $CMD; do
echo ""
echo "------------------------------------------------------"
echo ""
echo ""
echo ""
done
================================================
FILE: 源代码/2.2.5/mir9/run-win.bat
================================================
@echo off
E:\Demo\cocos2d-x\quick-cocos2d-x-2.2.5\player\win\player.exe -workdir E:\Demo\cocos2d-x\quick-cocos2d-x-2.2.5\projects\mir9 -file scripts\main.lua -size 960x640
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/GameSocket.lua
================================================
local PlayerController = require("app.figure.PlayerController")
local GameSocket = class("GameSocket")
function GameSocket.sendRoleCreate(node, roleID, nickName)
local _playerController = PlayerController.sharePlayerController()
_playerController.m_playerNumber = roleID
_playerController.m_weaponsNumber = 1000
_playerController.m_playerName = nickName
node:joinGame()
end
function GameSocket.attackGroup(one, two, skillNumber)
if ((not one) or (type(two) ~= "table") or (#two <= 0)) then
return
end
local hurt = one:getTheAttack()
if (skillNumber == 2005) then
hurt = hurt * 15
end
local r = math.random()
hurt = hurt + math.floor((hurt/10) * r) - hurt/20
for i = 1, #two do
if (two[i]:getBlood() <= 0) then
else
local blood = two[i]:getBlood() - hurt
blood = math.max(blood, 0)
two[i]:addAgainstMe(one, blood)
end
end
end
function GameSocket.attack(one, two, skillNumber)
if (not one or not two) then
return
end
if (two:getBlood() <= 0) then
return
end
local hurt = one:getTheAttack()
if (skillNumber == 1020) then
hurt = hurt * 1.5
end
hurt = hurt + (math.floor((hurt/10) * math.random()) - hurt/20)
local blood = two:getBlood() - hurt
blood = math.max(blood, 0)
two:addAgainstMe(one, blood)
end
return GameSocket
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/MyApp.lua
================================================
require("config")
require("framework.init")
local MyApp = class("MyApp", cc.mvc.AppBase)
function MyApp:ctor()
MyApp.super.ctor(self)
end
function MyApp:run()
math.randomseed(os.clock()*1000)
CCFileUtils:sharedFileUtils():addSearchPath("res/")
self:enterScene("LoginScene")
end
return MyApp
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/figure/Enemy.lua
================================================
local scheduler = require("framework.scheduler")
local MapPoint = require("app.map.MapPoint")
local Monomer = require("app.figure.Monomer")
local FlutteringFairy = require("app.game_ui.FlutteringFairy")
-- 敌人类
local Enemy = class("Enemy", Monomer)
function Enemy:ctor(enemyID, roleNumber, weaponNumber)
Enemy.super.ctor(self)
self.m_enemyID = enemyID
self.m_denPos = MapPoint.new(0, 0)
self.m_isActive = true
self:initWithEnemy(roleNumber, weaponNumber)
end
function Enemy:initWithEnemy(roleNumber, weaponNumber)
self.m_fReactionInterval = 1.0
self:setVisualRange(10)
self:setFigure(TexturePathType.Monster, roleNumber)
self:setWeapon(weaponNumber)
return true
end
function Enemy:onEnter()
Enemy.super.onEnter(self)
local mpoint = MapPoint.new(cc.p(self:getPosition()))
g_mainScene:insterMapPoint(self, mpoint)
end
function Enemy:onExit()
Enemy.super.onExit(self)
self:stopAllActions()
self:killTimer_Patrol()
end
-- 启动计时器
function Enemy:setTimer_Patrol(fTime)
self:killTimer_Patrol()
self.hPatrol = scheduler.scheduleGlobal(handler(self, self.patrol), fTime)
end
-- 关闭计时器
function Enemy:killTimer_Patrol()
if (self.hPatrol) then
scheduler.unscheduleGlobal(self.hPatrol)
self.hPatrol = nil
end
end
-- 显示人物
function Enemy:showFigure()
local point = cc.p(self:getPosition())
if (not g_mainScene:getCurrBgMap():getShowRect():containsPoint(point)) then
return
end
Enemy.super.showFigure(self)
end
-- 隐藏人物
function Enemy:hideFigure()
local point = cc.p(self:getPosition())
if (g_mainScene:getCurrBgMap():getHideRect():containsPoint(point)) then
return
end
Enemy.super.hideFigure(self)
end
-- 跑
function Enemy:runBy(mpoint)
local relust = Enemy.super.runBy(self, mpoint)
if (relust.fTime ~= 0) then
g_mainScene:insterMapPoint(self, relust.mpoint)
end
return relust
end
-- 走
function Enemy:walkBy(mpoint)
local relust = Enemy.super.walkBy(self, mpoint)
if (relust.fTime ~= 0) then
g_mainScene:insterMapPoint(self, relust.mpoint)
end
return relust
end
-- 去到指定点
function Enemy:goTo(mpoint)
g_mainScene:insterMapPoint(self, mpoint)
return Enemy.super.goTo(self, mpoint)
end
function Enemy:detectionOfEachOther()
Enemy.super.detectionOfEachOther(self)
self:detectionWhetherCounter()
end
-- 检测是否反击
function Enemy:detectionWhetherCounter()
if (not self.m_attackMonomerMajor) then
self:setAttackMonomerMajor(self:getAgainstMeOfFirst())
end
if (not self.m_attackMonomerMajor) then
self:patrol()
else
self:followAttackAndSetAttackMethods(self.m_attackMonomerMajor, self.m_attackSkillInfo.m_nNum)
end
end
function Enemy:followAttack()
self:killTimer_Patrol()
Enemy.super.followAttack(self)
end
function Enemy:followTheTracks()
local mpoint = self.m_attackMonomerMajor:ownAttackPoint(self, self.m_attackSkillInfo.m_attackDistance)
if (mpoint:equalsObj(MapPoint.new(cc.p(0, 0)))) then
return
end
mpoint = MapPoint.sub(mpoint, MapPoint.new(cc.p(self:getPosition())))
local relust = self:walkBy(mpoint)
local fTime = self.m_fReactionInterval + relust.fTime
self:delayCallBack(fTime, handler(self, self.followAttack)):setTag(TAG_FOLLOWATTACK)
end
-- 超出可视范围
function Enemy:beyondVisualRange()
self.m_attackMonomerMajor:removeAgainstMe(self)
self:patrol()
Enemy.super.beyondVisualRange(self)
end
-- 隔一段时间走动一下
function Enemy:patrol(fDelay)
self:killTimer_Patrol()
if (self.m_isCanMoved == false) then
return
end
local symbol = math.floor(2 * math.random())
local arcX = math.floor(10 * math.random())
local arcY = math.floor(10 * math.random())
local mpoint = MapPoint.new(self.m_denPos.x+arcX*symbol, self.m_denPos.z+arcY*symbol)
local dirt = MapPoint.sub(mpoint, MapPoint.new(cc.p(self:getPosition())))
self:walkBy(dirt)
local fTime = math.floor(180 * math.random()) + 1
self:setTimer_Patrol(fTime)
end
function Enemy:moveByEnd()
Enemy.super.moveByEnd(self)
end
-- 死亡
function Enemy:death()
if (self:getState() == FigureState.Death) then
return
end
Enemy.super.death(self)
local delayTime1 = cc.DelayTime:create(0.3)
local delayTime2 = cc.DelayTime:create(0.3)
local delayTime3 = cc.DelayTime:create(6)
local fadeOut = cc.FadeOut:create(0.1)
local callFunc1 = cc.CallFunc:create(handler(self, self.addExp))
local callFunc2 = cc.CallFunc:create(handler(self, self.removeThis))
local callFunc3 = cc.CallFunc:create(handler(self, self.removeFromParent))
local array = CCArray:create()
array:addObject(delayTime1)
array:addObject(callFunc1)
array:addObject(delayTime2)
array:addObject(callFunc2)
array:addObject(delayTime3)
array:addObject(fadeOut)
array:addObject(callFunc3)
local sequence = cc.Sequence:create(array)
self.m_nMonomer:runAction(sequence)
end
function Enemy:addAgainstMe(monomer, blood)
Enemy.super.addAgainstMe(self, monomer, blood)
self:hurt()
end
function Enemy:addExp()
local fairy = FlutteringFairy.addFairy(self, cc.p(0, self:getContentSize().height*0.6), FairyType.AddExp, math.random()*20+990, handler(self, self.flutteringFairyFinish))
self:pushFlutteringFairy(fairy)
end
function Enemy:removeThis()
g_mainScene:removeEnemy(self)
if (self.bloodBg) then
self.bloodBg:removeFromParent()
self.bloodBg = nil
end
end
function Enemy:getRoleNumber()
return self.m_nCurRoleNum
end
-- 攻击
function Enemy:attacking()
Enemy.super.attacking(self)
end
-- 受到攻击
function Enemy:underAttack()
Enemy.super.underAttack(self)
if (self.m_nState == FigureState.Death) then
return
end
if (self.m_attackMonomerMajor) then
return
end
self:detectionWhetherCounter()
end
-- 设置人物状态
function Enemy:setFigureState(nState, nDirection)
Enemy.super.setFigureState(self, nState, nDirection)
end
function Enemy:getDenPos()
return self.m_denPos
end
function Enemy:setDenPos(mpoint)
self.m_denPos = mpoint
end
function Enemy:getEnemyID()
return self.m_enemyID
end
function Enemy:getActive()
return self.m_isActive
end
function Enemy:setActive(bActive)
self.m_isActive = bActive
end
return Enemy
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/figure/Figure.lua
================================================
local TextureController = require("app.figure.TextureController")
local TAG_ANIMATE = 0xfffff0
-- 人物方向
FigureDirection = {
Up = 8, -- 上
LeftAndUp = 7, -- 左上
Left = 6, -- 左
LeftAndDown = 5, -- 左下
Down = 4, -- 下
RightAndDown = 3, -- 右下
Right = 2, -- 右
RightAndUp = 1, -- 右上
None = 0
}
-- 人物状态
FigureState = {
Death = 7, -- 死亡
Hurt = 6, -- 伤害
Caster = 5, -- 投掷
Attack = 4, -- 攻击
Run = 3, -- 跑
Walk = 2, -- 走
Stand = 1,
None = 0
}
-- 人物类
local Figure = class("Figure", function()
return display.newSprite()
end)
function Figure:ctor(nType, nFigureNum)
self.m_nState = FigureState.Stand
self.m_nDirection = FigureDirection.Down
self.m_nFrameRate = 0.5
self.m_nTexturePathType = nType
self.m_nFigureNum = math.floor(nFigureNum)
self.m_nHairNum = 0
self.m_nWeaponNum = 0
self.m_spHair = nil
self.m_spWeapon = nil
self.m_pDelegate = nil
TextureController.addSpriteFrames(self.m_nTexturePathType, self.m_nFigureNum, handler(self, self.updateFigure))
local point = cc.PointMult(cc.p(256, 256), 0.8)
self:setContentSize(point.x, point.y)
end
-- 设置头发
function Figure:setHair(nHairNum)
nHairNum = math.floor(nHairNum)
if (self.m_spHair ~= nil) then
self.m_spHair:removeFromParent()
TextureController.subSpriteFrames(TexturePathType.Hair, self.m_nHairNum)
self.m_spHair = nil
self.m_nHairNum = 0
end
if (self.m_nTexturePathType == TexturePathType.Monster) then
return
end
self.m_nHairNum = nHairNum * 10 + self.m_nFigureNum % 10
if (0 == self.m_nHairNum) then
return
end
TextureController.addSpriteFrames(TexturePathType.Hair, self.m_nHairNum, handler(self, self.updateFigure))
self.m_spHair = CCSprite:create()
self.m_spHair:setPosition(128*0.8, 128*0.8)
self:addChild(self.m_spHair, 1, 999)
end
-- 设置武器
function Figure:setWeapon(nWeaponNum)
if (self.m_spWeapon ~= nil) then
self.m_spWeapon:removeFromParent()
TextureController.subSpriteFrames(TexturePathType.Weapon, self.m_nWeaponNum)
self.m_spWeapon = nil
self.m_nWeaponNum = 0
end
if (self.m_nTexturePathType == TexturePathType.Monster) then
return
end
self.m_nWeaponNum = nWeaponNum
if (0 == self.m_nWeaponNum) then
return
end
TextureController.addSpriteFrames(TexturePathType.Weapon, self.m_nWeaponNum, handler(self, self.updateFigure))
self.m_spWeapon = CCSprite:create()
self.m_spWeapon:setPosition(128*0.8, 128*0.8)
self:addChild(self.m_spWeapon, 0, 888)
end
-- 设置状态和方向
function Figure:setFigureState(nState, nDirection)
local bIsChange = false
if (nState and nState ~= FigureState.None and nState ~= self.m_nState) then
self.m_nState = nState
bIsChange = true
end
if (nDirection and nDirection ~= FigureDirection.None and nDirection ~= self.m_nDirection) then
self.m_nDirection = nDirection
bIsChange = true
end
if (bIsChange) then
self:updateFigure()
end
end
local function getFrameRate(nState, nType)
local nFrameRate = 0
if (nType == TexturePathType.Figure) then
if (nState == FigureState.Stand) then
nFrameRate = 1/3.0
elseif (nState == FigureState.Walk) then
nFrameRate = 0.6/16.0
elseif (nState == FigureState.Run) then
nFrameRate = 0.6/16.0
elseif (nState == FigureState.Attack) then
nFrameRate = 1/8.0
elseif (nState == FigureState.Caster) then
nFrameRate = 1/8.0
elseif (nState == FigureState.Hurt) then
nFrameRate = 1/8.0
elseif (nState == FigureState.Death) then
nFrameRate = 1/4.0
end
end
if (nType == TexturePathType.Monster) then
if (nState == FigureState.Stand) then
nFrameRate = 1/5.0
elseif (nState == FigureState.Walk) then
nFrameRate = 0.6/8.0
elseif (nState == FigureState.Run) then
nFrameRate = 0.6/8.0
elseif (nState == FigureState.Attack) then
nFrameRate = 1/8.0
elseif (nState == FigureState.Caster) then
nFrameRate = 1/8.0
elseif (nState == FigureState.Hurt) then
nFrameRate = 1/8.0
elseif (nState == FigureState.Death) then
nFrameRate = 1/8.0
end
end
return nFrameRate
end
-- 更新人物状态
function Figure:updateFigure()
self.m_nFrameRate = getFrameRate(self.m_nState, self.m_nTexturePathType)
if (self.m_nDirection == FigureDirection.Left or
self.m_nDirection == FigureDirection.LeftAndUp or
self.m_nDirection == FigureDirection.LeftAndDown) then
self:setRotationY(180)
else
self:setRotationY(0)
end
if (self.m_spWeapon) then
if (self.m_nDirection == FigureDirection.Up) then
self.m_spWeapon:setZOrder(-1)
else
self.m_spWeapon:setZOrder(0)
end
end
self:runActions()
end
function Figure:runActions()
self:stopActionByTag(TAG_ANIMATE)
local figurePath = TextureController.getTexturePath(self.m_nTexturePathType, self.m_nFigureNum)
local animate = self:getRunActionsFromSprite(figurePath)
if (self.m_nState == FigureState.Attack) then
local delayTime = cc.DelayTime:create(animate:getDuration()/2)
local callFunc1 = cc.CallFunc:create(handler(self, self.attacking))
local callFunc2 = cc.CallFunc:create(handler(self, self.attackCompleted))
local array = CCArray:create()
array:addObject(delayTime)
array:addObject(callFunc1)
array:addObject(delayTime)
array:addObject(callFunc2)
self:runAction(cc.Sequence:create(array))
animate:setTag(TAG_ANIMATE)
self:runAction(animate)
elseif (self.m_nState == FigureState.Caster) then
local delayTime = cc.DelayTime:create(animate:getDuration()/2)
local callFunc1 = cc.CallFunc:create(handler(self, self.attacking))
local callFunc2 = cc.CallFunc:create(handler(self, self.attackCompleted))
local array = CCArray:create()
array:addObject(delayTime)
array:addObject(callFunc1)
array:addObject(delayTime)
array:addObject(callFunc2)
self:runAction(cc.Sequence:create(array))
animate:setTag(TAG_ANIMATE)
self:runAction(animate)
elseif (self.m_nState == FigureState.Hurt) then
local array = CCArray:create()
array:addObject(animate)
array:addObject(cc.CallFunc:create(handler(self, self.hurtCompleted)))
local sequence = cc.Sequence:create(array)
sequence:setTag(TAG_ANIMATE)
self:runAction(sequence)
elseif (self.m_nState == FigureState.Death) then
local array = CCArray:create()
array:addObject(animate)
array:addObject(cc.CallFunc:create(handler(self, self.deathCompleted)))
self:runAction(cc.Sequence:create(array))
else
local repeatForever = cc.RepeatForever:create(animate)
repeatForever:setTag(TAG_ANIMATE)
self:runAction(repeatForever)
end
if (self.m_spHair) then
self.m_spHair:stopAllActions()
local path = TextureController.getTexturePath(TexturePathType.Hair, self.m_nHairNum)
local animate = self:getRunActionsFromSprite(path)
if (self.m_nState > 3) then
self.m_spHair:runAction(animate)
else
self.m_spHair:runAction(cc.RepeatForever:create(animate))
end
end
if (self.m_spWeapon) then
self.m_spWeapon:stopAllActions()
local path = TextureController.getTexturePath(TexturePathType.Weapon, self.m_nWeaponNum)
if (self.m_nState == FigureState.Death) then
path = path .. string.sub(figurePath, -1)
else
path = path .. "0"
end
local animate = self:getRunActionsFromSprite(path)
if (self.m_nState > 3) then
self.m_spWeapon:runAction(animate)
else
self.m_spWeapon:runAction(cc.RepeatForever:create(animate))
end
end
end
function Figure:getRunActionsFromSprite(path)
local nDirection = self.m_nDirection
if (8 > nDirection and nDirection > 4) then
nDirection = 8 - nDirection
end
local flag = 0
local array = CCArray:createWithCapacity(8)
while (true) do
local frameName = string.format("%s_%d_%d_%02d.png", path, self.m_nState, nDirection, flag)
local frame = CCSpriteFrameCache:sharedSpriteFrameCache():spriteFrameByName(frameName)
if (not frame) then
break
end
array:addObject(frame)
flag = flag + 1
end
local animation = cc.Animation:createWithSpriteFrames(array, self.m_nFrameRate)
local animate = cc.Animate:create(animation)
return animate
end
function Figure:attacking()
if (self.m_pDelegate) then
self.m_pDelegate:attacking()
end
end
function Figure:attackCompleted()
if (self.m_pDelegate) then
self.m_pDelegate:attackCompleted()
end
end
function Figure:hurtCompleted()
if (self.m_pDelegate) then
self.m_pDelegate:underAttack()
end
end
function Figure:deathCompleted()
if (self.m_pDelegate) then
self.m_pDelegate:deathActionFinish()
end
end
function Figure:setDelegate(delegate)
self.m_pDelegate = delegate
end
-- 脚
function Figure:getAnchorPointWithFoot()
local x = self:getContentSize().width / 2 / self:getContentSize().width
local y = (self:getContentSize().height - 120) / self:getContentSize().height
return cc.p(x, y)
end
-- 手
function Figure:getAnchorPointWithHand()
local x = self:getContentSize().width / 2 / self:getContentSize().width
local y = (self:getContentSize().height - 64) / self:getContentSize().height
return cc.p(x, y)
end
function Figure:getAnchorPointCenter()
return cc.p(0.5, 0.5)
end
-- 设置透明度
function Figure:setOpacityEx(opacity)
self:setOpacity(opacity)
if (self.m_spHair) then
self.m_spHair:setOpacity(opacity)
end
if (self.m_spWeapon) then
self.m_spWeapon:setOpacity(opacity)
end
end
function Figure:getWeaponSprite()
return self.m_spWeapon
end
return Figure
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/figure/Monomer.lua
================================================
local scheduler = require("framework.scheduler")
local Figure = require("app.figure.Figure")
local MapPoint = require("app.map.MapPoint")
local BgMap = require("app.map.BgMap")
local TextureController = require("app.figure.TextureController")
local AttackSkillSystem = require("app.skill_system.AttackSkillSystem")
local SkillEffectShow = require("app.skill_system.SkillEffectShow")
local FlutteringFairy = require("app.game_ui.FlutteringFairy")
TAG_MOVET = 0xfffff1
TAG_FOLLOWATTACK = 0xfffff2
TAG_COOLINGTIMEATTACK = 0xfffff3
TAG_MOVETWAIT = 0xfffff4
MoveInfo = class("MoveInfo")
function MoveInfo:ctor(fTime, mpoint, bIsCanNotFineTheWay)
self.fTime = fTime
self.mpoint = mpoint
self.bIsCanNotFineTheWay = bIsCanNotFineTheWay
end
local Monomer = class("Monomer", function()
return display.newSprite()
end)
function Monomer:ctor()
self.m_nMonomer = nil
self.m_nDirection = FigureDirection.Down
self.m_nState = FigureState.Stand
self.m_attackMonomerMajor = nil
self.m_againstMeSet = {}
self.m_attackTime = 0.5
self.m_fReactionInterval = 0
self.m_bIsCanMoved = true
self.m_runSpeed = 1
self.m_visualRange = 5
self.m_bIsCooling = false
self.m_attackSkillInfo = nil
self.m_blood = 0
self.m_magic = 0
self.m_pTheAttack = 0
self.m_nTexturePathType = TexturePathType.Figure
self.m_nCurRoleNum = 0
self.m_nCurHairNum = 0
self.m_nCurWeaponNum = 0
self.m_nCurEffectID = 0
self.hUpdateVertexZ = 0
self.m_mapAttackSkill = {}
self.m_flutteringFairyDeque = {}
self:addAttackSkill(1001)
self.m_attackSkillInfo = g_attackSkillSystem:getAttackSkillInfo(1001)
self:setNodeEventEnabled(true)
self:setScale(1.0)
end
function Monomer:onEnter()
self:showFigure()
end
function Monomer:onExit()
self:stopAllActions()
self:killTimer_UpdateVertexZ()
end
-- 设置人物
function Monomer:setFigure(nType, nRoleNum)
self.m_nTexturePathType = nType
self.m_nCurRoleNum = nRoleNum
if (self.m_nTexturePathType ~= TexturePathType.Figure) then
self.m_nCurWeaponNum = 0
end
if (self.m_nMonomer) then
self:hideFigure()
self:showFigure()
end
end
-- 设置头发
function Monomer:setHair(nHairNum)
if (self.m_nTexturePathType ~= TexturePathType.Figure) then
return
end
self.m_nCurHairNum = nHairNum
if (self.m_nMonomer) then
self.m_nMonomer:setHair(self.m_nCurHairNum)
end
end
-- 设置武器
function Monomer:setWeapon(nWeaponNum)
if (self.m_nTexturePathType ~= TexturePathType.Figure) then
return
end
self.m_nCurWeaponNum = nWeaponNum
if (self.m_nMonomer) then
self.m_nMonomer:setWeapon(self.m_nCurWeaponNum)
end
end
-- 显示人物
function Monomer:showFigure()
if (0 == self.m_nCurRoleNum) then
return
end
if (self.m_nMonomer) then
return
end
self.m_nMonomer = Figure.new(self.m_nTexturePathType, self.m_nCurRoleNum)
self:setContentSize(self.m_nMonomer:getContentSize())
self:setAnchorPoint(self.m_nMonomer:getAnchorPointWithFoot())
local size = self:getContentSize()
self.m_nMonomer:setPosition(size.width/2, size.height/2)
self:addChild(self.m_nMonomer)
self.m_nMonomer:setDelegate(self)
self.m_nMonomer:setHair(self.m_nCurHairNum)
self.m_nMonomer:setWeapon(self.m_nCurWeaponNum)
self.m_nMonomer:setFigureState(self.m_nState, self.m_nDirection)
local ptBlood = cc.p(size.width * self:getAnchorPoint().x, size.height * 0.8)
self.bloodBg = display.newSprite("blood_box.png")
self.bloodBg:setAnchorPoint(cc.p(0.5, 0.5))
self.bloodBg:setPosition(ptBlood)
self.bloodBg:setScale(0.3)
self:addChild(self.bloodBg)
self.bloodIn = display.newSprite("blood_in.png")
self.bloodIn:setAnchorPoint(cc.p(0, 0))
self.bloodBg:addChild(self.bloodIn)
end
-- 隐藏人物
function Monomer:hideFigure()
if (not self.m_nMonomer) then
return
end
self.m_nMonomer:removeFromParent()
self.m_nMonomer = nil
self.bloodBg:removeFromParent()
end
-- 设置人物状态
function Monomer:setFigureState(nState, nDirection)
if (self.m_nState == FigureState.Death) then
return
end
if (nState ~= FigureState.None) then
self.m_nState = nState
end
if (nDirection ~= FigureDirection.None) then
self.m_nDirection = nDirection
end
if (self.m_nMonomer) then
self.m_nMonomer:setFigureState(nState, nDirection)
end
end
-- 脚
function Monomer:getHandPointRelativeFootOffset()
local anchorPoint
if (self.m_nMonomer) then
anchorPoint = cc.PointSub(self.m_nMonomer:getAnchorPointWithHand(), cc.p(self:getAnchorPoint()))
else
anchorPoint = cc.p(0.5, 0.5)
end
local szContent = self:getContentSize()
return cc.p(szContent.width * anchorPoint.x, szContent.height * anchorPoint.y)
end
-- 手
function Monomer:getHandPoint()
local handRelativeFoot = self:getHandPointRelativeFootOffset()
local point = cc.p(self:getPosition())
return cc.PointAdd(point, handRelativeFoot)
end
function Monomer:getHurtPointRelativeFootOffset()
local anchorPoint
if (self.m_nMonomer) then
anchorPoint = cc.PointSub(self.m_nMonomer:getAnchorPointCenter(), cc.p(self:getAnchorPoint()))
else
anchorPoint = cc.p(0.5, 0.5)
end
local szContent = self:getContentSize()
return cc.p(szContent.width * anchorPoint.x, szContent.height * anchorPoint.y)
end
function Monomer:getHurtPoint()
local hurtRelativeFoot = self:getHurtPointRelativeFootOffset()
local point = cc.p(self:getPosition())
return cc.PointAdd(point, hurtRelativeFoot)
end
function Monomer:getAgainstMeOfFirst()
if (#self.m_againstMeSet <= 0) then
return nil
end
return self.m_againstMeSet[1]
end
function Monomer:getRect()
local ptPos = cc.p(self:getPosition())
local szContent = self:getContentSize()
local ptAnchor = self:getAnchorPoint()
local off_x = szContent.width * 0.4
local off_y = szContent.height * ptAnchor.y * 0.5
local width = szContent.width * 0.3
local height = szContent.height * 0.6
local rect = cc.rect(0,0,0,0)
rect.origin = cc.p(off_x, off_y)
rect.size = cc.size(width, height)
local x = szContent.width * ptAnchor.x
local y = szContent.height * ptAnchor.y
local point = cc.p(x, y)
point = cc.PointSub(ptPos, point)
local relustRect = rect
relustRect.origin = cc.PointAdd(point, rect.origin)
return relustRect
end
function Monomer:getAlphaWithPoint(point)
return 0
end
-- 走到左面
function Monomer:walkLeft()
self:setFigureState(FigureState.Walk, FigureDirection.Left)
end
-- 走到右面
function Monomer:walkRight()
self:setFigureState(FigureState.Walk, FigureDirection.Right)
end
-- 走到上面
function Monomer:walkUp()
self:setFigureState(FigureState.Walk, FigureDirection.Up)
end
-- 走到下面
function Monomer:walkDown()
self:setFigureState(FigureState.Walk, FigureDirection.Down)
end
-- 走到左上
function Monomer:walkLeftAndUp()
self:setFigureState(FigureState.Walk, FigureDirection.LeftAndUp)
end
-- 走到右上
function Monomer:walkRightAndUp()
self:setFigureState(FigureState.Walk, FigureDirection.RightAndUp)
end
-- 走到右下
function Monomer:walkRightAndDown()
self:setFigureState(FigureState.Walk, FigureDirection.RightAndDown)
end
-- 走到左下
function Monomer:walkLeftAndDown()
self:setFigureState(FigureState.Walk, FigureDirection.LeftAndDown)
end
-- 跑到左面
function Monomer:runLeft()
self:setFigureState(FigureState.Run, FigureDirection.Left)
end
-- 跑到右面
function Monomer:runRight()
self:setFigureState(FigureState.Run, FigureDirection.Right)
end
-- 跑到上面
function Monomer:runUp()
self:setFigureState(FigureState.Run, FigureDirection.Up)
end
-- 跑到下面
function Monomer:runDown()
self:setFigureState(FigureState.Run, FigureDirection.Down)
end
-- 跑到左上
function Monomer:runLeftAndUp()
self:setFigureState(FigureState.Run, FigureDirection.LeftAndUp)
end
-- 跑到右上
function Monomer:runRightAndUp()
self:setFigureState(FigureState.Run, FigureDirection.RightAndUp)
end
-- 跑到右下
function Monomer:runRightAndDown()
self:setFigureState(FigureState.Run, FigureDirection.RightAndDown)
end
-- 跑到左下
function Monomer:runLeftAndDown()
self:setFigureState(FigureState.Run, FigureDirection.LeftAndDown)
end
function Monomer:stand()
self:setFigureState(FigureState.Stand, FigureDirection.None)
end
-- 伤害
function Monomer:hurt()
if (self:getState() ~= FigureState.Death) then
self:setFigureState(FigureState.Hurt, FigureDirection.None)
end
end
-- 死亡
function Monomer:death()
if (self:getState() ~= FigureState.Death) then
self.m_nMonomer:stopAllActions()
--self.m_nMonomer:unscheduleAllSelectors()
self:stopAllActions()
--self:unscheduleAllSelectors()
self:setFigureState(FigureState.Death, FigureDirection.None)
self:clearData()
end
end
function Monomer:playEffect(node, path)
if ((not node) or (not path) or (path == "")) then
return
end
local array = CCArray:createWithCapacity(64)
local flag = 4
while (true) do
local fileName = string.format("%s%04d.png", path, flag)
local spriteFrame = CCSpriteFrameCache:sharedSpriteFrameCache():spriteFrameByName(fileName)
if (not spriteFrame) then
break
end
array:addObject(spriteFrame)
flag = flag + 1
end
if (array:count() == 0) then
return
end
local sprite = CCSprite:createWithSpriteFrame(array:objectAtIndex(0))
local x = self:getContentSize().width * self:getAnchorPoint().x
local y = self:getContentSize().height * 0.65
sprite:setPosition(x, y)
node:addChild(sprite, 1000)
local animation = cc.Animation:createWithSpriteFrames(array, 1 / 32)
local animate = cc.Animate:create(animation)
local callFunc = cc.CallFunc:create(handler(sprite, sprite.removeFromParent))
local array = CCArray:create()
array:addObject(animate)
array:addObject(callFunc)
local sequence = cc.Sequence:create(array)
sprite:runAction(sequence)
end
-- 恢复血量
function Monomer:bloodReturn(fBlood)
local blood = math.min(self:getBlood() + fBlood, self:getBloodCap())
self:setBlood(blood)
self:updateBloodProgress()
local point = cc.p(0, self:getContentSize().height * 0.5)
local fairy = FlutteringFairy.addFairy(self, point, TypeAddBlood, fBlood, handler(self, self.flutteringFairyFinish))
self:pushFlutteringFairy(fairy)
self:playEffect(self, "addh-")
end
function Monomer:followAttack()
self:stopActionByTag(TAG_FOLLOWATTACK)
if (not self.m_attackMonomerMajor) then
self:beyondVisualRange()
return
end
if (self.m_attackMonomerMajor:getState() == FigureState.Death) then
self:beyondVisualRange()
return
end
if (self:isInTheAttackRange(self.m_attackMonomerMajor)) then -- 敌人在攻击范围内
self:attackEnemy()
elseif (self:isInTheFieldOfView(self.m_attackMonomerMajor)) then -- 敌人在可视范围内
self:followTheTracks()
else
self:beyondVisualRange()
end
end
function Monomer:followTheTracks()
local mpoint = self.m_attackMonomerMajor:ownAttackPoint(self, self.m_attackSkillInfo.m_attackDistance)
if (mpoint:equalsObj(MapPoint.new(0, 0))) then
return
end
local point = cc.p(self:getPosition())
local mpos = MapPoint.new(point)
mpoint = MapPoint.sub(mpoint, mpos)
local relust = self:runBy(mpoint)
if (relust.fTime == 0) then
return
end
local fTime = self.m_fReactionInterval + relust.fTime + 0.01
self:delayCallBack(fTime, handler(self, self.followAttack)):setTag(TAG_FOLLOWATTACK)
end
function Monomer:isInTheAttackRange(monomer)
local pos1 = cc.p(self:getPosition())
local pos2 = cc.p(monomer:getPosition())
local mpos1 = MapPoint.new(pos1)
local mpos2 = MapPoint.new(pos2)
local attackRange = self.m_attackSkillInfo.m_attackDistance
if (mpos1:getDistance(mpos2) > attackRange) then
return false
end
if (mpos1:equalsObj(mpos2)) then
return false
end
if (self:isMoveRunning()) then
return false
end
return true
end
function Monomer:isInTheFieldOfView(monomer)
local pos1 = cc.p(self:getPosition())
local pos2 = cc.p(monomer:getPosition())
local mpos1 = MapPoint.new(pos1)
local mpos2 = MapPoint.new(pos2)
if (mpos1:getDistance(mpos2) <= self.m_visualRange) then
return true
end
return false
end
function Monomer:beyondVisualRange()
self:setAttackMonomerMajor(nil)
end
function Monomer:clearData()
self.m_flutteringFairyDeque = {}
for i = 1, #self.m_againstMeSet do
local monomer = self.m_againstMeSet[i]
monomer:removeAttackMonomerMajor(self)
end
self.m_againstMeSet = {}
if (self.m_attackMonomerMajor) then
self.m_attackMonomerMajor:removeAgainstMe(self)
self:setAttackMonomerMajor(nil)
end
end
function Monomer:followAttackAndSetAttackMethods(otherEnemy, nAttackSkillNum)
if (nAttackSkillNum ~= 0) then
if (not self.m_mapAttackSkill[nAttackSkillNum]) then
return
end
self.m_attackSkillInfo = self.m_mapAttackSkill[nAttackSkillNum]
end
if (not otherEnemy) then
return
end
if (self:getState() == FigureState.Death) then
return
end
self:setAttackMonomerMajor(otherEnemy)
self:followAttack()
end
function Monomer:ownAttackPoint(monomer, attackRange)
local relust = MapPoint.new(0, 0)
local mpos1 = MapPoint.new(cc.p(self:getPosition()))
local mpos2 = MapPoint.new(cc.p(monomer:getPosition()))
local lenght = math.min(mpos1:getDistance(mpos2), attackRange)
if (attackRange == 1) then
relust = mpos1
else
local x = -lenght
local z = -lenght
local arrMPoint = {}
while (true) do
if (#arrMPoint == 8*lenght) then
break
end
table.insert(arrMPoint, MapPoint.new(x, z))
if (#arrMPoint <= 2*lenght) then
x = x + 1
elseif (2*lenght < #arrMPoint and #arrMPoint <= 4*lenght) then
z = z + 1
elseif (4*lenght < #arrMPoint and #arrMPoint <= 6*lenght) then
x = x - 1
elseif (6*lenght < #arrMPoint and #arrMPoint < 8*lenght) then
z = z - 1
end
end
local l = 0xffff
for i = 1, #arrMPoint do
local mpoint = MapPoint.add(mpos2, arrMPoint[i])
if ((not g_mainScene:isPointValid(mpoint)) or (mpoint:getDistance(mpos1) >= l)) then
else
relust = mpoint
l = mpoint:getDistance(mpos1)
end
end
end
return relust
end
--function Monomer:standAndWatch(MapPoint point)
--{
-- M_INT lenghtX = mapSub(point, MapPoint(m_obPosition)).x;
-- M_INT lenghtY = mapSub(point, MapPoint(m_obPosition)).z;
-- float lenght = sqrtf(pow(lenghtX, 2) + pow(lenghtY, 2));
-- float pointX = lenghtX / lenght;
-- float pointY = lenghtY / lenght;
-- float angle_X = acosf(pointX) * 180 / M_PI;
-- float angle_Y = acosf(pointY) * 180 / M_PI;
--
-- float angle = angle_X;
-- if (angle_Y > 90)
-- {
-- angle = 360 - angle_X;
-- }
--
-- FigureDirectionType dirType = this->getDirectionType(angle);
--
-- this->setFigureState(FStateStand, dirType);
--}
function Monomer:isMoveRunning()
local x, y = self:getPosition()
local pos = cc.p(x, y)
local mpos = MapPoint.new(pos)
return (cc.PointDistance(mpos:getCCPointValue(), pos) >= 5.0)
end
function Monomer:actionsWithPoint(startMPoint, endMPoint)
local callFunc = nil
local array = CCArray:create()
if (startMPoint:equalsObj(endMPoint)) then
return array
end
local lenghtX = endMPoint.x - startMPoint.x
local lenghtY = endMPoint.z - startMPoint.z
local lenght = math.sqrt(lenghtX * lenghtX + lenghtY * lenghtY)
local gridNumber = startMPoint:getDistance(endMPoint)
local fTime = 0.6 * startMPoint:getDistance(endMPoint) / self.m_runSpeed / gridNumber
local pointX = lenghtX / lenght
local pointY = lenghtY / lenght
local angle_X = math.acos(pointX) * 180 / math.pi
local angle_Y = math.acos(pointY) * 180 / math.pi
local angle = angle_X
if (angle_Y > 90) then
angle = 360 - angle_X
end
local nType = math.floor(((angle + 22.5) % 360 ) / 45.0)
if (lenght < 2) then
if (nType == 0) then
callFunc = cc.CallFunc:create(handler(self, self.walkRight))
elseif (nType == 1) then
callFunc = cc.CallFunc:create(handler(self, self.walkRightAndUp))
elseif (nType == 2) then
callFunc = cc.CallFunc:create(handler(self, self.walkUp))
elseif (nType == 3) then
callFunc = cc.CallFunc:create(handler(self, self.walkLeftAndUp))
elseif (nType == 4) then
callFunc = cc.CallFunc:create(handler(self, self.walkLeft))
elseif (nType == 5) then
callFunc = cc.CallFunc:create(handler(self, self.walkLeftAndDown))
elseif (nType == 6) then
callFunc = cc.CallFunc:create(handler(self, self.walkDown))
elseif (nType == 7) then
callFunc = cc.CallFunc:create(handler(self, self.walkRightAndDown))
end
else
if (nType == 0) then
callFunc = cc.CallFunc:create(handler(self, self.runRight))
elseif (nType == 1) then
callFunc = cc.CallFunc:create(handler(self, self.runRightAndUp))
elseif (nType == 2) then
callFunc = cc.CallFunc:create(handler(self, self.runUp))
elseif (nType == 3) then
callFunc = cc.CallFunc:create(handler(self, self.runLeftAndUp))
elseif (nType == 4) then
callFunc = cc.CallFunc:create(handler(self, self.runLeft))
elseif (nType == 5) then
callFunc = cc.CallFunc:create(handler(self, self.runLeftAndDown))
elseif (nType == 6) then
callFunc = cc.CallFunc:create(handler(self, self.runDown))
elseif (nType == 7) then
callFunc = cc.CallFunc:create(handler(self, self.runRightAndDown))
end
end
array:addObject(callFunc)
local moveTo = cc.MoveTo:create(fTime, endMPoint:getCCPointValue())
array:addObject(moveTo)
return array
end
function Monomer:actionsWithMoveTo(dequeMapPoint)
local array = CCArray:createWithCapacity(8)
if (#dequeMapPoint <= 1) then
return array
end
local callFunc1 = cc.CallFunc:create(handler(self, self.setTimer_UpdateVertexZ))
local callFunc2 = cc.CallFunc:create(handler(self, self.killTimer_UpdateVertexZ))
array:addObject(callFunc1)
for i = 2, #dequeMapPoint do
local startMPoint = dequeMapPoint[i-1]
local endMPoint = dequeMapPoint[i]
array:addObjectsFromArray(self:actionsWithPoint(startMPoint, endMPoint))
end
array:addObject(callFunc2)
return array
end
-- 跑
function Monomer:runBy(mpoint)
local pos = cc.p(self:getPosition())
local relust = MoveInfo.new(0.0, MapPoint.new(pos), false)
if (self.m_bIsCanMoved == false) then
return relust
end
local nState = self:getState()
if (nState == FigureState.Death or
nState == FigureState.Attack or
nState == FigureState.Caster or
nState == FigureState.Hurt) then
return relust
end
if (self:isMoveRunning()) then
return relust
end
self:stopActionByTag(TAG_MOVET)
self:stopActionByTag(TAG_FOLLOWATTACK)
self:stopActionByTag(TAG_COOLINGTIMEATTACK)
local mpos = MapPoint.new(pos)
local dequeMPoint = g_mainScene:getPathNextRunGrid(mpos, MapPoint.add(mpos, mpoint))
if (#dequeMPoint <= 1) then
self:stand()
relust.bIsCanNotFineTheWay = true
return relust
end
local array = self:actionsWithMoveTo(dequeMPoint)
local callFunc = cc.CallFunc:create(handler(self, self.moveByBegin))
local callFunc2 = cc.CallFunc:create(handler(self, self.moveByEnd))
array:insertObject(callFunc, 0)
array:addObject(callFunc2)
local sequence = cc.Sequence:create(array)
sequence:setTag(TAG_MOVET)
self:runAction(sequence)
relust.fTime = sequence:getDuration()
relust.mpoint = dequeMPoint[#dequeMPoint]
return relust
end
-- 走
function Monomer:walkBy(mpoint)
local pos = cc.p(self:getPosition())
local relust = MoveInfo.new(0.0, MapPoint.new(pos), false)
if (self.m_bIsCanMoved == false) then
return relust
end
local nState = self:getState()
if (nState == FigureState.Death or
nState == FigureState.Attack or
nState == FigureState.Caster or
nState == FigureState.Hurt) then
return relust
end
if (self:isMoveRunning()) then
return relust
end
self:stopActionByTag(TAG_MOVET)
self:stopActionByTag(TAG_FOLLOWATTACK)
self:stopActionByTag(TAG_COOLINGTIMEATTACK)
local mpos = MapPoint.new(pos)
local dequeMPoint = g_mainScene:getPathNextWalkGrid(mpos, MapPoint.add(mpos, mpoint))
if (#dequeMPoint <= 1) then
self:stand()
relust.bIsCanNotFineTheWay = true
return relust
end
local array = self:actionsWithMoveTo(dequeMPoint)
local callFunc = cc.CallFunc:create(handler(self, self.moveByBegin))
local callFunc2 = cc.CallFunc:create(handler(self, self.moveByEnd))
array:insertObject(callFunc, 0)
array:addObject(callFunc2)
local sequence = cc.Sequence:create(array)
sequence:setTag(TAG_MOVET)
self:runAction(sequence)
relust.fTime = sequence:getDuration()
relust.mpoint = dequeMPoint[#dequeMPoint]
return relust
end
-- 去到指定点
function Monomer:goTo(mpoint)
local pos = cc.p(self:getPosition())
local relust = MoveInfo.new(0.0, MapPoint.new(pos), false)
if (self.m_bIsCanMoved == false) then
return relust
end
local nState = self:getState()
if (nState == FigureState.Death or
nState == FigureState.Attack or
nState == FigureState.Caster or
nState == FigureState.Hurt) then
return relust
end
if (self:isMoveRunning()) then
return relust
end
self:stopActionByTag(TAG_MOVET)
self:stopActionByTag(TAG_FOLLOWATTACK)
self:stopActionByTag(TAG_COOLINGTIMEATTACK)
local begin = MapPoint.new(pos)
local dequeMPoint = g_mainScene:getPath(begin, mpoint)
if (#dequeMPoint <= 1) then
self:stand()
relust.bIsCanNotFineTheWay = true
return relust
end
local array = self:actionsWithMoveTo(dequeMPoint)
local callFunc = cc.CallFunc:create(handler(self, self.goBegin))
local callFunc2 = cc.CallFunc:create(handler(self, self.goEnd))
array:insertObject(callFunc, 0)
array:addObject(callFunc2)
local sequence = cc.Sequence:create(array)
sequence:setTag(TAG_MOVET)
self:runAction(sequence)
relust.fTime = sequence:getDuration()
relust.mpoint = dequeMPoint[#dequeMPoint]
return relust
end
-- 启动更新Z轴计时器
function Monomer:setTimer_UpdateVertexZ()
self:killTimer_UpdateVertexZ()
self.hUpdateVertexZ = scheduler.scheduleGlobal(handler(self, self.updateVertexZ), 0.1)
end
-- 关闭更新Z轴计时器
function Monomer:killTimer_UpdateVertexZ()
if (self.hUpdateVertexZ) then
scheduler.unscheduleGlobal(self.hUpdateVertexZ)
self.hUpdateVertexZ = nil
end
end
-- 更新Z轴计时器回调函数
function Monomer:updateVertexZ(fDelay)
local point = cc.p(self:getPosition())
local value = BgMap.getZOrder(point) -- z轴
self:setZOrder(value)
if (not self.m_nMonomer) then
return
end
if (g_mainScene:getCurrBgMap():getCurrentGridValue(MapPoint.new(point)) == 2) then
if (self.m_nMonomer:getOpacity() == 128) then
return
end
self.m_nMonomer:setOpacityEx(128)
self.m_nMonomer:setColor(ccc3(166,166,166))
else
if (self.m_nMonomer:getOpacity() == 255) then
return
end
self.m_nMonomer:setOpacityEx(255)
self.m_nMonomer:setColor(ccc3(255,255,255))
end
end
-- 添加攻击技能
function Monomer:addAttackSkill(skillNumber)
local skillInfo = g_attackSkillSystem:getAttackSkillInfo(skillNumber)
if (skillInfo) then
self.m_mapAttackSkill[skillInfo.m_nNum] = skillInfo
TextureController.addSpriteFrames(TexturePathType.SkillCaster, skillInfo.m_casterSpecificID)
TextureController.addSpriteFrames(TexturePathType.SkillLocus, skillInfo.m_locusSpecificID)
TextureController.addSpriteFrames(TexturePathType.SkillExplosion, skillInfo.m_explosionSpecificID)
end
end
-- 删除攻击技能
function Monomer:subAttackSkill(skillNumber)
local skillInfo = self.m_mapAttackSkill[skillNumber]
if (skillInfo) then
TextureController.subSpriteFrames(TexturePathType.SkillCaster, skillInfo.m_casterSpecificID)
TextureController.subSpriteFrames(TexturePathType.SkillLocus, skillInfo.m_locusSpecificID)
TextureController.subSpriteFrames(TexturePathType.SkillExplosion, skillInfo.m_explosionSpecificID)
end
end
function Monomer:moveByBegin()
end
function Monomer:moveByEnd()
self:stand()
end
function Monomer:goBegin()
end
function Monomer:goEnd()
self:stand()
end
-- 攻击敌人
function Monomer:attackEnemy()
if (not self.m_attackMonomerMajor) then
return false
end
if (self.m_isCooling) then
return false
end
self.m_isCooling = true
self:stopActionByTag(TAG_MOVET)
local nState = FigureState.Attack
if (not self.m_attackSkillInfo) then
self.m_attackSkillInfo = self.m_mapAttackSkill[1]
end
if (self.m_attackSkillInfo.m_nAttackType == 2) then
nState = FigureState.Caster
end
local lenghtX = self.m_attackMonomerMajor:getPositionX() - self:getPositionX()
local lenghtY = (self.m_attackMonomerMajor:getPositionY() - self:getPositionY()) * math.sqrt(2)
local lenght = math.sqrt(lenghtX * lenghtX + lenghtY * lenghtY)
local pointX = lenghtX / lenght
local pointY = lenghtY / lenght
local angle_X = math.acos(pointX) * 180 / math.pi
local angle_Y = math.acos(pointY) * 180 / math.pi
local angle = angle_X
if (angle_Y > 90) then
angle = 360 - angle_X
end
local nDirection = self:getDirectionType(angle)
self:setFigureState(nState, nDirection)
return true
end
-- 根据指定角度获取方向
function Monomer:getDirectionType(fAngle)
local nDirection = FigureDirection.None
local nType = math.floor(((math.floor(fAngle + 22.5)) % 360 ) / 45.0)
if (nType == 0) then
nDirection = FigureDirection.Right
elseif (nType == 1) then
nDirection = FigureDirection.RightAndUp
elseif (nType == 2) then
nDirection = FigureDirection.Up
elseif (nType == 3) then
nDirection = FigureDirection.LeftAndUp
elseif (nType == 4) then
nDirection = FigureDirection.Left
elseif (nType == 5) then
nDirection = FigureDirection.LeftAndDown
elseif (nType == 6) then
nDirection = FigureDirection.Down
elseif (nType == 7) then
nDirection = FigureDirection.RightAndDown
end
return nDirection
end
function Monomer:setCoolingFalse()
self.m_isCooling = false
end
function Monomer:addAgainstMe(monomer, fBlood)
if (self:getState() == FigureState.Death) then
return
end
if (monomer:getState() == FigureState.Death) then
return
end
local fairy = FlutteringFairy.addFairy(self, cc.p(0, self:getContentSize().height * 0.5), FairyType.SubBlood, self.m_blood-fBlood, handler(self, self.flutteringFairyFinish))
self:pushFlutteringFairy(fairy)
self:setBlood(fBlood)
self:updateBloodProgress()
local bFind = false
for i = 1, #self.m_againstMeSet do
local m = self.m_againstMeSet[i]
if (m == monomer) then
bFind = true
break
end
end
if (not bFind) then
table.insert(self.m_againstMeSet, monomer)
end
if (self.m_blood > 0) then
return
end
self:death()
end
function Monomer:detectionOfEachOther()
end
function Monomer:pushFlutteringFairy(fairy)
if (#self.m_flutteringFairyDeque > 0) then
for i = 1, #self.m_flutteringFairyDeque do
local lastFairy = self.m_flutteringFairyDeque[i]
local y = 30
if (y > 0) then
local moveBy = cc.MoveBy:create(0.15, cc.p(0, y))
lastFairy:runAction(moveBy)
end
end
end
table.insert(self.m_flutteringFairyDeque, fairy)
end
function Monomer:flutteringFairyFinish()
if (#self.m_flutteringFairyDeque > 0) then
table.remove(self.m_flutteringFairyDeque, 1)
end
end
function Monomer:detectionWhetherCounter()
end
-- 更新血条
function Monomer:updateBloodProgress()
if (not self.bloodBg) then
return
end
local rect = cc.rect(0,0,0,0)
rect.size = cc.size(self.bloodBg:getContentSize().width*self.m_blood/self.m_bloodCap, self.bloodIn:getContentSize().height)
rect.size.width = math.max(rect.size.width, 0)
self.bloodIn:setTextureRect(rect)
end
function Monomer:removeAttackMonomerMajor(monomer)
if (monomer == self.m_attackMonomerMajor) then
self:setAttackMonomerMajor(nil)
end
end
function Monomer:removeAgainstMe(monomer)
for i = 1, #self.m_againstMeSet do
local m = self.m_againstMeSet[i]
if (m == monomer) then
table.remove(self.m_againstMeSet, i)
return
end
end
end
function Monomer:delayCallBack(fTime, callFunc)
fTime = math.max(fTime, 0.0)
local array = CCArray:create()
array:addObject(cc.DelayTime:create(fTime))
array:addObject(cc.CallFunc:create(callFunc))
local sequence = cc.Sequence:create(array)
self:runAction(sequence)
return sequence
end
function Monomer:attacking()
SkillEffectShow.playSkillEffect(self.m_attackSkillInfo, self, self.m_attackMonomerMajor, 0)
end
function Monomer:underAttack()
self:setFigureState(FigureState.Stand, FigureDirection.None)
end
function Monomer:attackCompleted()
self:setFigureState(FigureState.Stand, FigureDirection.None)
self:delayCallBack(self.m_attackTime, handler(self, self.setCoolingFalse))
self:delayCallBack(self.m_attackTime, handler(self, self.detectionOfEachOther)):setTag(TAG_FOLLOWATTACK)
end
function Monomer:deathActionFinish()
self:setZOrder(BgMap.getZOrderZero(g_mainScene:getCurrBgMap())) -- z轴
end
function Monomer:getFigure()
return self.m_nMonomer
end
function Monomer:getState()
return self.m_nState
end
function Monomer:getDirection()
return self.m_nDirection
end
function Monomer:getCanMoved()
return self.m_isCanMoved
end
function Monomer:setCanMoved(bCanMoved)
self.m_isCanMoved = bCanMoved
end
function Monomer:getRunSpeed()
return self.m_runSpeed
end
function Monomer:setRunSpeed(runSpeed)
self.m_runSpeed = runSpeed
end
function Monomer:getVisualRange()
return self.m_visualRange
end
function Monomer:setVisualRange(visualRange)
self.m_visualRange = visualRange
end
function Monomer:getBloodCap()
return self.m_bloodCap
end
function Monomer:setBloodCap(bloodCap)
self.m_bloodCap = bloodCap
end
function Monomer:getMagicCap()
return self.m_magicCap
end
function Monomer:setMagicCap(magicCap)
self.m_magicCap = magicCap
end
function Monomer:getBlood()
return self.m_blood
end
function Monomer:setBlood(blood)
self.m_blood = blood
end
function Monomer:getMagic()
return self.m_magic
end
function Monomer:setMagic(magic)
self.m_magic = m_magic
end
function Monomer:getTheAttack()
return self.m_pTheAttack
end
function Monomer:setTheAttack(pTheAttack)
self.m_pTheAttack = pTheAttack
end
function Monomer:getAttackTime()
return self.m_attackTime
end
function Monomer:setAttackTime(attackTime)
self.m_attackTime = attackTime
end
function Monomer:getAttackMonomerMajor()
return self.m_attackMonomerMajor
end
function Monomer:setAttackMonomerMajor(attackMonomerMajor)
self.m_attackMonomerMajor = attackMonomerMajor
end
return Monomer
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/figure/Player.lua
================================================
local scheduler = require("framework.scheduler")
local MapPoint = require("app.map.MapPoint")
local PlayerController = require("app.figure.PlayerController")
local Monomer = require("app.figure.Monomer")
local GameLoading = require("app.scenes.GameLoading")
local TAG_MOVET = 0xfffff1
local TAG_FOLLOWATTACK = 0xfffff2
local TAG_COOLINGTIMEATTACK = 0xfffff3
local TAG_MOVETWAIT = 0xfffff4
-- 玩家类
local Player = class("Player", Monomer)
function Player:ctor()
Player.super.ctor(self)
self.m_isMoveActions = false
self.m_willGoPoint = MapPoint.new(0, 0)
local _playerController = PlayerController.sharePlayerController()
self:setFigure(TexturePathType.Figure, _playerController.m_playerNumber)
self:setHair(_playerController.m_hairNumber)
self:setWeapon(_playerController.m_weaponsNumber)
self:setTray()
self:setBlood(100000)
self:setBloodCap(100000)
self:setTheAttack(2500)
self:setVisualRange(100)
self:addAttackSkill(1002)
self:addNodeEventListener(cc.NODE_ENTER_FRAME_EVENT, function(...)
self:update_(...)
end)
self:scheduleUpdate()
end
function Player:onEnter()
Player.super.onEnter(self)
end
function Player:onExit()
Player.super.onExit(self)
self:stopAllActions()
g_mainScene:getCurrBgMap():killTimer_UpdateMap()
self:killTimer_DetectionReplaceBgMap()
end
function Player:update_(dt)
if (not self.m_isMoveActions) then
return
end
g_mainScene:getCurrBgMap():updateMap(dt)
self:detectionReplaceBgMap(dt)
end
function Player:setTray()
end
function Player:detectionOfEachOther()
Player.super.detectionOfEachOther(self)
if (self.m_attackMonomerMajor) then
self:detectionWhetherCounter()
end
end
function Player:detectionWhetherCounter()
self:followAttack()
end
function Player:runBy(mpoint)
local relust = Player.super.runBy(self, mpoint)
if (relust.fTime ~= 0) then
g_mainScene:insterMapPoint(self, relust.mpoint)
end
if (relust.fTime == 0 and relust.bIsCanNotFineTheWay == false) then
self.m_willGoPoint = mpoint
self:stopActionByTag(TAG_MOVETWAIT)
self:delayCallBack(1 / 60.0, handler(self, self.waitRunBy)):setTag(TAG_MOVETWAIT)
return relust
end
if (self.m_isMoveActions == false) then
-- g_mainScene:getCurrBgMap():setTimer_UpdateMap()
-- self:setTimer_DetectionReplaceBgMap()
self.m_isMoveActions = true
end
return relust
end
function Player:waitRunBy()
self:runBy(self.m_willGoPoint)
end
function Player:walkBy(mpoint)
local relust = Player.super.walkBy(self, mpoint)
if (relust.fTime ~= 0) then
g_mainScene:insterMapPoint(self, relust.mpoint)
end
if (relust.fTime == 0 and relust.bIsCanNotFineTheWay == false) then
self.m_willGoPoint = mpoint
self:stopActionByTag(TAG_MOVETWAIT)
self:delayCallBack(1 / 60.0, handler(self, self.waitWalkBy)):setTag(TAG_MOVETWAIT)
return relust
end
if (self.m_isMoveActions == false) then
-- g_mainScene:getCurrBgMap():setTimer_UpdateMap()
-- self:setTimer_DetectionReplaceBgMap()
self.m_isMoveActions = true
end
return relust
end
function Player:waitWalkBy()
self:walkBy(self.m_willGoPoint)
end
function Player:goTo(mpoint)
local relust = Player.super.goTo(self, mpoint)
if (relust.fTime ~= 0 and relust.bIsCanNotFineTheWay == false) then
g_mainScene:insterMapPoint(self, relust.mpoint)
else
self.m_willGoPoint = mpoint
self:stopActionByTag(TAG_MOVETWAIT)
self:delayCallBack(1 / 60.0, handler(self, self.waitGoTo)):setTag(TAG_MOVETWAIT)
end
return relust
end
function Player:waitGoTo()
self:goTo(self.m_willGoPoint)
end
function Player:moveByEnd()
if (g_mainScene:getPlayerMoveActions() == false) then
Player.super.moveByEnd(self)
-- g_mainScene:getCurrBgMap():setTimer_UpdateMap()
-- self:setTimer_DetectionReplaceBgMap()
-- self.m_isMoveActions = false
else
g_mainScene:playerRunning()
end
end
function Player:goBegin()
Player.super.goBegin(self)
if (self.m_isMoveActions) then
return
end
-- g_mainScene:getCurrBgMap():setTimer_UpdateMap()
-- self:setTimer_DetectionReplaceBgMap()
self.m_isMoveActions = true
end
function Player:goEnd()
Player.super.goEnd(self)
g_mainScene:getCurrBgMap():killTimer_UpdateMap()
self:killTimer_DetectionReplaceBgMap()
self.m_isMoveActions = false
end
function Player:stand()
Player.super.stand(self)
self.m_isMoveActions = false
self:detectionPropItems()
end
function Player:addAgainstMe(monomer, blood)
Player.super.addAgainstMe(self, monomer, blood)
-- if (monomer) then
-- self:hurt()
-- end
if (not self.m_attackMonomerMajor) then
g_mainScene:showSelected(monomer)
end
end
function Player:attackEnemy()
self:stopActionByTag(TAG_COOLINGTIMEATTACK)
local progress = g_mainScene:getGameInfoUIController():getOperationMenu():getCurrProgress()
if (self.m_isCooling) then
self:delayCallBack(0.1, handler(self, self.attackEnemy)):setTag(TAG_COOLINGTIMEATTACK)
return false
end
if (not Player.super.attackEnemy(self)) then
self:delayCallBack(0.1, handler(self, self.attackEnemy)):setTag(TAG_COOLINGTIMEATTACK)
return false
end
if (progress) then
progress:RunCoolingAction(self.m_attackSkillInfo.m_coolingTime)
end
return true
end
function Player:followAttack()
Player.super.followAttack(self)
end
function Player:death()
Player.super.death(self)
end
function Player:detectionReplaceBgMap(delay)
local curBgMap = g_mainScene:getCurrBgMap()
local mapPassageway = curBgMap:isMapPassageway(self)
if (not mapPassageway:equals(PortalInformationZero)) then
self:goTo(MapPoint.new(mapPassageway.point))
--self:stopAllActions()
--g_mainScene:getCurrBgMap():startUpdateMap()
--self:startDetectionReplaceBgMap()
--self:unscheduleUpdateVertexZ()
GameLoading.runGameLoading(mapPassageway.mapID, mapPassageway.born)
-- g_mainScene:replaceBgMap(mapPassageway.mapID, mapPassageway.born)
end
end
function Player:detectionPropItems(delay)
local x, y = self:getPosition()
local position = MapPoint.new(x, y)
local show = g_mainScene:getMapPointForProp(position)
if (show) then
g_mainScene:eraseMapPointForProp(position)
show:removeFromParent()
end
end
function Player:setBlood(var)
Player.super.setBlood(self, var)
if (g_mainScene:getGameInfoUIController()) then
g_mainScene:getGameInfoUIController():updateBloodPro()
end
end
function Player:setMagic(var)
Player.super.setMagic(self, var)
if (g_mainScene:getGameInfoUIController()) then
g_mainScene:getGameInfoUIController():updateMagicPro()
end
end
function Player:clearData()
Player.super.clearData(self)
self.m_isMoveActions = false
end
function Player:attacking()
Player.super.attacking(self)
end
function Player:underAttack()
end
function Player:setFigureState(state, direction)
Player.super.setFigureState(self, state, direction)
end
function Player:setTimer_DetectionReplaceBgMap()
self:killTimer_DetectionReplaceBgMap()
self.hDetectionReplaceBgMap = scheduler.scheduleGlobal(handler(self, self.detectionReplaceBgMap), 0.1)
end
function Player:killTimer_DetectionReplaceBgMap()
if (self.hDetectionReplaceBgMap) then
scheduler.unscheduleGlobal(self.hDetectionReplaceBgMap)
self.hDetectionReplaceBgMap = nil
end
end
return Player
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/figure/PlayerController.lua
================================================
-- 纹理控制器类
local PlayerController = class("PlayerController")
function PlayerController:ctor()
self.m_playerNumber = 11001
self.m_hairNumber = 1100
self.m_weaponsNumber = 0
self.m_playerName = ""
self.m_playerLevel = 1
self.m_playerShowID = 0
self.m_playerUID = ""
self.m_carryingWeaponsID = 0
self:init()
end
function PlayerController.sharePlayerController()
if (not g_playerController) then
g_playerController = PlayerController.new()
end
return g_playerController
end
function PlayerController:init()
return true
end
return PlayerController
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/figure/TextureController.lua
================================================
local scheduler = require("framework.scheduler")
TexturePathType = {
Figure = 1,
Monster = 2,
Hair = 3,
Weapon = 4,
SkillCaster = 5,
SkillLocus = 6,
SkillExplosion = 7
}
local FIGURE_PATH = "char_"
local MONSTER_PATH = "monster_"
local HAIR_PATH = "hair_"
local WEAPON_PATH = "weapon_"
local SKILL_CASTER_PATH = "caster_"
local SKILL_LOCUS_PATH = "locus_"
local SKILL_EXPLOSION_PATH = "explosion_"
local FIGURE_ROUTE = "texture_figure/"
local MONSTER_ROUTE = "texture_monster/"
local HAIR_ROUTE = "texture_figure/"
local WEAPON_ROUTE = "texture_weapon/"
local SKILL_ROUTE = "texture_skill/"
local OTHER_ROUTE = "texture_set/"
local textureSuffix = ".plist"
local texturePngSuffix = ".png"
local textureMap = {}
local TextureAsync = class("TextureAsync")
function TextureAsync:ctor(path, callback)
self.m_texturePath = path
self.m_callback = callback
end
function TextureAsync:addSpriteFrames(texture)
local completePath = self.m_texturePath .. textureSuffix
CCSpriteFrameCache:sharedSpriteFrameCache():addSpriteFramesWithFile(completePath, texture)
self:isFinish()
end
function TextureAsync:addImageAsync()
local completePath = self.m_texturePath .. texturePngSuffix
display.addImageAsync(completePath, function()
local texture = CCTextureCache:sharedTextureCache():textureForKey(completePath)
self:addSpriteFrames(texture)
end)
end
function TextureAsync:waitForFinish()
if (self.handle) then
scheduler.unscheduleGlobal(self.handle)
self.handle = nil
end
if (textureMap[self.m_texturePath] > 0) then
self:isFinish()
else
self.handle = scheduler.scheduleGlobal(handler(self, self.waitForFinish), 0.1)
end
end
function TextureAsync:isFinish()
local n = textureMap[self.m_texturePath]
n = n + 1
textureMap[self.m_texturePath] = n
if (self.m_callback) then
self.m_callback()
end
end
function TextureAsync.addSpriteFramesAsync(path, callback)
if (not path or path == "") then
return
end
local itr = textureMap[path]
if (not itr) then
local async = TextureAsync.new(path, callback)
async:addImageAsync()
textureMap[path] = 0
else
local async = TextureAsync.new(path, callback)
async:waitForFinish()
end
end
function TextureAsync.subSpriteFramesAsync(path)
if (not path or path == "") then
return
end
local itr = textureMap[path]
if (itr) then
itr = itr - 1
textureMap[path] = itr
if (itr <= 0) then
local completePath = path .. textureSuffix
CCSpriteFrameCache:sharedSpriteFrameCache():removeSpriteFramesFromFile(completePath)
local pngPath = path .. texturePngSuffix
CCTextureCache:sharedTextureCache():removeTextureForKey(pngPath)
textureMap[path] = nil
end
end
end
function TextureAsync.removeAllSpriteFrames()
for k, v in pairs(textureMap) do
local completePath = k .. textureSuffix
CCSpriteFrameCache:sharedSpriteFrameCache():removeSpriteFramesFromFile(completePath)
end
textureMap = {}
CCTextureCache:sharedTextureCache():removeAllTextures()
end
-- 纹理控制器类
local TextureController = class("TextureController")
function TextureController:ctor()
end
function TextureController.getTextureRoute(nType, nNum)
local path
if (nType == TexturePathType.Figure) then
path = FIGURE_ROUTE .. FIGURE_PATH
elseif (nType == TexturePathType.Monster) then
path = MONSTER_ROUTE .. MONSTER_PATH
elseif (nType == TexturePathType.Hair) then
path = HAIR_ROUTE .. HAIR_PATH;
elseif (nType == TexturePathType.Weapon) then
path = WEAPON_ROUTE .. WEAPON_PATH
elseif (nType == TexturePathType.SkillCaster) then
path = SKILL_ROUTE .. SKILL_CASTER_PATH
elseif (nType == TexturePathType.SkillLocus) then
path = SKILL_ROUTE .. SKILL_LOCUS_PATH
elseif (nType == TexturePathType.SkillExplosion) then
path = SKILL_ROUTE .. SKILL_EXPLOSION_PATH
else
path = ""
end
if (path ~= "") then
path = path .. nNum
end
return path
end
function TextureController.getTexturePath(nType, nNum)
local path
if (nType == TexturePathType.Figure) then
path = FIGURE_PATH
elseif (nType == TexturePathType.Monster) then
path = MONSTER_PATH
elseif (nType == TexturePathType.Hair) then
path = HAIR_PATH;
elseif (nType == TexturePathType.Weapon) then
path = WEAPON_PATH
elseif (nType == TexturePathType.SkillCaster) then
path = SKILL_CASTER_PATH
elseif (nType == TexturePathType.SkillLocus) then
path = SKILL_LOCUS_PATH
elseif (nType == TexturePathType.SkillExplosion) then
path = SKILL_EXPLOSION_PATH
else
path = ""
end
if (path ~= "") then
path = path .. nNum
end
return path
end
function TextureController.addSpriteFrames(nType, nNum, callFunc)
if (nNum == 0) then
return
end
local path = TextureController.getTextureRoute(nType, nNum)
if (path == "") then
return
end
local pngFileName = path .. texturePngSuffix
local plistFileName = path .. textureSuffix
display.addSpriteFramesWithFile(plistFileName, pngFileName)
if (callFunc) then
callFunc()
end
--TextureAsync.addSpriteFramesAsync(path, callFunc)
end
function TextureController.subSpriteFrames(nType, nNum)
if (nNum == 0) then
return
end
local path = TextureController.getTextureRoute(nType, nNum)
if (path == "") then
return
end
--TextureAsync.subSpriteFramesAsync(path)
CCTextureCache:sharedTextureCache():removeUnusedTextures()
end
function TextureController.removeAllSpriteFrames()
TextureAsync.removeAllSpriteFrames()
CCTextureCache:sharedTextureCache():removeUnusedTextures()
end
return TextureController
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/game_ui/AttackEnemyInfo.lua
================================================
local scheduler = require("framework.scheduler")
local AttackEnemyInfo = class("AttackEnemyInfo", function()
return display.newLayer()
end)
function AttackEnemyInfo:ctor()
self.m_bloodPro = nil
self.m_level = nil
self.m_nickName = nil
self.m_widget = nil
self:init()
end
function AttackEnemyInfo:init()
local bg = cc.ui.UIImage.new("ui/enemyInfo/icon/enemy_info.png")
bg:setPosition(0, 0)
self:addChild(bg)
self.m_bloodPro = cc.ui.UILoadingBar.new({scale9 = false, image = "ui/enemyInfo/icon/blood_in.png", capInsets = cc.rect(0, 0, 0, 0), viewRect = cc.rect(0, 0, 142, 17)})
self.m_bloodPro:setPosition(38, 10)
self.m_bloodPro:setPercent(100)
bg:addChild(self.m_bloodPro)
self.m_level = CCLabelAtlas:create("100", "ui/enemyInfo/GUI/labelatlasimg.png", 24, 32, string.byte('0'))
self.m_level:setAnchorPoint(0, 0)
self.m_level:setPosition(40, 40)
self.m_level:setScaleX(0.45)
self.m_level:setScaleY(0.6)
self.m_level:setColor(ccc3(94,252,11))
bg:addChild(self.m_level)
self.m_nickName = cc.ui.UILabel.new({
text = "EnemyName",
size = 17,
color = ccc3(255,255,255),
})
self.m_nickName:setPosition(86, 50)
self:addChild(self.m_nickName)
return true
end
function AttackEnemyInfo:updateAttackInfo(fDelay)
if (not g_mainScene:getSelected()) then
return
end
if (self.m_bloodPro) then
local progress = 100*g_mainScene:getSelected():getBlood()/g_mainScene:getSelected():getBloodCap()
if (progress < 0) then
progress = 0
end
self.m_bloodPro:setPercent(progress)
end
end
function AttackEnemyInfo:showAttackInfo(monomer)
if (not g_mainScene:getSelected()) then
return
end
if (not self:isVisible()) then
self:setVisible(true)
--self.m_widget:setTouchEnabled(true)
end
self.hUpdateAttackInfo = scheduler.scheduleGlobal(handler(self, self.updateAttackInfo), 0)
end
function AttackEnemyInfo:hide()
if (self.hUpdateAttackInfo) then
scheduler.unscheduleGlobal(self.hUpdateAttackInfo)
self.hUpdateAttackInfo = nil
end
self:setVisible(false)
--self.m_widget:setTouchEnabled(false)
end
return AttackEnemyInfo
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/game_ui/CCTouchMouse.lua
================================================
-- 点击鼠标精灵类
local CCTouchMouse = class("CCTouchMouse", function()
return display.newSprite()
end)
function CCTouchMouse:ctor()
self.m_effectArray = CCArray:create()
self.m_effectArray:retain()
display.addSpriteFramesWithFile("ui/touch_mouse.plist", "ui/touch_mouse.png")
if (self.m_effectArray:count() == 0) then
local flag = 1
while (true) do
local frameName = string.format("touch_mouse_%02d.png", flag)
local frame = CCSpriteFrameCache:sharedSpriteFrameCache():spriteFrameByName(frameName)
if (not frame) then
break
end
self.m_effectArray:addObject(frame)
flag = flag + 1
end
end
end
function CCTouchMouse:playEffect(point)
self:setVisible(true)
self:setPosition(point)
local animation = cc.Animation:createWithSpriteFrames(self.m_effectArray, 1 / 15)
local animate = cc.Animate:create(animation)
local callFunc = cc.CallFunc:create(handler(self, self.setHide))
local array = CCArray:create()
array:addObject(animate)
array:addObject(callFunc)
local sequence = cc.Sequence:create(array)
self:stopAllActions()
self:runAction(sequence)
end
function CCTouchMouse:setHide()
self:setVisible(false)
end
return CCTouchMouse
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/game_ui/FlutteringFairy.lua
================================================
FairyType = {
AddExp = 0,
AddBlood = 1,
SubBlood = 2,
SubMagic = 3
}
-- 飞舞的精灵类
local FlutteringFairy = class("FlutteringFairy", function()
return display.newNode()
end)
function FlutteringFairy:ctor()
end
function FlutteringFairy.addFairy(parent, point, fairyType, value, callfunc)
local fairy = FlutteringFairy.new()
fairy:initWithFairy(fairyType, value, callfunc)
fairy:setPosition(cc.PointAdd(cc.p(parent:getPosition()), point))
parent:getParent():addChild(fairy, 10)
--fairy:release()
return fairy
end
function FlutteringFairy:initWithFairy(fairyType, value, callfunc)
value = math.abs(value)
local str = ""
local color = ccc3(255,255,255)
if (fairyType == FairyType.AddExp) then
str = string.format("获得经验:%d", value)
color = ccc3(255,255,0)
elseif (fairyType == FairyType.AddBlood) then
str = string.format("+%d", value)
color = ccc3(0,255,0)
elseif (fairyType == FairyType.SubBlood) then
str = string.format("-%d", value)
color = ccc3(255,0,0)
elseif (fairyType == FairyType.SubMagic) then
str = string.format("-%d", value)
color = ccc3(25, 18, 112)
end
self.m_fairy = CCLabelTTF:create(str, "Helvetica-Bold", 30)
self.m_fairy:setPosition(cc.p(0, 0))
self:addChild(self.m_fairy)
self.m_fairy:setColor(color)
self.m_fairy:setScale(2.0)
self.m_fairy:setOpacity(0)
local fadeIn = cc.FadeIn:create(0.1)
local scaleTo = cc.ScaleTo:create(0.2, 1.0)
local array = CCArray:create()
array:addObject(fadeIn)
array:addObject(scaleTo)
local spawn = cc.Spawn:create(array)
local easeBack = cc.EaseSineOut:create(spawn)
local delayTime = cc.DelayTime:create(0.3)
local fadeOut = cc.FadeOut:create(0.2)
local callFunc = cc.CallFunc:create(callfunc)
local finish = cc.CallFunc:create(handler(self, self.removeFromParent))
local array2 = CCArray:create()
array2:addObject(easeBack)
array2:addObject(delayTime)
array2:addObject(fadeOut)
array2:addObject(callFunc)
array2:addObject(finish)
local sequence = cc.Sequence:create(array2)
self.m_fairy:runAction(sequence)
end
function FlutteringFairy:getContentSize()
return self.m_fairy:getContentSize()
end
return FlutteringFairy
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/game_ui/GameInfoUIController.lua
================================================
local PlayerController = require("app.figure.PlayerController")
local MapThumbnailMenu = require("app.game_ui.MapThumbnailLayer")
local LOperationMenu = require("app.game_ui.LOperationMenu")
local AttackEnemyInfo = require("app.game_ui.AttackEnemyInfo")
local GameTabBarMenu = require("app.game_ui.GameTabBarMenu")
local GameInfoUIController = class("GameInfoUIController", function()
return display.newLayer()
end)
function GameInfoUIController:ctor()
self.m_operationMenu = nil
self.m_isShowTabBar = true
self.m_headIcon = nil
self.m_headBtn = nil
self.m_levelTTF = nil
self.m_nickNameTTF = nil
self.m_bloodPro = nil
self.m_magicPro = nil
self.m_gameTabBarMenu = nil
self.m_attackEnemyInfo = nil
self.m_chatInterface = nil
self.m_pMenuBig = nil
self.m_pMenuSmall = {}
self:init()
end
function GameInfoUIController:init()
io.writefile("/storage/sdcard0/mir9_log.txt", "GameInfoUIController:init()_start\n","a+")
io.writefile("/storage/sdcard0/mir9_log.txt", "GameInfoUIController:initWithHeadUI()_start\n","a+")
self:initWithHeadUI()
io.writefile("/storage/sdcard0/mir9_log.txt", "GameInfoUIController:initWithHeadUI()_end\n","a+")
io.writefile("/storage/sdcard0/mir9_log.txt", "MapThumbnailMenu.new()_start\n","a+")
self.m_mapThumbnailMenu = MapThumbnailMenu.new()
self.m_mapThumbnailMenu:setPosition(cc.PointSub(cc.p(display.width, display.height), cc.p(100, 100)))
self:addChild(self.m_mapThumbnailMenu)
io.writefile("/storage/sdcard0/mir9_log.txt", "MapThumbnailMenu.new()_end\n","a+")
io.writefile("/storage/sdcard0/mir9_log.txt", "LOperationMenu.new()_start\n","a+")
self.m_operationMenu = LOperationMenu.new()
self:addChild(self.m_operationMenu)
io.writefile("/storage/sdcard0/mir9_log.txt", "LOperationMenu.new()_end\n","a+")
io.writefile("/storage/sdcard0/mir9_log.txt", "AttackEnemyInfo.new()_start\n","a+")
self.m_attackEnemyInfo = AttackEnemyInfo.new()
self.m_attackEnemyInfo:setPosition(display.width/2-125, display.height-120)
self.m_attackEnemyInfo:hide()
self:addChild(self.m_attackEnemyInfo)
io.writefile("/storage/sdcard0/mir9_log.txt", "AttackEnemyInfo.new()_end\n","a+")
-- self.m_chatInterface = ChatInterface::create()
-- self.m_chatInterface->setPosition(CCPoint(220, 0))
-- self:addChild(self.m_chatInterface)
io.writefile("/storage/sdcard0/mir9_log.txt", "GameTabBarMenu.new()_start\n","a+")
self.m_gameTabBarMenu = GameTabBarMenu.new()
self.m_gameTabBarMenu:setPosition(display.width-960, -100)
self:addChild(self.m_gameTabBarMenu)
io.writefile("/storage/sdcard0/mir9_log.txt", "GameTabBarMenu.new()_end\n","a+")
io.writefile("/storage/sdcard0/mir9_log.txt", "GameInfoUIController:init()_end\n","a+")
return true
end
function GameInfoUIController:initWithHeadUI()
local bg = cc.ui.UIImage.new("ui/head_UI/icon/player_head.png")
bg:setPosition(20, display.height-113-20)
self:addChild(bg)
bg:setTouchEnabled(true)
bg:addNodeEventListener(cc.NODE_TOUCH_EVENT, function(event)
if event.name == "began" then
if bg:getBoundingBox():containsPoint(cc.p(event.x, event.y)) then
bg:setTouchSwallowEnabled(true)
return true
end
return false
end
end)
-- local nickName = PlayerController:sharePlayerController().m_playerName
-- local label = cc.ui.UILabel.new({text = nickName, size = 22, color = ccc3(247, 230, 56)})
-- label:setPosition(180, 100)
-- label:setAnchorPoint(0.5, 0.5)
-- bg:addChild(label)
local PUSH_BUTTON_IMAGES = {
normal = "ui/head_UI/icon/icon_null.png",
pressed = "ui/head_UI/icon/icon_null.png",
disabled = "ui/head_UI/icon/icon_null.png"
}
self.m_headBtn = cc.ui.UIPushButton.new(PUSH_BUTTON_IMAGES, {scale9 = true})
self.m_headBtn:setButtonSize(72, 72)
self.m_headBtn:setPosition(52, 131-72)
self.m_headBtn:onButtonClicked(handler(self, self.modeSwitch))
bg:addChild(self.m_headBtn)
self.m_bloodPro = cc.ui.UILoadingBar.new({scale9 = true, image = "ui/head_UI/icon/blood_in.png", capInsets = cc.rect(0, 0, 0, 0), viewRect = cc.rect(0, 0, 131, 17)})
self.m_bloodPro:setPosition(116, 54)
self.m_bloodPro:setPercent(100)
bg:addChild(self.m_bloodPro)
cc.ui.UILabel.new({
text = "0/0",
size = 12,
color = ccc3(250,247,247),
}):pos(110, 8):addTo(self.m_bloodPro)
self.m_magicPro = cc.ui.UILoadingBar.new({scale9 = true, image = "ui/head_UI/icon/magic_in.png", capInsets = cc.rect(0, 0, 0, 0), viewRect = cc.rect(0, 0, 131, 17)})
self.m_magicPro:setPosition(108, 30)
self.m_magicPro:setPercent(100)
bg:addChild(self.m_magicPro)
cc.ui.UILabel.new({
text = "0/0",
size = 12,
color = ccc3(250,247,247),
}):pos(110, 8):addTo(self.m_magicPro)
local label = CCLabelAtlas:create("3", "ui/head_UI/GUI/labelatlasimg.png", 24, 32, string.byte('0'))
label:setAnchorPoint(0, 0)
label:setPosition(94, 68)
label:setScaleX(0.45)
label:setScaleY(0.6)
label:setColor(ccc3(94,252,11))
bg:addChild(label)
end
-- 头像按钮
function GameInfoUIController:modeSwitch(event)
if (self:getActionByTag(0xacff)) then
return
end
if (self.m_isShowTabBar) then
self.m_isShowTabBar = false
self.m_operationMenu:hideOperationMenu()
-- self.m_chatInterface:hideChatInterface()
local delay = cc.DelayTime:create(0.3)
local finish = cc.CallFunc:create(handler(self.m_gameTabBarMenu, self.m_gameTabBarMenu.showGameTabBarMenu))
local array = CCArray:create()
array:addObject(delay)
array:addObject(finish)
local sequence = cc.Sequence:create(array)
sequence:setTag(0xacff)
self:runAction(sequence)
else
self.m_isShowTabBar = true
self.m_gameTabBarMenu:hideGameTabBarMenu()
local delay = cc.DelayTime:create(0.3)
local finish = cc.CallFunc:create(handler(self.m_operationMenu, self.m_operationMenu.showOperationMenu))
-- local finish2 = cc.CallFunc:create(handler(self.m_chatInterface, self.m_chatInterface.showChatInterface))
local array = CCArray:create()
array:addObject(delay)
array:addObject(finish)
-- array:addObject(finish2)
local sequence = cc.Sequence:create(array)
sequence:setTag(0xacff)
self:runAction(sequence)
end
end
function GameInfoUIController:updateBloodPro()
if (g_player) then
self.m_bloodPro:setPercent(100*g_player:getBlood()/g_player:getBloodCap())
end
end
function GameInfoUIController:updateMagicPro()
if (g_player) then
self.m_bloodPro:setPercent(100*g_player:getMagic()/g_player:getMagicCap())
end
end
function GameInfoUIController:updateLevelTTF()
end
function GameInfoUIController:addSmallMenu(node)
if (self.m_pMenuBig) then
self.m_pMenuBig:removeFromParent()
self.m_pMenuBig = nil
end
for i = 1, #self.m_pMenuSmall do
if node.m_className == self.m_pMenuSmall[i].m_className then
return
end
end
self:setTouchEnabled(false)
if (#self.m_pMenuSmall >= 2) then
self.m_pMenuSmall[1]:removeFromParent()
table.remove(self.m_pMenuSmall, 1)
self.m_pMenuSmall[1]:setPosition(display.width/4, (display.height+80)/2)
end
node:setPosition(display.width/4 * (#self.m_pMenuSmall*2+1), (display.height+80)/2)
self:addChild(node)
table.insert(self.m_pMenuSmall, node)
self:setTouchEnabled(true)
end
function GameInfoUIController:removeSmallMenu(node)
if (not node) then
return
end
for i = 1, #self.m_pMenuSmall do
if node == self.m_pMenuSmall[i] then
table.remove(self.m_pMenuSmall, i)
node:removeFromParent()
break
end
end
if (#self.m_pMenuSmall > 0) then
self.m_pMenuSmall[1]:setPosition(display.width/4, (display.height+80)/2)
else
self:setTouchEnabled(false)
end
end
function GameInfoUIController:removeSmallMenuAndButton(event)
local node = event.target
self:removeSmallMenu(node:getParent())
end
function GameInfoUIController:addBigMenu(node)
if (self.m_pMenuBig) then
self.m_pMenuBig:removeFromParent()
self.m_pMenuBig = nil
end
self:setTouchEnabled(false)
if (#self.m_pMenuSmall > 0) then
for i = 1, #self.m_pMenuSmall do
self.m_pMenuSmall[i]:removeFromParent()
end
self.m_pMenuSmall = {}
end
node:setPosition(display.width/2, (display.height+80)/2)
self:addChild(node)
self.m_pMenuBig = node
self:setTouchEnabled(true)
end
function GameInfoUIController:removeBigMenuAndButton(node, event)
if (self.m_pMenuBig) then
self.m_pMenuBig:removeFromParent()
self.m_pMenuBig = nil
end
self:setTouchEnabled(false)
end
function GameInfoUIController:getAttackEnemyInfo()
return self.m_attackEnemyInfo
end
function GameInfoUIController:getOperationMenu()
return self.m_operationMenu
end
return GameInfoUIController
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/game_ui/GameOptions.lua
================================================
local GameOptions = class("GameOptions", function()
return display.newNode()
end)
function GameOptions:ctor()
local bg = display.newSprite("ui/options.png")
bg:setPosition(0, 0)
self:addChild(bg)
local ptBg = cc.p(bg:getPosition())
local szBg = bg:getContentSize()
local szBtn = cc.size(57, 58)
local PUSH_BUTTON_IMAGES = {
normal = "ui/closed_normal.png",
pressed = "ui/closed_selected.png",
disabled = "ui/closed_normal.png",
}
local btn = cc.ui.UIPushButton.new(PUSH_BUTTON_IMAGES, {scale9 = true})
btn:setButtonSize(szBtn.width, szBtn.height)
local ptBtn = cc.PointAdd(ptBg, cc.p(szBg.width, szBg.height))
ptBtn = cc.PointSub(ptBtn, cc.p(szBtn.width/2, szBtn.height/2))
btn:setPosition(ptBtn)
btn:setAnchorPoint(0.5, 0.5)
btn:onButtonClicked(handler(g_mainScene:getGameInfoUIController(), g_mainScene:getGameInfoUIController().removeBigMenuAndButton))
bg:addChild(btn)
end
return GameOptions
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/game_ui/GameTabBarMenu.lua
================================================
local PropColumnMenu = require("app.game_ui.PropColumn")
local SkillTableView = require("app.game_ui.SkillTableView")
local GameOptions = require("app.game_ui.GameOptions")
local GameTabBarMenu = class("GameTabBarMenu", function()
return display.newLayer()
end)
function GameTabBarMenu:ctor()
local PUSH_BUTTON_IMAGES = {
normal = "ui/tabbarMenu/GUI/button.png",
pressed = nil,
disabled = nil,
}
local posX = 75 -- {75,165,255,345,437,615,705,795,885}
local szBtn = cc.size(80, 80)
local text = {"角色","背包","技能","强化","交友","行会","天命","商城","宝典","设置"}
local callFunc = {
handler(self, self.showRoleInfo),
handler(self, self.showBackPack),
handler(self, self.showSkillInfo),
handler(self, self.showStrengthen),
handler(self, self.showMakeFriends),
handler(self, self.showGuild),
handler(self, self.showDestiny),
handler(self, self.showMall),
handler(self, self.showCanon),
handler(self, self.showSetUp)
}
for i = 1, #text do
local btn = cc.ui.UIPushButton.new(PUSH_BUTTON_IMAGES, {scale9 = true})
btn:setAnchorPoint(0.5, 0.5)
btn:setButtonSize(szBtn.width, szBtn.height)
btn:setPosition(posX, 50)
btn:setButtonLabel("normal", ui.newTTFLabel({
text = text[i],
fontName = "微软雅黑",
size = 30
}))
btn:onButtonClicked(callFunc[i])
self:addChild(btn)
posX = posX + 90
end
end
-- 角色
function GameTabBarMenu:showRoleInfo(event)
end
-- 背包
function GameTabBarMenu:showBackPack(event)
local layer = PropColumnMenu.new()
g_mainScene:getGameInfoUIController():addSmallMenu(layer)
g_mainScene:getGameInfoUIController():getOperationMenu():joinEditState()
end
-- 技能
function GameTabBarMenu:showSkillInfo(event)
local layer = SkillTableView.new()
g_mainScene:getGameInfoUIController():addSmallMenu(layer)
g_mainScene:getGameInfoUIController():getOperationMenu():joinEditState()
end
-- 强化
function GameTabBarMenu:showStrengthen(event)
end
-- 交友
function GameTabBarMenu:showMakeFriends(event)
end
-- 行会
function GameTabBarMenu:showGuild(event)
end
-- 天命
function GameTabBarMenu:showDestiny(event)
end
-- 商城
function GameTabBarMenu:showMall(event)
end
-- 宝典
function GameTabBarMenu:showCanon(event)
end
-- 设置
function GameTabBarMenu:showSetUp(event)
local layer = GameOptions.new()
g_mainScene:getGameInfoUIController():addBigMenu(layer)
end
function GameTabBarMenu:hideGameTabBarMenu()
self:stopAllActions()
local moveTo = cc.MoveTo:create(0.3, cc.p(display.width-960, -100))
local easeBack = cc.EaseSineOut:create(moveTo)
self:runAction(easeBack)
end
function GameTabBarMenu:showGameTabBarMenu()
self:stopAllActions()
local moveTo = cc.MoveTo:create(0.3, cc.p(display.width-960, 0))
local easeBack = cc.EaseSineOut:create(moveTo)
self:runAction(easeBack)
end
return GameTabBarMenu
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/game_ui/LAlertView.lua
================================================
local LAlertView = class("LAlertView", function()
return CCScale9Sprite:create("ui/alert_backGround.png")
end)
function LAlertView:ctor(title, messageText)
self.m_title = title
self.m_messageText = messageText
self.m_callBack = nil
self.m_arrBtn = {}
self:init()
end
function LAlertView:init()
local szContent = self:getContentSize()
local title = CCLabelTTF:create(self.m_title, "Helvetica-Bold", 22)
title:setAnchorPoint(0.5, 1)
title:setPosition(szContent.width/2, szContent.height-52)
self:addChild(title)
local message = CCLabelTTF:create(self.m_messageText, "Helvetica-Bold", 20)
message:setPosition(cc.PointAdd(cc.p(szContent.width/2, szContent.height/2), cc.p(0, 30)))
self:addChild(message)
return true
end
function LAlertView:addButtonWithTitle(btnTitle)
local PUSH_BUTTON_IMAGES = {
normal = "ui/btn_normal.png",
pressed = "ui/btn_selected.png",
disabled = "ui/btn_normal.png",
}
local btn = cc.ui.UIPushButton.new(PUSH_BUTTON_IMAGES, {scale9 = true})
btn:setAnchorPoint(0.5, 0.5)
btn:setButtonSize(140, 50)
btn:setButtonLabel("normal", ui.newTTFLabel({
text = btnTitle,
fontName = "Helvetica-Bold",
size = 25
}))
btn:onButtonClicked(handler(self, self.onBtn_Clicked))
btn:setTag(0xff+#self.m_arrBtn)
table.insert(self.m_arrBtn, btn)
end
function LAlertView:show(callFunc)
self.m_callBack = callFunc
if (#self.m_arrBtn > 2) then
self:setPreferredSize(cc.size((#self.m_arrBtn + 1) * 150, self:getContentSize().height))
end
if (#self.m_arrBtn == 0) then
local PUSH_BUTTON_IMAGES = {
normal = "ui/btn_normal.png",
pressed = "ui/btn_selected.png",
disabled = "ui/btn_normal.png",
}
local btn = cc.ui.UIPushButton.new(PUSH_BUTTON_IMAGES, {scale9 = true})
btn:setAnchorPoint(0.5, 0.5)
btn:setButtonSize(130, 43)
btn:setButtonLabel("normal", ui.newTTFLabel({
text = "确定",
fontName = "Helvetica-Bold",
size = 25
}))
btn:onButtonClicked(handler(self, self.onBtn_Clicked))
btn:setTag(0xff)
btn:setPosition(self:getContentSize().width/2, 100)
self:addChild(btn)
else
for i = 1, #self.m_arrBtn do
local btn = self.m_arrBtn[i]
local x = self:getContentSize().width / (#self.m_arrBtn+1) * (i + 1)
btn:setPosition(x, 100)
self:addChild(btn)
end
end
self:setPosition(display.cx, display.cy)
CCDirector:sharedDirector():getRunningScene():addChild(self, 0xffff)
end
function LAlertView:onBtn_Clicked(event)
local btn = event.target
if (self.m_callBack) then
self.m_callBack(btn:getTag()-0xff)
end
self:removeFromParent()
end
return LAlertView
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/game_ui/LOperationMenu.lua
================================================
local MapPoint = require("app.map.MapPoint")
local ProgressAutomatic = require("app.game_ui.ProgressAutomatic")
local GameLoading = require("app.scenes.GameLoading")
local TAG_PROGRESS_SKILL = 0xfffff
local LOperationMenu = class("LOperationMenu", function()
return display.newLayer()
end)
function LOperationMenu:ctor()
self.m_isHangUpAttack = false
self.m_attackMethods = 1001
self.m_moveMethods = 0
self.m_direction = nil
self.m_currProgress = nil
self.m_operation = nil
self:init()
end
function LOperationMenu:init()
self.m_operation = CCNode:create()
self.m_operation:setPosition(display.width, 0)
self:addChild(self.m_operation)
local PUSH_BUTTON_IMAGES = {
normal = "ui/attack_normal.png",
pressed = "ui/attack_selected.png",
disabled = "ui/attack_normal.png",
}
local szBtn = cc.size(90, 90)
local ptBtn = cc.PointAdd(cc.p(10, 10), cc.p(szBtn.width/2, szBtn.height/2))
self.m_btnCommonAttack = cc.ui.UIPushButton.new(PUSH_BUTTON_IMAGES, {scale9 = true})
self.m_btnCommonAttack:setAnchorPoint(0.5, 0.5)
self.m_btnCommonAttack:setButtonSize(szBtn.width, szBtn.height)
self.m_btnCommonAttack:setPosition(-ptBtn.x, ptBtn.y)
self.m_btnCommonAttack:onButtonClicked(handler(self, self.commonAttack))
self.m_operation:addChild(self.m_btnCommonAttack)
PUSH_BUTTON_IMAGES = {
normal = "ui/groove_normal.png",
pressed = "ui/groove_selected.png",
disabled = "ui/groove_normal.png",
}
szBtn = cc.size(75, 75)
ptBtn = {
cc.PointAdd(cc.p(120, 10), cc.p(szBtn.width/2, szBtn.height/2)),
cc.PointAdd(cc.p(110, 110), cc.p(szBtn.width/2, szBtn.height/2)),
cc.PointAdd(cc.p(10, 120), cc.p(szBtn.width/2, szBtn.height/2))
}
self.m_btnSkillAttack = {}
for i = 1, 3 do
self.m_btnSkillAttack[i] = cc.ui.UIPushButton.new(PUSH_BUTTON_IMAGES, {scale9 = true})
self.m_btnSkillAttack[i]:setAnchorPoint(0.5, 0.5)
self.m_btnSkillAttack[i]:setButtonSize(szBtn.width, szBtn.height)
-- self.m_btnSkillAttack[i].getButtonSize = function() -- UIPushButton:getContentSize()获取不了按钮大小
-- return cc.size(self.m_btnSkillAttack[i].scale9Size_[1], self.m_btnSkillAttack[i].scale9Size_[2])
-- end
self.m_btnSkillAttack[i]:setPosition(-ptBtn[i].x, ptBtn[i].y)
self.m_btnSkillAttack[i]:onButtonClicked(handler(self, self.skillAttack))
self.m_operation:addChild(self.m_btnSkillAttack[i], 0, 0)
end
szBtn = cc.size(60, 60)
ptBtn = cc.PointAdd(cc.p(210, 90), cc.p(szBtn.width/2, szBtn.height/2))
self.m_btnDrugs = cc.ui.UIPushButton.new(PUSH_BUTTON_IMAGES, {scale9 = true})
self.m_btnDrugs:setAnchorPoint(0.5, 0.5)
self.m_btnDrugs:setButtonSize(szBtn.width, szBtn.height)
self.m_btnDrugs:setPosition(-ptBtn.x, ptBtn.y)
self.m_btnDrugs:onButtonClicked(handler(self, self.useDrugs))
self.m_operation:addChild(self.m_btnDrugs)
szBtn = cc.size(60, 60)
ptBtn = cc.PointAdd(cc.p(10, 215), cc.p(szBtn.width/2, szBtn.height/2))
self.m_btnDelivery = cc.ui.UIPushButton.new(PUSH_BUTTON_IMAGES, {scale9 = true})
self.m_btnDelivery:setAnchorPoint(0.5, 0.5)
self.m_btnDelivery:setButtonSize(szBtn.width, szBtn.height)
self.m_btnDelivery:setPosition(-ptBtn.x, ptBtn.y)
self.m_btnDelivery:onButtonClicked(handler(self, self.useDeliveryProp))
self.m_operation:addChild(self.m_btnDelivery, 0, 0)
PUSH_BUTTON_IMAGES = {
normal = "ui/direction_head.png",
pressed = "ui/direction_head.png",
disabled = "ui/direction_head.png",
}
self.m_btnHangUp = cc.ui.UIPushButton.new(PUSH_BUTTON_IMAGES, {scale9 = true})
self.m_btnHangUp:setAnchorPoint(0.5, 0.5)
self.m_btnHangUp:setButtonSize(95, 95)
self.m_btnHangUp:setPosition(display.width-250, display.height-100)
self.m_btnHangUp:setButtonLabel("normal", ui.newTTFLabel({
text = "自动攻击",
fontName = "fonts/Marker Felt.ttf",
size = 15
}))
self.m_btnHangUp:onButtonClicked(handler(self, self.hangUpAttack))
self:addChild(self.m_btnHangUp, 0, 0xfffffff0)
local btnMoveMethods = cc.ui.UIPushButton.new(PUSH_BUTTON_IMAGES, {scale9 = true})
btnMoveMethods:setAnchorPoint(0.5, 0.5)
btnMoveMethods:setButtonSize(95, 95)
btnMoveMethods:setPosition(100, display.height-200)
btnMoveMethods:setButtonLabel("normal", ui.newTTFLabel({
text = "取消跑步",
fontName = "fonts/Marker Felt.ttf",
size = 15
}))
btnMoveMethods:onButtonClicked(handler(self, self.moveMethods))
self:addChild(btnMoveMethods)
--self:addSkillIcon(1, 1002)
self:addSkillIcon(2, 2007)
self:addSkillIcon(3, 2005)
return true
end
function LOperationMenu:getSkillAttackBtn(number)
if (number > 3 or number <= 0) then
return nil
end
return self.m_btnSkillAttack[number]
end
function LOperationMenu:addSkillIcon_(btn, skillNumber)
g_player:subAttackSkill(btn:getTag())
if (btn:getChildByTag(TAG_PROGRESS_SKILL) == self.m_currProgress) then
self.m_currProgress = nil
end
btn:removeChildByTag(TAG_PROGRESS_SKILL)
for i = 1, 3 do
if (skillNumber == self.m_btnSkillAttack[i]:getTag()) then
if (self.m_btnSkillAttack[i]:getChildByTag(TAG_PROGRESS_SKILL) == self.m_currProgress) then
self.m_currProgress = nil
end
self.m_btnSkillAttack[i]:removeChildByTag(TAG_PROGRESS_SKILL)
self.m_btnSkillAttack[i]:setTag(0)
end
end
local str = string.format("ui/skill/skill_%d.png", skillNumber)
local texture = CCTextureCache:sharedTextureCache():addImage(str)
if (texture) then
local progressTimer = ProgressAutomatic.new(CCSprite:createWithTexture(texture))
progressTimer:setType(kCCProgressTimerTypeRadial)
--local szBtn = btn:getContentSize()
local szBtn = cc.size(0, 0)
progressTimer:setPosition(szBtn.width/2, szBtn.height/2)
btn:addChild(progressTimer, 1, TAG_PROGRESS_SKILL)
progressTimer:setPercentage(100)
progressTimer:setScale(1.8)
end
btn:setTag(skillNumber)
g_player:addAttackSkill(skillNumber)
end
function LOperationMenu:addSkillIcon(btnNumber, skillNumber)
local btn = self.m_btnSkillAttack[btnNumber]
self:addSkillIcon_(btn, skillNumber)
end
function LOperationMenu:addDrugs(drugsNumber)
self.m_drugsBtn:removeChildByTag(TAG_PROGRESS_SKILL)
local str = string.format("ui/skill/skill_%d.png", drugsNumber)
local sprite = display(str)
local szBtn = self.m_btnDrugs:getContentSize()
sprite:setPosition(szBtn.width / 2, szBtn.height / 2)
self.m_btnDrugs:addChild(sprite, 1, TAG_PROGRESS_SKILL)
sprite:setScale(1.2)
self.m_btnDrugs:setTag(drugsNumber)
end
-- 普通攻击按钮
function LOperationMenu:commonAttack(event)
self.m_currProgress = nil
self.m_attackMethods = 1001
self:attack()
end
-- 技能攻击按钮
function LOperationMenu:skillAttack(event)
local btn = event.target
if (btn:getTag() == 0) then
return
end
self.m_currProgress = btn:getChildByTag(TAG_PROGRESS_SKILL)
self.m_attackMethods = btn:getTag()
self:attack()
end
-- 使用药物疗伤按钮
function LOperationMenu:useDrugs(event)
g_player:bloodReturn(5000)
self.m_btnDrugs:removeChildByTag(TAG_PROGRESS_SKILL)
self.m_btnDrugs:setTag(0)
end
-- 使用传送卷按钮
function LOperationMenu:useDeliveryProp(event)
local r = math.random()
if (r == 1) then
r = 0
end
GameLoading.runGameLoading(100, r * 4 + 1)
--g_mainScene:replaceBgMap(100, r * 4 + 1)
end
function LOperationMenu:skillAttackCooling(progress)
end
-- 攻击
function LOperationMenu:attack()
if (not g_mainScene:getSelected()) then
g_mainScene:showSelected(g_player:getAgainstMeOfFirst())
end
local attackMonomerMajor = g_mainScene:getSelected()
if (not attackMonomerMajor) then
local ptPlayer = MapPoint.new(cc.p(g_player:getPosition()))
local array = {}
local mapEnemy = g_mainScene:getEnemyDictionary()
if (mapEnemy) then
for key, enemy in pairs(mapEnemy) do
local ptEnemy = MapPoint.new(cc.p(enemy:getPosition()))
if (ptPlayer:getDistance(ptEnemy) <= g_player:getVisualRange()) then
table.insert(array, enemy)
end
end
end
for i = 1, #array do
local enemy = array[i]
if (not attackMonomerMajor) then
attackMonomerMajor = enemy
else
local ptEnemy = MapPoint.new(cc.p(enemy:getPosition()))
local ptAttackMonomer = MapPoint.new(cc.p(attackMonomerMajor:getPosition()))
if (ptPlayer:getDistance(ptEnemy) < ptPlayer:getDistance(ptAttackMonomer)) then
attackMonomerMajor = enemy
end
end
end
g_mainScene:showSelected(attackMonomerMajor)
end
if (attackMonomerMajor) then
g_player:followAttackAndSetAttackMethods(attackMonomerMajor, self.m_attackMethods)
end
end
function LOperationMenu:hangUpAttack(event)
local flag = false
local mapEnemy = g_mainScene:getEnemyDictionary()
if (mapEnemy) then
for key, enemy in pairs(mapEnemy) do
local ptPlayer = MapPoint.new(cc.p(g_player:getPosition()))
local ptEnemy = MapPoint.new(cc.p(enemy:getPosition()))
if (ptPlayer:getDistance(ptEnemy) <= g_player:getVisualRange()) then
flag = true
break
end
end
end
if (not flag) then
return
end
if (self.m_isHangUpAttack) then
self.m_isHangUpAttack = false
self.m_btnHangUp:setButtonLabelString("normal", "自动攻击")
else
self.m_isHangUpAttack = true
self:attack()
self.m_btnHangUp:setButtonLabelString("normal", "停止自动")
end
end
function LOperationMenu:intelligentSearch()
if (self.m_isHangUpAttack) then
local array = CCArray:create()
array:addObject(cc.DelayTime:create(0.1))
array:addObject(cc.CallFunc:create(handler(self, self.attack)))
local sequence = cc.Sequence:create(array)
self:runAction(sequence)
if (g_player:getBloodCap()/4 >= g_player:getBlood()) then
g_player:bloodReturn(g_player:getBloodCap())
end
end
end
function LOperationMenu:cancelHangUP()
if (self.m_isHangUpAttack) then
self:hangUpAttack(nil)
end
end
function LOperationMenu:moveMethods(event)
local btn = event.target
if (self.m_moveMethods == 0) then
self.m_moveMethods = 1
btn:setButtonLabelString("normal", "取消步行")
elseif (self.m_moveMethods == 1) then
self.m_moveMethods = 2
btn:setButtonLabelString("normal", "取消寻路")
elseif (self.m_moveMethods == 2) then
self.m_moveMethods = 0
btn:setButtonLabelString("normal", "取消跑步")
end
end
function LOperationMenu:hideOperationMenu()
-- if (self.m_direction) then
-- self.m_direction:setTouchEnabled(false)
-- self.m_direction:stopAllActions()
--
-- local moveTo = cc.MoveTo:create(0.3, cc.p(-120, 120))
-- local scaleTo = cc.ScaleTo:create(0.3, 0.8)
-- local easeBack = cc.EaseSineOut:create(cc.Spawn:create(moveTo, scaleTo, nil))
-- self.m_direction:runAction(easeBack)
-- end
if (self.m_operation) then
self.m_operation:stopAllActions()
local moveTo2 = cc.MoveTo:create(0.3, cc.p(display.width+300, 0))
local scaleTo2 = cc.ScaleTo:create(0.3, 1.0)
local array = CCArray:create()
array:addObject(moveTo2)
array:addObject(scaleTo2)
local easeBack2 = cc.EaseSineOut:create(cc.Spawn:create(array))
self.m_operation:runAction(easeBack2)
end
end
function LOperationMenu:showOperationMenu()
-- if (self.m_direction) then
-- self.m_direction:setTouchEnabled(true)
-- self.m_direction:stopAllActions()
--
-- local moveTo = cc.MoveTo:create(0.3, cc.p(120, 120))
-- local scaleTo = cc.ScaleTo:create(0.3, 0.8)
-- local easeBack = cc.EaseSineOut:create(cc.Spawn:create(moveTo, scaleTo, nil))
-- self.m_direction:runAction(easeBack)
-- end
if (self.m_operation) then
self.m_operation:stopAllActions()
local moveTo2 = cc.MoveTo:create(0.3, cc.p(display.width, 0))
local scaleTo2 = cc.ScaleTo:create(0.3, 1.0)
local array = CCArray:create()
array:addObject(moveTo2)
array:addObject(scaleTo2)
local easeBack2 = cc.EaseSineOut:create(cc.Spawn:create(array))
self.m_operation:runAction(easeBack2)
end
end
function LOperationMenu:joinEditState()
if (self.m_operation) then
self.m_operation:setPositionY(100)
local moveTo2 = cc.MoveTo:create(0.3, cc.p(display.width, 100))
local scaleTo2 = cc.ScaleTo:create(0.3, 1.0)
local array = CCArray:create()
array:addObject(moveTo2)
array:addObject(scaleTo2)
local easeBack2 = cc.EaseSineOut:create(cc.Spawn:create(array))
self.m_operation:runAction(easeBack2)
end
end
function LOperationMenu:getDrugsBtn()
return self.m_btnDrugs
end
function LOperationMenu:getDeliveryBtn()
return self.m_btnDelivery
end
function LOperationMenu:getCurrProgress()
return self.m_currProgress
end
function LOperationMenu:getMoveMethods()
return self.m_moveMethods
end
return LOperationMenu
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/game_ui/MapThumbnailLayer.lua
================================================
local MapPoint = require("app.map.MapPoint")
local centerPoint = cc.p(72, 93)
local lenght = 60
local scale = 1000
local function createIndicator(size)
return display.newRect(size, size, {color = ccc4f(255,255,255,255), fill = true})
end
local MapThumbnailScrollView = class("MapThumbnailScrollView", cc.ui.UIScrollView)
function MapThumbnailScrollView:ctor(params)
MapThumbnailScrollView.super.ctor(self, params)
self.m_rcView = params.viewRect
self.m_bIsMoved = false
self.m_beginPoint = cc.p(0, 0)
self:initWithMap()
end
function MapThumbnailScrollView:initWithMap()
self:setAnchorPoint(0, 0)
self:setBounceable(false)
local texture = g_mainScene:getCurrBgMap():getSmallMap():getTexture()
self.m_scrollNode = CCSprite:createWithTexture(texture)
self.m_scrollNode:setAnchorPoint(0, 0)
self.m_scrollNode:setPosition(0, 0)
self:addScrollNode(self.m_scrollNode)
self.m_pEndPoint = createIndicator(8)
self.m_pEndPoint:setLineColor(ccc4f(255,255,0,255))
self.m_scrollNode:addChild(self.m_pEndPoint)
self.m_pEndPoint:setPosition(-100, -100)
local blink = CCBlink:create(0.5, 1)
local repeatForever = CCRepeatForever:create(blink)
self.m_pEndPoint:runAction(repeatForever)
self.m_playerIndicator = display.newSprite("ui/self_indicator.png")
self.m_scrollNode:addChild(self.m_playerIndicator)
local x = g_player:getPositionX() * self.m_scrollNode:getContentSize().width / g_mainScene:getCurrBgMap():getBgSize().width
local y = g_player:getPositionY() * self.m_scrollNode:getContentSize().height / g_mainScene:getCurrBgMap():getBgSize().height
x = x - self.m_rcView.width / 2
y = y - self.m_rcView.height / 2
x = math.min(x, self.m_scrollNode:getContentSize().width - self.m_rcView.width)
x = math.max(x, 0)
y = math.min(y, self.m_scrollNode:getContentSize().height - self.m_rcView.height)
y = math.max(y, 0)
self.m_scrollNode:setPosition(-x, -y)
self:scheduleUpdate()
end
function MapThumbnailScrollView:update_(dt)
MapThumbnailScrollView.super.update_(self, dt)
local x = g_player:getPositionX() * self.m_scrollNode:getContentSize().width / g_mainScene:getCurrBgMap():getBgSize().width
local y = g_player:getPositionY() * self.m_scrollNode:getContentSize().height / g_mainScene:getCurrBgMap():getBgSize().height
self.m_playerIndicator:setPosition(x, y)
end
function MapThumbnailScrollView:onTouch_(event)
MapThumbnailScrollView.super.onTouch_(self, event)
if "began" == event.name and not self:isTouchInViewRect(event) then
return false
end
if event.name == "began" then
local bRet = self:onTouchBegan(event)
self:setTouchSwallowEnabled(bRet)
return bRet
elseif event.name == "moved" then
self:onTouchMoved(event)
elseif event.name == "ended" then
self:onTouchEnded(event)
elseif event.name == "cancel" then
self:onTouchCancelled(event)
end
end
function MapThumbnailScrollView:onTouchBegan(event)
self.m_beginPoint = cc.p(event.x, event.y)
return true
end
function MapThumbnailScrollView:onTouchMoved(event)
local point = cc.p(event.x, event.y)
if (cc.PointDistance(self.m_beginPoint, point) < 5) then
self.m_bIsMoved = true
end
end
function MapThumbnailScrollView:onTouchEnded(event)
if (self.m_bIsMoved) then
self.m_bIsMoved = false
return
end
local point = cc.p(event.x, event.y)
local point = self.m_scrollNode:convertToNodeSpace(point)
self.m_pEndPoint:setPosition(point)
local x = point.x * g_mainScene:getCurrBgMap():getBgSize().width / self.m_scrollNode:getContentSize().width
local y = point.y * g_mainScene:getCurrBgMap():getBgSize().height / self.m_scrollNode:getContentSize().height
g_player:goTo(MapPoint.new(cc.p(x, y)))
end
local MapThumbnailLayer = class("MapThumbnailLayer", function()
return display.newLayer()
end)
function MapThumbnailLayer:ctor()
local bg = display.newSprite("ui/bg_map_layer.png")
bg:setPosition(display.cx, display.cy)
self:addChild(bg)
local bound = cc.rect(0, 0, 600, 480)
self.m_nMap = MapThumbnailScrollView.new({viewRect = bound})
self.m_nMap:setPosition(43, 43)
bg:addChild(self.m_nMap)
local szBg = bg:getContentSize()
local szBtn = cc.size(57, 58)
local PUSH_BUTTON_IMAGES = {
normal = "ui/closed_normal.png",
pressed = "ui/closed_selected.png",
disabled = "ui/closed_normal.png",
}
local btn = cc.ui.UIPushButton.new(PUSH_BUTTON_IMAGES, {scale9 = true})
btn:setButtonSize(szBtn.width, szBtn.height)
local point = cc.PointAdd(cc.p(bg:getPosition()), cc.p(szBg.width/2, szBg.height/2))
point = cc.PointSub(point, cc.p(szBtn.width/2, szBtn.height/2))
btn:setAnchorPoint(0.5, 0.5)
btn:setPosition(point)
btn:onButtonClicked(handler(self, self.onBtn_Close))
self:addChild(btn)
end
function MapThumbnailLayer:onBtn_Close(event)
self:removeFromParent()
end
local MapThumbnailMenu = class("MapThumbnailMenu", function()
return display.newSprite("ui/mapThumbnail.png")
end)
function MapThumbnailMenu:ctor()
self.m_mapEnemySp = {}
self.m_arrEnemyKey = {}
local bg = display.newSprite("ui/bg_mapThumbnail.png")
bg:setAnchorPoint(0, 0)
self:addChild(bg, -2)
self.m_playerIndicator = createIndicator(4)
self.m_playerIndicator:setPosition(centerPoint)
self:addChild(self.m_playerIndicator, -1)
self.m_pCoordinateTTF = CCLabelTTF:create("", "Helvetica-Bold", 12)
self.m_pCoordinateTTF:setPosition(centerPoint.x, 16)
self:addChild(self.m_pCoordinateTTF)
self:addNodeEventListener(cc.NODE_TOUCH_EVENT, function(event)
if event.name == "began" then
local bRet = self:onTouchBegan(event)
self:setTouchSwallowEnabled(bRet)
return bRet
elseif event.name == "moved" then
self:onTouchMoved(event)
elseif event.name == "ended" then
self:onTouchEnded(event)
elseif event.name == "cancel" then
self:onTouchCancelled(event)
end
end)
self:setTouchEnabled(true)
self:addNodeEventListener(cc.NODE_ENTER_FRAME_EVENT, function(...)
self:update_(...)
end)
self:scheduleUpdate()
end
function MapThumbnailMenu:update_(dt)
local mapEnemy = g_mainScene:getEnemyDictionary()
if (not mapEnemy) then
return
end
for i = 1, #self.m_arrEnemyKey do
local key = self.m_arrEnemyKey[i]
local enemy = mapEnemy[key]
if (not enemy) then
local enemyIndicator = self.m_mapEnemySp[key]
self.m_mapEnemySp[key] = nil
enemyIndicator:removeFromParent()
else
local distance = cc.PointDistance(cc.p(g_player:getPosition()), cc.p(enemy:getPosition()))
if (distance > scale) then
local enemyIndicator = self.m_mapEnemySp[key]
self.m_mapEnemySp[key] = nil
enemyIndicator:removeFromParent()
end
end
end
self.m_arrEnemyKey = {}
for key, enemy in pairs(mapEnemy) do
local distance = cc.PointDistance(cc.p(g_player:getPosition()), cc.p(enemy:getPosition()))
if (distance <= scale) then
table.insert(self.m_arrEnemyKey, key)
local distanceX = enemy:getPositionX() - g_player:getPositionX()
local distanceY = enemy:getPositionY() - g_player:getPositionY()
local x = lenght * distanceX/scale + centerPoint.x
local y = lenght * distanceY/scale + centerPoint.y
local enemyIndicator = self.m_mapEnemySp[key]
if (not enemyIndicator) then
enemyIndicator = createIndicator(2)
enemyIndicator:setLineColor(ccc4f(255,0,0,255))
self:addChild(enemyIndicator, -1)
self.m_mapEnemySp[key] = enemyIndicator
end
enemyIndicator:setPosition(x, y)
end
end
local point = cc.p(g_player:getPositionX()/10, g_player:getPositionY()/10)
local str = string.format("X:%03d Y:%03d", point.x, point.y)
self.m_pCoordinateTTF:setString(str)
end
function MapThumbnailMenu:onTouchBegan(event)
local point = cc.p(event.x, event.y)
point = self:convertToNodeSpace(point)
if (cc.PointDistance(point, centerPoint) <= lenght) then
return true
end
return false
end
function MapThumbnailMenu:onTouchMoved(event)
end
function MapThumbnailMenu:onTouchEnded(event)
if (g_mainScene:getGameInfoUIController():getChildByTag(0xff00f)) then
return
end
local map = MapThumbnailLayer.new()
g_mainScene:getGameInfoUIController():addChild(map, 0, 0xff00f)
end
function MapThumbnailMenu:onTouchCancelled(event)
end
return MapThumbnailMenu
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/game_ui/ProgressAutomatic.lua
================================================
local scheduler = require("framework.scheduler")
local ProgressAutomatic = class("ProgressAutomatic", function(sprite)
return CCProgressTimer:create(sprite)
end)
function ProgressAutomatic:ctor(sprite)
local sprite2 = CCSprite:createWithTexture(sprite:getTexture())
sprite2:setColor(ccc3(100, 100, 100))
local szContent = self:getContentSize()
sprite2:setPosition(szContent.width/2, szContent.height/2)
self:addChild(sprite2, -1)
self:setNodeEventEnabled(true)
end
function ProgressAutomatic:onExit()
if (self.handle) then
scheduler.unscheduleGlobal(self.handle)
self.handle = nil
end
end
function ProgressAutomatic:RunCoolingAction(fDelay)
if (self:getPercentage() < 100.0) then
return
end
self:setPercentage(0)
self.m_fInterval = 100 / (fDelay * 60)
if (self.handle) then
scheduler.unscheduleGlobal(self.handle)
self.handle = nil
end
self.handle = scheduler.scheduleGlobal(handler(self, self.updateCoolingAction), 0)
end
function ProgressAutomatic:updateCoolingAction(dt)
local fPercentage = self:getPercentage()
local percentage = fPercentage + self.m_fInterval
self:setPercentage(percentage)
if (percentage >= 100.0) then
if (self.handle) then
scheduler.unscheduleGlobal(self.handle)
self.handle = nil
end
end
end
function ProgressAutomatic:RunCoolingNotAction(fDelay)
if (self:getPercentage() < 100.0) then
return
end
self:setPercentage(0)
local delayTime = cc.DelayTime:create(fDelay)
local callFunc = cc.CallFunc:create(handler(self, self.setCoolingFalse))
local sequence = cc.Sequence:create(delayTime, callFunc, nil)
self:runAction(sequence)
end
function ProgressAutomatic:setCoolingFalse()
self:setPercentage(100)
end
return ProgressAutomatic
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/game_ui/PropColumn.lua
================================================
local MapPoint = require("app.map.MapPoint")
local BgMap = require("app.map.BgMap")
local PropIconShow = require("app.prop_system.PropIconShow")
local GRID_WIDTH = 39
local GRID_HEIGHT = 35
local PROP_X = 88
local PROP_Y = 80
local COL = 10
local ROW = 6
local PropColumnMenu = class("PropColumnMenu", function()
return display.newLayer()
end)
function PropColumnMenu:ctor()
self.m_className = "PropColumnMenu"
self.m_editProp = nil
self.m_propVec = {}
self:init()
end
function PropColumnMenu:onEnter()
self:updatePropVecPoint()
end
function PropColumnMenu:init()
local bg = display.newSprite("ui/prop_column.png")
self:addChild(bg)
self.m_propColumn = CCLayerColor:create(ccc4(255, 255, 255, 0), GRID_WIDTH*COL, GRID_HEIGHT*ROW)
self.m_propColumn:setContentSize(GRID_WIDTH*COL, GRID_HEIGHT*ROW)
self.m_propColumn:setPosition(PROP_X, PROP_Y)
bg:addChild(self.m_propColumn)
local ptBg = cc.p(bg:getPosition())
local szBg = bg:getContentSize()
local szBtn = cc.size(57, 58)
local PUSH_BUTTON_IMAGES = {
normal = "ui/closed_normal.png",
pressed = "ui/closed_selected.png",
disabled = "ui/closed_normal.png",
}
local btn = cc.ui.UIPushButton.new(PUSH_BUTTON_IMAGES, {scale9 = true})
btn:setButtonSize(szBtn.width, szBtn.height)
local ptBtn = cc.PointAdd(ptBg, cc.p(szBg.width/2, szBg.height/2))
ptBtn = cc.PointSub(ptBtn, cc.p(szBtn.width/2, szBtn.height/2))
btn:setPosition(ptBtn)
btn:setAnchorPoint(0.5, 0.5)
btn:onButtonClicked(handler(g_mainScene:getGameInfoUIController(), g_mainScene:getGameInfoUIController().removeSmallMenuAndButton))
self:addChild(btn)
for i = 1, 12 do
self.m_propVec[i-1] = PropIconShow.new(g_propSystem:getPropInfo(i))
self.m_propColumn:addChild(self.m_propVec[i-1])
end
self:updatePropVecPoint()
self:addNodeEventListener(cc.NODE_TOUCH_EVENT, function(event)
if event.name == "began" then
local bRet = self:onTouchBegan(event)
self:setTouchSwallowEnabled(bRet)
return bRet
elseif event.name == "moved" then
self:onTouchMoved(event)
elseif event.name == "ended" then
self:onTouchEnded(event)
elseif event.name == "cancel" then
self:onTouchCancelled(event)
end
end)
self:setTouchEnabled(true)
return true
end
function PropColumnMenu:updatePropVecPoint()
for j = 0, ROW-1 do
for i = 0, COL-1 do
if (self.m_propVec[j*COL+i]) then
self.m_propVec[j*COL+i]:setPosition(GRID_WIDTH * (i+0.5), GRID_HEIGHT * (ROW-j-0.5))
end
end
end
end
function PropColumnMenu:getPropRect(i)
local rect = cc.rect(0,0,0,0)
local x = math.floor(i % COL)
local y = math.floor(i / COL)
rect.origin = cc.p(GRID_WIDTH * x, GRID_HEIGHT * (ROW-y-1))
rect.origin = self.m_propColumn:convertToWorldSpace(rect.origin)
rect.size = cc.size(GRID_WIDTH, GRID_HEIGHT)
return rect
end
function PropColumnMenu:getPropPoint(i)
local x = math.floor(i % COL)
local y = math.floor(i / COL)
return cc.p(GRID_WIDTH * (x+0.5), GRID_HEIGHT * (ROW-y-0.5))
end
function PropColumnMenu:propHoming(i)
if (i < COL*ROW and self.m_propVec[i]) then
local point = self:getPropPoint(i)
self.m_propVec[i]:setPosition(point)
end
end
function PropColumnMenu:swapProp(a, b)
if (a < COL*ROW and b < COL*ROW) then
local tmp = self.m_propVec[a]
self.m_propVec[a] = self.m_propVec[b]
self.m_propVec[b] = tmp
end
self:propHoming(a)
self:propHoming(b)
end
function PropColumnMenu:onTouchBegan(event)
local point = cc.p(event.x, event.y)
local rect = cc.rect(0,0,0,0)
rect.origin = self.m_propColumn:convertToWorldSpace(cc.p(0,0))
rect.size = self.m_propColumn:getContentSize()
if (not rect:containsPoint(point)) then
return false
end
for i = 0, COL*ROW-1 do
if (self.m_propVec[i] and self:getPropRect(i):containsPoint(point)) then
self.m_propVec[i]:setVisible(false)
self.m_editProp = PropIconShow.new(self.m_propVec[i].m_propInfo)
self.m_editProp:setPosition(point)
g_mainScene:getGameInfoUIController():addChild(self.m_editProp)
self.m_editProp:setTag(i)
self.m_editProp:setOpacity(127)
break
end
end
if (not self.m_editProp) then
return false
end
return true
end
function PropColumnMenu:onTouchMoved(event)
local point = cc.p(event.x, event.y)
self.m_editProp:setPosition(point)
local btn = g_mainScene:getGameInfoUIController():getOperationMenu():getDrugsBtn()
local rect = cc.rect(0,0,0,0)
rect.origin = btn:convertToWorldSpace(cc.p(0,0))
rect.size = btn:getContentSize()
if (rect:containsPoint(point)) then
if (self.m_editProp:getOpacity() == 255) then
return
end
self.m_editProp:setOpacity(255)
btn:stopAllActions()
local scaleTo = cc.ScaleTo:create(0.1, 1.1)
btn:runAction(scaleTo)
else
if (self.m_editProp:getOpacity() == 127) then
return
end
self.m_editProp:setOpacity(127)
btn:stopAllActions()
local scaleTo = cc.ScaleTo:create(0.1, 1.0)
btn:runAction(scaleTo)
end
end
function PropColumnMenu:onTouchEnded(event)
local point = cc.p(event.x, event.y)
local rect = cc.rect(0,0,0,0)
rect.origin = self.m_propColumn:convertToWorldSpace(cc.p(0,0))
rect.size = self.m_propColumn:getContentSize()
if (rect:containsPoint(point)) then
point = self.m_propColumn:convertToNodeSpace(point)
local x = math.floor(point.x / GRID_WIDTH)
local y = math.floor(point.y / GRID_HEIGHT)
y = ROW - y - 1
self.m_propVec[self.m_editProp:getTag()]:setVisible(true)
self:swapProp(self.m_editProp:getTag(), y*COL+x)
else
if (self.m_editProp:getOpacity() == 255) then
g_mainScene:getGameInfoUIController():getOperationMenu():addDrugs(2001)
local btn = g_mainScene:getGameInfoUIController():getOperationMenu():getDrugsBtn()
btn:stopAllActions()
local scaleTo = cc.ScaleTo:create(0.1, 1.0)
btn:runAction(scaleTo)
self.m_propVec[self.m_editProp:getTag()]:removeFromParent()
self.m_propVec[self.m_editProp:getTag()] = nil
else
local r = math.random()
if (r == 1) then
r = 0
end
local bgMap = g_mainScene:getCurrBgMap()
local playerPosition = MapPoint.new(cc.p(g_player:getPosition()))
local ptZero = MapPoint.new(0, 0)
local point = ptZero
local mapVec = {}
local lenght = 1
while (true) do
mapVec = playerPosition:getMapPointVectorForDistance(lenght)
local index = 0
for index = 1, #mapVec do
if (not g_mainScene:getMapPointForProp(mapVec[index])) then
point = mapVec[index]
end
end
if (not point:equalsObj(ptZero)) then
break
end
lenght = lenght + 1
end
local show = self.m_propVec[self.m_editProp:getTag()]
self.m_propVec[self.m_editProp:getTag()] = nil
show:setVisible(true)
show:retain()
show:removeFromParent()
show:setPosition(point:getCCPointValue())
bgMap:addChild(show, BgMap.getZOrderZero(bgMap))
show:release()
show:setScale(0.8)
g_mainScene:insterMapPointForProp(show, point)
show:setOpacity(0)
local fadeIn = cc.FadeIn:create(0.1)
local jumpBy = cc.JumpBy:create(0.3, cc.p(0, 0), 30, 1)
local array = CCArray:create()
array:addObject(fadeIn)
array:addObject(jumpBy)
local spawn = cc.Spawn:create(array)
show:runAction(spawn)
end
end
self.m_editProp:removeFromParent()
self.m_editProp = nil
end
function PropColumnMenu:onTouchCancelled(event)
end
return PropColumnMenu
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/game_ui/SkillTableView.lua
================================================
local SkillTableView = class("SkillTableView", function()
return display.newNode()
end)
function SkillTableView:ctor()
self.m_className = "SkillTableView"
self.m_pEditingSkill = nil
self.m_pEditingBtn = nil
self.m_arrSkill = {}
self:init()
end
function SkillTableView:init()
self:setAnchorPoint(0.5, 0.5)
local szBg = cc.size(450, 500)
local ptBg = cc.p(szBg.width/-2, szBg.height/-2)
local bg = CCLayerColor:create(ccc4(255, 255, 255, 127), szBg.width, szBg.height)
bg:setPosition(ptBg)
self:addChild(bg, -1)
local title = CCLabelTTF:create("技能列表", "fonts/Marker Felt.ttf", 40)
title:setPosition(szBg.width/2, szBg.height-30)
bg:addChild(title)
local szBtn = cc.size(57, 58)
local PUSH_BUTTON_IMAGES = {
normal = "ui/closed_normal.png",
pressed = "ui/closed_selected.png",
disabled = "ui/closed_normal.png",
}
local btn = cc.ui.UIPushButton.new(PUSH_BUTTON_IMAGES, {scale9 = true})
btn:setButtonSize(szBtn.width, szBtn.height)
local ptBtn = cc.PointAdd(ptBg, cc.p(szBg.width, szBg.height))
ptBtn = cc.PointSub(ptBtn, cc.p(szBtn.width/2, szBtn.height/2))
btn:setPosition(ptBtn)
btn:setAnchorPoint(0.5, 0.5)
btn:onButtonClicked(handler(g_mainScene:getGameInfoUIController(), g_mainScene:getGameInfoUIController().removeSmallMenuAndButton))
self:addChild(btn)
self.m_lvSkill = cc.ui.UIListView.new({
-- bgColor = cc.c4b(200, 200, 200, 120),
-- bg = "sunset.png",
viewRect = cc.rect(0, 0, 420, 420),
direction = cc.ui.UIScrollView.DIRECTION_VERTICAL,
-- scrollbarImgV = "bar.png"
})
self.m_lvSkill:setPosition(15, 15)
self.m_lvSkill:setAlignment(cc.ui.UIListView.ALIGNMENT_LEFT)
bg:addChild(self.m_lvSkill)
-- add items
for i = 1, 9 do
local item = self.m_lvSkill:newItem()
local fileName = string.format("ui/skill/skill_%d.png", 2000 + i)
item:setBg("ui/cell.png")
local content = cc.ui.UIImage.new(fileName)
content:setAnchorPoint(0.5, 0.5)
content:addNodeEventListener(cc.NODE_TOUCH_EVENT, function(event)
local point = cc.p(event.x, event.y)
if event.name == "began" then
self.m_pEditingSkill = CCSprite:createWithTexture(content:getTexture())
self.m_pEditingSkill:setPosition(point)
g_mainScene:getGameInfoUIController():addChild(self.m_pEditingSkill)
self.m_pEditingSkill:setTag(content:getParent():getTag())
self.m_pEditingSkill:setScale(1.5)
self.m_pEditingSkill:setOpacity(127)
content:setTouchSwallowEnabled(true)
return true
elseif event.name == "moved" then
if (not self.m_pEditingSkill) then
return
end
self.m_pEditingSkill:setPosition(point)
if (self.m_pEditingBtn) then
local rect = cc.rect(0,0,0,0)
rect.origin = self.m_pEditingBtn:convertToWorldSpace(cc.p(0,0))
rect.size = self.m_pEditingBtn:getContentSize()
if (not rect:containsPoint(point)) then
self.m_pEditingSkill:setOpacity(127)
self.m_pEditingBtn:stopAllActions()
local scaleTo = cc.ScaleTo:create(0.1, 1.0)
self.m_pEditingBtn:runAction(scaleTo)
self.m_pEditingBtn = nil
end
end
if (not self.m_pEditingBtn) then
for i = 1, 3 do
local btn = g_mainScene:getGameInfoUIController():getOperationMenu():getSkillAttackBtn(i)
local rect = cc.rect(0,0,0,0)
rect.origin = btn:convertToWorldSpace(cc.p(0,0))
rect.size = cc.size(75,75) -- btn:getButtonSize()
rect.origin.x = rect.origin.x - rect.size.width/2 -- 因为按钮锚点是(0.5,0.5),所以这里修正一下
rect.origin.y = rect.origin.y - rect.size.height/2
if (rect:containsPoint(point)) then
self.m_pEditingSkill:setOpacity(255)
self.m_pEditingBtn = btn
self.m_pEditingBtn:stopAllActions()
local scaleTo = cc.ScaleTo:create(0.1, 1.1)
self.m_pEditingBtn:runAction(scaleTo)
break
end
end
end
elseif event.name == "ended" then
if (self.m_pEditingSkill) then
if (self.m_pEditingBtn) then
g_mainScene:getGameInfoUIController():getOperationMenu():addSkillIcon_(self.m_pEditingBtn, self.m_pEditingSkill:getTag())
local scaleTo = cc.ScaleTo:create(0.1, 1.0)
self.m_pEditingBtn:runAction(scaleTo)
self.m_pEditingBtn = nil
end
self.m_pEditingSkill:removeFromParent()
self.m_pEditingSkill = nil
end
end
end)
content:setTouchEnabled(true)
item:addContent(content)
item:setItemSize(420, 80)
item:setMargin({left = 30, bottom = 26, right = 0, top = 0})
item:setTag(2000 + i)
self.m_lvSkill:addItem(item)
table.insert(self.m_arrSkill, content)
end
self.m_lvSkill:reload()
return true
end
function SkillTableView:onTouchBegan(event)
-- local point = cc.p(event.x, event.y)
--
-- local rcListView = cc.rect(0,0,0,0)
-- rcListView.origin = self.m_lvSkill:getParent():convertToWorldSpace(cc.p(self.m_lvSkill:getPosition()))
-- rcListView.size = cc.size(420, 420)
--
-- if (not rcListView:containsPoint(point)) then
-- return false
-- end
--
-- if (#self.m_arrSkill == 0) then
-- return false
-- end
--
-- for i = 1, #self.m_arrSkill do
-- local imgSkillIcon = self.m_arrSkill[i]
-- local szSkillIcon = imgSkillIcon:getContentSize()
-- local ptSkillIcon = cc.p(imgSkillIcon:getPosition())
-- ptSkillIcon = imgSkillIcon:getParent():convertToWorldSpace(ptSkillIcon)
-- ptSkillIcon = cc.PointSub(ptSkillIcon, cc.p(szSkillIcon.width/2, szSkillIcon.height/2))
-- local rect = cc.rect(ptSkillIcon.x, ptSkillIcon.y, szSkillIcon.width, szSkillIcon.height)
-- if (rect:containsPoint(point)) then
-- self.m_pEditingSkill = CCSprite:createWithTexture(imgSkillIcon:getTexture())
-- self.m_pEditingSkill:setPosition(point)
-- g_mainScene:getGameInfoUIController():addChild(self.m_pEditingSkill)
-- self.m_pEditingSkill:setTag(imgSkillIcon:getParent():getTag())
-- self.m_pEditingSkill:setScale(1.5)
-- self.m_pEditingSkill:setOpacity(127)
-- return true
-- end
-- end
--
-- return false
end
function SkillTableView:onTouchMoved(event)
-- local point = cc.p(event.x, event.y)
--
-- if (not self.m_pEditingSkill) then
-- return
-- end
--
-- self.m_pEditingSkill:setPosition(point)
--
-- if (self.m_pEditingBtn) then
-- local rect = cc.rect(0,0,0,0)
-- rect.origin = self.m_pEditingBtn:convertToWorldSpace(cc.p(0,0))
-- rect.size = self.m_pEditingBtn:getContentSize()
-- if (not rect:containsPoint(point)) then
-- self.m_pEditingSkill:setOpacity(127)
-- self.m_pEditingBtn:stopAllActions()
-- local scaleTo = cc.ScaleTo:create(0.1, 1.0)
-- self.m_pEditingBtn:runAction(scaleTo)
-- self.m_pEditingBtn = nil
-- end
-- end
--
-- if (not self.m_pEditingBtn) then
-- for i = 1, 3 do
-- local btn = g_mainScene:getGameInfoUIController():getOperationMenu():getSkillAttackBtn(i)
-- local rect = cc.rect(0,0,0,0)
-- rect.origin = btn:convertToWorldSpace(cc.p(0,0))
-- rect.size = btn:getContentSize()
--
-- if (rect:containsPoint(point)) then
-- self.m_pEditingSkill:setOpacity(255)
-- self.m_pEditingBtn = btn
-- self.m_pEditingBtn:stopAllActions()
-- local scaleTo = cc.ScaleTo:create(0.1, 1.1)
-- self.m_pEditingBtn:runAction(scaleTo)
-- break
-- end
-- end
-- end
end
function SkillTableView:onTouchEnded(event)
-- if (self.m_pEditingSkill) then
-- if (self.m_pEditingBtn) then
-- g_mainScene:getGameInfoUIController():getOperationMenu():addSkillIcon(self.m_pEditingBtn, self.m_pEditingSkill:getTag())
-- local scaleTo = cc.ScaleTo:create(0.1, 1.0)
-- self.m_pEditingBtn:runAction(scaleTo)
-- self.m_pEditingBtn = nil
-- end
-- self.m_pEditingSkill:removeFromParent()
-- self.m_pEditingSkill = nil
-- end
end
function SkillTableView:onTouchCancelled(event)
end
return SkillTableView
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/map/AStarSearch.lua
================================================
SEARCH_STATE_NOT_INITIALISED = 0
SEARCH_STATE_SEARCHING = 1
SEARCH_STATE_SUCCEEDED = 2
SEARCH_STATE_FAILED = 3
SEARCH_STATE_OUT_OF_MEMORY = 4
SEARCH_STATE_INVALID = 5
-- 对array[first..last]进行堆筛选
function sift_heap(array, first, last)
local i = first -- 被筛选结点索引
local j = 2 * i -- 被筛选结点的左孩子索引
local temp = array[i] -- 保存被筛选结点
while (j <= last) do
if (j < last and array[j].f > array[j + 1].f) then
j = j + 1 -- 若右孩子较小,把j指向右孩子
end
if (temp.f > array[j].f) then
array[i] = array[j] -- 将array[j]调整到双亲结点位置上
i = j -- 修改i和j值,指向下一个被筛选结点和被筛选结点的左孩子
j = 2 * i
else
break -- 已是小根堆,筛选结束
end
end
array[i] = temp -- 被筛选结点的值放入最终位置
end
-- 建立初始小根堆
function make_heap(array, first, last)
local n = last - first + 1
for i = math.floor(n/2), 1, -1 do
sift_heap(array, i, n)
end
end
-- 往小根堆中插入一个结点
function push_heap(array, first, last)
make_heap(array, first, last)
end
-- 从小根堆中弹出一个结点
function pop_heap(array, first, last)
array[first], array[last] = array[last], array[first]
make_heap(array, first, last-1)
end
-- 打印数组
function print_heap(array)
str = ""
for i = 1, #array do
str = str .. array[i] .. ","
end
print("#######################", str)
end
-- The AStar search class.
local AStarSearch = class("AStarSearch")
local Node = class("Node")
function Node:ctor()
self.parent = nil -- used during the search to record the parent of successor nodes
self.child = nil -- used after the search for the application to view the search in reverse
self.g = 0.0 -- cost of this node + it's predecessors
self.h = 0.0 -- heuristic estimate of distance to goal
self.f = 0.0 -- sum of cumulative cost of predecessors and self and heuristic
self.m_UserState = nil
end
-- constructor just initialises private data
function AStarSearch:ctor(nMaxNodes)
self.m_AllocateNodeCount = 0
self.m_State = SEARCH_STATE_NOT_INITIALISED
self.m_CurrentSolutionNode = nil
self.m_CancelRequest = false
-- Heap (simple vector but used as a heap, cf. Steve Rabin's game gems article)
self.m_OpenList = {}
-- Closed list is a vector.
self.m_ClosedList = {}
-- Successors is a vector filled out by the user each type successors to a node
-- are generated
self.m_Successors = {}
-- State
self.m_State = 0
-- Counts steps
self.m_Steps = 0
-- Start and goal state pointers
self.m_Start = nil
self.m_Goal = nil
self.m_CurrentSolutionNode = nil
-- Debug : need to keep these two iterators around
-- for the user Dbg functions
self.iterDbgOpen = 1
self.iterDbgClosed = 1
self.m_CancelRequest = false
end
-- call at any time to cancel the search and free up all the memory
function AStarSearch:cancelSearch()
self.m_CancelRequest = true
end
-- Set Start and goal states
function AStarSearch:setStartAndGoalStates(Start, Goal)
self.m_CancelRequest = false
self.m_Start = Node.new()
self.m_Goal = Node.new()
self.m_Start.m_UserState = Start
self.m_Goal.m_UserState = Goal
self.m_State = SEARCH_STATE_SEARCHING
-- Initialise the AStar specific parts of the Start Node
-- The user only needs fill out the state information
self.m_Start.g = 0
self.m_Start.h = self.m_Start.m_UserState:goalDistanceEstimate(self.m_Goal.m_UserState)
self.m_Start.f = self.m_Start.g + self.m_Start.h
self.m_Start.parent = nil
-- Push the start node on the Open list
table.insert(self.m_OpenList, self.m_Start) -- heap now unsorted
-- Sort back element into heap
push_heap(self.m_OpenList, 1, #self.m_OpenList)
-- Initialise counter for search steps
self.m_Steps = 0
end
-- Advances search one step
function AStarSearch:searchStep()
-- Firstly break if the user has not initialised the search
if (not ((self.m_State > SEARCH_STATE_NOT_INITIALISED) and
(self.m_State < SEARCH_STATE_INVALID))) then
return self.m_State
end
-- Next I want it to be safe to do a searchstep once the search has succeeded...
if ((self.m_State == SEARCH_STATE_SUCCEEDED) or
(self.m_State == SEARCH_STATE_FAILED)) then
return self.m_State
end
-- Failure is defined as emptying the open list as there is nothing left to
-- search...
-- New: Allow user abort
if (#self.m_OpenList <= 0 or self.m_CancelRequest) then
self:freeAllNodes()
self.m_State = SEARCH_STATE_FAILED
return self.m_State
end
-- Incremement step count
self.m_Steps = self.m_Steps + 1
-- Pop the best node (the one with the lowest f)
local n = self.m_OpenList[1] -- get pointer to the node
pop_heap(self.m_OpenList, 1, #self.m_OpenList)
table.remove(self.m_OpenList)
-- Check for the goal, once we pop that we're done
if (n.m_UserState:isGoal(self.m_Goal.m_UserState)) then
-- The user is going to use the Goal Node he passed in
-- so copy the parent pointer of n
self.m_Goal.parent = n.parent
-- A special case is that the goal was passed in as the start state
-- so handle that here
if (false == n.m_UserState:isSameState(self.m_Start.m_UserState)) then
n = nil
-- set the child pointers in each node (except Goal which has no child)
local nodeChild = self.m_Goal
local nodeParent = self.m_Goal.parent
repeat
nodeParent.child = nodeChild
nodeChild = nodeParent
nodeParent = nodeParent.parent
until (not (nodeChild ~= self.m_Start)) -- Start is always the first node by definition
end
-- delete nodes that aren't needed for the solution
self:freeUnusedNodes()
self.m_State = SEARCH_STATE_SUCCEEDED
return self.m_State
else -- not goal
-- We now need to generate the successors of this node
-- The user helps us to do this, and we keep the new nodes in
-- m_Successors ...
self.m_Successors = {} -- empty vector of successor nodes to n
-- User provides this functions and uses AddSuccessor to add each successor of
-- node 'n' to m_Successors
local ret = n.m_UserState:getSuccessors(self, (n.parent and n.parent.m_UserState) or nil)
if (not ret) then
-- free the nodes that may previously have been added
-- for i = 1, #self.m_Successors do
-- self.m_Successors[i] = nil
-- end
self.m_Successors = {} -- empty vector of successor nodes to n
-- free up everything else we allocated
self:freeAllNodes()
self.m_State = SEARCH_STATE_OUT_OF_MEMORY
return self.m_State
end
local successor = nil
-- Now handle each successor to the current node ...
for i = 1, #self.m_Successors do
successor = self.m_Successors[i]
-- The g value for this successor ...
local newg = n.g + n.m_UserState:getCost(successor.m_UserState)
-- Now we need to find whether the node is on the open or closed lists
-- If it is but the node that is already on them is better (lower g)
-- then we can forget about this successor
-- First linear search of open list to find node
local openlist_result = nil
local openlist_index = 1
for j = 1, #self.m_OpenList do
if (self.m_OpenList[j].m_UserState:isSameState(successor.m_UserState)) then
openlist_result = self.m_OpenList[j]
openlist_index = j
break
end
end
if (openlist_result and openlist_result.g <= newg) then
-- we found this state on open
successor = nil
-- the one on Open is cheaper than this one
-- continue
else
local closedlist_result = nil
local closedlist_index = 1
for j = 1, #self.m_ClosedList do
if (self.m_ClosedList[j].m_UserState:isSameState(successor.m_UserState)) then
closedlist_result = self.m_ClosedList[j]
closedlist_index = j
break
end
end
if (closedlist_result and closedlist_result.g <= newg) then
-- we found this state on closed
-- the one on Closed is cheaper than this one
successor = nil
-- continue
else
-- This node is the best node so far with this particular state
-- so lets keep it and set up its AStar specific data ...
successor.parent = n
successor.g = newg
successor.h = successor.m_UserState:goalDistanceEstimate(self.m_Goal.m_UserState)
successor.f = successor.g + successor.h
-- Remove successor from closed if it was on it
if (closedlist_result) then
-- remove it from Closed
table.remove(self.m_ClosedList, closedlist_index)
closedlist_result = nil
-- Fix thanks to ...
-- Greg Douglas
-- who noticed that this code path was incorrect
-- Here we have found a new state which is already CLOSED
-- anus
end
-- Update old version of this node
if (openlist_result) then
table.remove(self.m_OpenList, openlist_index)
openlist_result = nil
-- re-make the heap
-- make_heap rather than sort_heap is an essential bug fix
-- thanks to Mike Ryynanen for pointing this out and then explaining
-- it in detail. sort_heap called on an invalid heap does not work
make_heap(self.m_OpenList, 1, #self.m_OpenList)
end
-- heap now unsorted
table.insert(self.m_OpenList, successor)
-- sort back element into heap
push_heap(self.m_OpenList, 1, #self.m_OpenList)
end
end
end
-- push n onto Closed, as we have expanded it now
table.insert(self.m_ClosedList, n)
end -- end else (not goal so expand)
return self.m_State -- Succeeded bool is false at this point.
end
-- User calls this to add a successor to a list of successors
-- when expanding the search frontier
function AStarSearch:addSuccessor(state)
local node = Node.new()
if (node) then
node.m_UserState = state
table.insert(self.m_Successors, node)
return true
end
return false
end
-- Free the solution nodes
-- This is done to clean up all used Node memory when you are done with the
-- search
function AStarSearch:freeSolutionNodes()
local n = self.m_Start
if (self.m_Start.child) then
repeat
local del = n
n = n.child
del = nil
until (not (n ~= self.m_Goal))
n = nil -- Delete the goal
else
-- if the start node is the solution we need to just delete the start and goal
-- nodes
self.m_Start = nil
self.m_Goal = nil
end
end
-- Functions for traversing the solution
-- Get start node
function AStarSearch:getSolutionStart()
self.m_CurrentSolutionNode = self.m_Start
if (self.m_Start) then
return self.m_Start.m_UserState
else
return nil
end
end
-- Get next node
function AStarSearch:getSolutionNext()
if (self.m_CurrentSolutionNode) then
if (self.m_CurrentSolutionNode.child) then
local child = self.m_CurrentSolutionNode.child
self.m_CurrentSolutionNode = self.m_CurrentSolutionNode.child
return child.m_UserState
end
end
return nil
end
-- Get end node
function AStarSearch:getSolutionEnd()
self.m_CurrentSolutionNode = self.m_Goal
if (self.m_Goal) then
return self.m_Goal.m_UserState
else
return nil
end
end
-- Step solution iterator backwards
function AStarSearch:getSolutionPrev()
if (self.m_CurrentSolutionNode) then
if (self.m_CurrentSolutionNode.parent) then
local parent = self.m_CurrentSolutionNode.parent
self.m_CurrentSolutionNode = self.m_CurrentSolutionNode.parent
return parent.m_UserState
end
end
return nil
end
-- For educational use and debugging it is useful to be able to view
-- the open and closed list at each step, here are two functions to allow that.
function AStarSearch:getOpenListStart()
self.iterDbgOpen = 1
local iter = self.m_OpenList[self.iterDbgOpen]
if (not iter) then
return iter.f, iter.g, iter.h, iter.m_UserState
end
return nil
end
function AStarSearch:getOpenListNext()
self.iterDbgOpen = self.iterDbgOpen + 1
local iter = self.m_OpenList[self.iterDbgOpen]
if (not iter) then
return iter.f, iter.g, iter.h, iter.m_UserState
end
return nil
end
function AStarSearch:getClosedListStart()
self.iterDbgClosed = 1
local iter = self.m_ClosedList[self.iterDbgClosed]
if (not iter) then
return iter.f, iter.g, iter.h, iter.m_UserState
end
return nil
end
function AStarSearch:getClosedListNext()
self.iterDbgClosed = self.iterDbgClosed + 1
local iter = self.m_ClosedList[self.iterDbgClosed]
if (not iter) then
return iter.f, iter.g, iter.h, iter.m_UserState
end
return nil
end
-- Get the number of steps
function AStarSearch:getStepCount()
return self.m_Steps
end
function AStarSearch:ensureMemoryFreed()
-- assert(m_AllocateNodeCount == 0);
end
-- This is called when a search fails or is cancelled to free all used
-- memory
function AStarSearch:freeAllNodes()
self.m_OpenList = {}
self.m_ClosedList = {}
end
-- This call is made by the search class when the search ends. A lot of nodes may be
-- created that are still present when the search ends. They will be deleted by this
-- routine once the search ends
function AStarSearch:freeUnusedNodes()
self.m_OpenList = {}
self.m_ClosedList = {}
end
return AStarSearch
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/map/BgMap.lua
================================================
local cjson = require("cjson")
local scheduler = require("framework.scheduler")
local BgMapFloorTile = require("app.map.BgMapFloorTile")
local PortalSprite = require("app.map.PortalSprite")
local MapPoint = require("app.map.MapPoint")
local NpcFigure = require("app.map.NpcFigure")
PortalInformation = class("PortalInformation")
function PortalInformation:ctor(key, mapID, born, point)
self.key = key
self.mapID = mapID
self.born = born
self.point = point
end
function PortalInformation:equals(other)
return (self.key == other.key and
self.mapID == other.mapID and
self.born == other.born and
self.point:equals(other.point))
end
PortalInformationZero = PortalInformation.new(0, 0, 0, cc.p(0, 0))
local NpcInformation = class("NpcInformation")
function NpcInformation:ctor(key, direction, point)
self.key = key
self.direction = direction
self.point = point
end
function NpcInformation:equals(other)
return (self.key == other.key and
self.direction == other.direction and
self.point.equals(other.point))
end
NPCDirection = {
DownAndLeft = 5,
Down = 4,
RightAndDown = 3
}
local OFF_SIZE = cc.p(128, 128)
-- 背景地图类
local BgMap = class("BgMap", function()
return display.newNode()
end)
local RADIUS_PASSAGEWAY = 64
local TYPE_PROTAL = 100
local TYPE_BORN_POINT = 101
local TYPE_NPC = 200
local TYPE_ENEMY = 300
local TYPE_BACKGROUND_MUSIC = 400
function BgMap:ctor()
self.m_gridRow = 0
self.m_gridCol = 0
self.m_gridSize = cc.size(0, 0)
self.m_imageRow = 0
self.m_imageCol = 0
self.m_imageSize = cc.size(0, 0)
self.m_bgSize = cc.size(0, 0)
self.m_nMapID = 0
self.m_playerLead = nil
self.m_delegate = nil
self.m_grid = {}
self.m_arrPassageway = {}
self.m_mapBornPoint = {}
self.m_arrNpcInfo = {}
self.m_arrEnemy = {}
self.m_arrFloorTile = {}
self.m_arrNpcFigure = {}
end
-- 加载地图
function BgMap:loadMap(nMapID)
self.m_nMapID = nMapID
self:readGirdData()
self:readGoodsData()
local path = string.format("map/s%d/min_s%d.jpg", self.m_nMapID, self.m_nMapID)
self.m_spMap = display.newSprite(path)
self.m_spMap:setAnchorPoint(cc.p(0, 0))
self:addChild(self.m_spMap, BgMap.getZOrderZero(self))
self.m_spMap:setScale(10/3.0)
self:initBgMapFloorTile()
self:initBgMapPassagewayImage()
self:initNpcFigure()
self:updateImageDisplay()
-- if (self.m_backGroundMusic ~= "") then
-- audio.playMusic(self.m_backGroundMusic, true)
-- --audio.setBackgroundMusicVolume(0.2)
-- end
end
-- 卸载地图
function BgMap:unloadMap()
self:killTimer_UpdateMap()
self:setDelegate(nil)
CCTextureCache:sharedTextureCache():removeUnusedTextures()
end
function BgMap:readGirdData()
local path = string.format("map/s%d/data_gird_%d.json", self.m_nMapID, self.m_nMapID)
local json_str = CCString:createWithContentsOfFile(path)
local json_value = cjson.decode(json_str:getCString())
-- 地图宽高
local width = json_value["mapW"]
local height = json_value["mapH"]
self.m_bgSize = cc.size(width, height)
--
local gWidth = json_value["mapGridW"]
local gHeight = json_value["mapGridH"]
self.m_gridSize = cc.size(gWidth, gHeight)
MapPoint.setGridSize(self.m_gridSize)
self.m_gridRow = math.ceil(width/self.m_gridSize.width)
self.m_gridCol = math.ceil(height/self.m_gridSize.height)
self:initGridData(json_value["mapFlagArr"])
-- 切图宽高
local iWidth = json_value["divideBlockW"]
local iHeight = json_value["divideBlockH"]
self.m_imageSize = cc.size(iWidth, iHeight)
self.m_imageRow = math.ceil(width/self.m_imageSize.width)
self.m_imageCol = math.ceil(height/self.m_imageSize.height)
end
function BgMap:readGoodsData()
local path = string.format("map/s%d/data_goods_%d.json", self.m_nMapID, self.m_nMapID)
local json_str = CCString:createWithContentsOfFile(path)
local json_value = cjson.decode(json_str:getCString())
for i = 1, #json_value["items"] do
local goods = json_value["items"][i]
local itemType = goods["itemType"]
if (itemType == TYPE_PROTAL) then -- 传送点
local key = goods["itemSN"]
local mapID = goods["portalToMap"]
local born = goods["portalToPos"]
local point = cc.p(goods["itemPosX"], goods["itemPosY"])
local info = PortalInformation.new(key, mapID, born, point)
table.insert(self.m_arrPassageway, info)
elseif (itemType == TYPE_BORN_POINT) then --
local born = goods["itemSN"]
local point = cc.p(goods["itemPosX"], goods["itemPosY"])
self.m_mapBornPoint[born] = point
elseif (itemType == TYPE_NPC) then -- NPC
local key = goods["itemSN"]
local direction = goods["npcDirection"]
if (not direction) then
direction = NPCDirection.Down
end
local point = cc.p(goods["itemPosX"], goods["itemPosY"])
local info = NpcInformation.new(key, direction, point)
table.insert(self.m_arrNpcInfo, info)
elseif (itemType == TYPE_ENEMY) then -- 敌人
local key = goods["itemSN"]
local mpoint = MapPoint.new(cc.p(goods["itemPosX"], goods["itemPosY"]))
table.insert(self.m_arrEnemy, {["key"] = key, ["mpoint"] = mpoint})
elseif (itemType == TYPE_BACKGROUND_MUSIC) then -- 背景音乐
local key = goods["itemSN"]
self.m_backGroundMusic = string.format("music/400/%d.mp3", key)
end
end
end
function BgMap:initGridData(json_value)
-- self.m_grid = json_value
for i = 0, self.m_gridCol-1 do
self.m_grid[i] = {}
end
for i = 0, #json_value-1 do
self.m_grid[math.floor(i/self.m_gridRow)][i%self.m_gridRow] = json_value[i+1]
end
end
function BgMap:initBgMapFloorTile()
for i = 0, self.m_imageCol-1 do
for j = 0, self.m_imageRow-1 do
local floorTile = BgMapFloorTile.new()
local path = string.format("map/s%d/s%d_%d_%d.jpg", self.m_nMapID, self.m_nMapID, i, j)
floorTile.m_fileName = path
floorTile:setPosition(self.m_imageSize.width*j, self.m_imageSize.height*i)
self:addChild(floorTile, BgMap.getZOrderZero(self)) -- z轴
table.insert(self.m_arrFloorTile, floorTile)
end
end
end
function BgMap:initBgMapPassagewayImage()
for i = 1, #self.m_arrPassageway do
local point = self.m_arrPassageway[i].point
point = MapPoint.new(point):getCCPointValue()
-- 生成传送门
local value = BgMap.getZOrder(point) -- z轴
local sprite = PortalSprite.new("trans-")
sprite:setPosition(point)
self:addChild(sprite, value)
end
end
function BgMap:initNpcFigure()
for i = 1, #self.m_arrNpcInfo do
local npc = NpcFigure.new(self.m_arrNpcInfo[i].key, self.m_arrNpcInfo[i].direction)
npc:setPosition(self.m_arrNpcInfo[i].point)
self:addChild(npc, BgMap.getZOrder(cc.p(npc:getPosition())))
table.insert(self.m_arrNpcFigure, npc)
end
end
function BgMap:updateImageDisplay()
local rect = self:getShowRect()
local rect2 = self:getHideRect()
local nStartX = math.floor(rect.origin.x / self.m_imageSize.width)
local nStartY = math.floor(rect.origin.y / self.m_imageSize.height)
nStartX = math.max(nStartX, 0)
nStartY = math.max(nStartY, 0)
local nEndX = math.ceil((rect.origin.x+rect.size.width) / self.m_imageSize.width)
local nEndY = math.ceil((rect.origin.y+rect.size.height) / self.m_imageSize.height)
nEndX = math.min(nEndX, self.m_imageRow-1)
nEndY = math.min(nEndY, self.m_imageCol-1)
for i = nStartY, nEndY do
for j = nStartX, nEndX do
self.m_arrFloorTile[i*self.m_imageRow+j+1]:IntelligentDisplay(rect, rect2)
end
end
-- 显示地砖
-- for i = 1, #self.m_arrFloorTile do
-- self.m_arrFloorTile[i]:IntelligentDisplay(rect, rect2)
-- end
-- 显示NPC
for i = 1, #self.m_arrNpcFigure do
self.m_arrNpcFigure[i]:IntelligentDisplay(rect, rect2)
end
if (self.m_delegate) then
self.m_delegate:updateImageDisplay(rect, rect2)
end
-- CCTextureCache:sharedTextureCache():removeUnusedTextures()
end
-- 更新地图计时器回调函数
function BgMap:updateMap(fDelay)
if (not self.m_playerLead) then
return
end
local x, y = self.m_playerLead:getPosition()
local pMap = cc.PointSub(cc.p(display.cx, display.cy), cc.p(x, y))
pMap.x = math.max(pMap.x, display.width-self.m_bgSize.width)
pMap.y = math.max(pMap.y, display.height-self.m_bgSize.height)
pMap.x = math.min(pMap.x, 0)
pMap.y = math.min(pMap.y, 0)
self:setPosition(pMap)
self:updateImageDisplay()
end
function BgMap:getCurrentGridValue(mpoint)
local row = mpoint.x
local col = mpoint.z
local relust = 1
if (1 < col and col < self.m_gridCol-1 and 1 < row and row < self.m_gridRow-1) then
relust = self.m_grid[col][row]
end
return relust
end
function BgMap:isMapPassageway(node)
for i = 1, #self.m_arrPassageway do
local mapPassageway = self.m_arrPassageway[i]
if (cc.PointDistance(mapPassageway.point, cc.p(node:getPosition())) <= RADIUS_PASSAGEWAY) then
return mapPassageway
end
end
return PortalInformationZero
end
function BgMap:getEnemeyMap()
return self.m_arrEnemy
end
function BgMap:addChildPlayerLead(node, bornPoint)
local point = self.m_mapBornPoint[math.floor(bornPoint)]
point = MapPoint.new(point):getCCPointValue()
self:addChildPlayerLead_(node, point)
end
function BgMap:addChildPlayerLead_(node, point)
local x, y = self:getPosition()
local value = BgMap.getZOrder(cc.p(x, y)) -- z轴
self.m_playerLead = node
point = MapPoint.new(point)
point = point:getCCPointValue()
self.m_playerLead:setPosition(point)
self:addChild(self.m_playerLead, value)
self:updateMap()
end
function BgMap:getShowRect()
-- local rect = cc.rect(0, 0, 0, 0)
-- rect.origin = cc.PointSub(cc.p(0, 0), OFF_SIZE)
-- rect.origin = cc.PointSub(rect.origin, cc.p(self:getPosition()))
-- local point = cc.PointAdd(cc.p(display.width, display.height), cc.p(OFF_SIZE.x*2, OFF_SIZE.y*2))
-- rect.size = cc.size(point.x, point.y)
-- return rect
if (not self.m_tmpRect) then
self.m_tmpRect = cc.rect(0, 0, 0, 0)
end
self.m_tmpRect.origin.x = 0 - OFF_SIZE.x
self.m_tmpRect.origin.y = 0 - OFF_SIZE.y
self.m_tmpRect.origin.x = self.m_tmpRect.origin.x - self:getPositionX()
self.m_tmpRect.origin.y = self.m_tmpRect.origin.y - self:getPositionY()
self.m_tmpRect.size.width = display.width + OFF_SIZE.x*2
self.m_tmpRect.size.height = display.height + OFF_SIZE.y*2
return self.m_tmpRect
end
function BgMap:getHideRect()
-- local rect = cc.rect(0, 0, 0, 0)
-- rect.origin = cc.PointSub(cc.p(0, 0), cc.p(OFF_SIZE.x * 2, OFF_SIZE.y * 2))
-- rect.origin = cc.PointSub(rect.origin, cc.p(self:getPosition()))
-- local point = cc.PointAdd(cc.p(display.width, display.height), cc.p(OFF_SIZE.x*4, OFF_SIZE.y*4))
-- rect.size = cc.size(point.x, point.y)
-- return rect
if (not self.m_tmpRect) then
self.m_tmpRect = cc.rect(0, 0, 0, 0)
end
self.m_tmpRect.origin.x = 0 - OFF_SIZE.x * 2
self.m_tmpRect.origin.y = 0 - OFF_SIZE.y * 2
self.m_tmpRect.origin.x = self.m_tmpRect.origin.x - self:getPositionX()
self.m_tmpRect.origin.y = self.m_tmpRect.origin.y - self:getPositionY()
self.m_tmpRect.size.width = display.width + OFF_SIZE.x*4
self.m_tmpRect.size.height = display.height + OFF_SIZE.y*4
return self.m_tmpRect
end
function BgMap.getZOrder(point)
return (-point.y / 10.0)
end
function BgMap.getZOrderZero(bgMap)
return (-bgMap.m_bgSize.height / 10.0)
end
function BgMap:setDelegate(delegate)
self.m_delegate = delegate
end
function BgMap:getMapGrid()
return self.m_grid
end
function BgMap:getGridRow()
return self.m_gridRow
end
function BgMap:getGridCol()
return self.m_gridCol
end
-- 开启更新地图计时器
function BgMap:setTimer_UpdateMap()
self:killTimer_UpdateMap()
self.hUpdateMap = scheduler.scheduleGlobal(handler(self, self.updateMap), 0.01)
end
-- 关闭更新地图计时器
function BgMap:killTimer_UpdateMap()
if (self.hUpdateMap) then
scheduler.unscheduleGlobal(self.hUpdateMap)
self.hUpdateMap = nil
end
end
function BgMap:getSmallMap()
return self.m_spMap
end
function BgMap:getBgSize()
return self.m_bgSize
end
return BgMap
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/map/BgMapFloorTile.lua
================================================
-- 背景地图地砖类
local BgMapFloorTile = class("BgMapFloorTile", function()
return display.newNode()
end)
local OFF_SIZE = cc.p(128, 128)
function BgMapFloorTile:ctor()
self.m_fileName = nil
self.m_sprite = nil
self.m_bIsDisplay = false
end
function BgMapFloorTile:displayImageView()
if (self.m_bIsDisplay == false) then
self.m_bIsDisplay = true
display.addImageAsync(self.m_fileName, function()
local texture = CCTextureCache:sharedTextureCache():textureForKey(self.m_fileName)
self:initWithImageView(texture)
end)
end
end
function BgMapFloorTile:hideImageView()
if (self.m_bIsDisplay) then
self.m_bIsDisplay = false
if (self.m_sprite) then
self.m_sprite:removeFromParent()
self.m_sprite = nil
end
CCTextureCache:sharedTextureCache():removeTextureForKey(self.m_fileName)
end
end
function BgMapFloorTile:initWithImageView(texture)
if (not self.m_sprite) then
self.m_sprite = CCSprite:createWithTexture(texture)
self.m_sprite:setAnchorPoint(cc.p(0, 0))
self:addChild(self.m_sprite)
end
end
function BgMapFloorTile:IntelligentDisplay(rcShow, rcHide)
-- local x, y = self:getPosition()
-- local point = cc.PointAdd(cc.p(x, y), OFF_SIZE)
if (not self.m_tmpPos) then
self.m_tmpPos = cc.p(0, 0)
end
self.m_tmpPos.x, self.m_tmpPos.y = self:getPosition()
self.m_tmpPos.x = self.m_tmpPos.x + OFF_SIZE.x
self.m_tmpPos.y = self.m_tmpPos.y + OFF_SIZE.y
if (rcShow:containsPoint(self.m_tmpPos)) then
self:displayImageView()
end
if (not rcHide:containsPoint(self.m_tmpPos)) then
self:hideImageView()
end
end
return BgMapFloorTile
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/map/MapPoint.lua
================================================
--
local MapPoint = class("MapPoint")
local GRID_SIZE = cc.size(60, 32)
function MapPoint:ctor(x, z)
if (x and z) then
self.x = math.floor(x)
self.z = math.floor(z)
elseif (x) then
if type(x) == "number" then
self.x = math.floor(x / 65536)
self.z = math.floor(x % 65536)
else
self.x = math.floor(x.x/GRID_SIZE.width)
self.z = math.floor(x.y/GRID_SIZE.height)
end
else
self.x = 0
self.z = 0
end
end
function MapPoint:getValue()
return self.x * 65536 + self.z
end
function MapPoint:getCCPointValue()
local point = cc.p(self.x * GRID_SIZE.width, self.z * GRID_SIZE.height)
return cc.PointAdd(point, cc.p(GRID_SIZE.width/2, GRID_SIZE.height/2))
end
function MapPoint:getCCSizeValue()
return cc.size(self.x * GRID_SIZE.width, self.z * GRID_SIZE.height)
end
-- 赋值
function MapPoint.set(left, right)
left.x = right.x
left.z = right.z
return left
end
-- 相加
function MapPoint.add(left, right)
return MapPoint.new(left.x + right.x, left.z + right.z)
end
-- 相减
function MapPoint.sub(left, right)
return MapPoint.new(left.x - right.x, left.z - right.z)
end
-- 负号
function MapPoint.minus(self)
return MapPoint.new(-self.x, -self.z)
end
-- 乘以一个数
function MapPoint.mul(self, a)
return MapPoint.new(self.x * a, self.z * a)
end
-- 除以一个数
function MapPoint.div(self, a)
error(a, "CCPoint division by 0.");
return MapPoint.new(self.x / a, self.z / a)
end
-- 小于
function MapPoint.less(left, right)
local a = left.x * 65536 + left.z
local b = right.x * 65536 + right.z
return (a < b)
end
-- 相等
function MapPoint.equals(left, right)
local a = left.x * 65536 + left.z
local b = right.x * 65536 + right.z
return (a == b)
end
-- 对象值相等
function MapPoint.equalsObj(left, right)
return (left.x == right.x and left.z == right.z)
end
function MapPoint:getMapPointVectorForDistance(lenght)
local arrMPoint = {}
local x = -lenght
local z = -lenght
while (true) do
if (#arrMPoint == 8*lenght) then
break
end
table.insert(arrMPoint, MapPoint.add(self, MapPoint.new(x, z)))
if (#arrMPoint <= 2*lenght) then
x = x + 1
elseif (2*lenght < #arrMPoint and #arrMPoint <= 4*lenght) then
z = z + 1
elseif (4*lenght < #arrMPoint and #arrMPoint <= 6*lenght) then
x = x - 1
elseif (6*lenght < #arrMPoint and #arrMPoint < 8*lenght) then
z = z - 1
end
end
return arrMPoint
end
function MapPoint.setGridSize(size)
GRID_SIZE = size
end
function MapPoint:getLength()
return math.floor(math.max(math.abs(self.x), math.abs(self.z)))
end
function MapPoint:getDistance(mpoint)
return math.floor(math.max(math.abs(mpoint.x - self.x), math.abs(mpoint.z - self.z)))
end
return MapPoint
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/map/NpcFigure.lua
================================================
local LAlertView = require("app.game_ui.LAlertView")
local NpcFigure = class("NpcFigure", function()
return display.newSprite()
end)
function NpcFigure:ctor(roleNumber, direction)
self.m_npcInfo = nil
self.m_direction = direction
self.m_sprite = nil
self.m_bIsDisplay = false
self.m_fAnchorPoint = cc.p(0.5, 3/8.0)
self.m_fSpriteRect = cc.rect(80, 64, 50, 96)
self.m_npcInfo = g_npcInfoSystem:getNpcInfo(roleNumber)
self.m_fileName = string.format("texture_npc/npc_%u_1_%d.png", self.m_npcInfo.m_nRID, self.m_direction)
self.m_plistName = string.format("texture_npc/npc_%u_1_%d.plist", self.m_npcInfo.m_nRID, self.m_direction)
self.m_arrAction = CCArray:create()
self.m_arrAction:retain()
self:addNodeEventListener(cc.NODE_TOUCH_EVENT, function(event)
if event.name == "began" then
local bRet = self:onTouchBegan(event)
self:setTouchSwallowEnabled(bRet)
return bRet
elseif event.name == "moved" then
self:onTouchMoved(event)
elseif event.name == "ended" then
self:onTouchEnded(event)
elseif event.name == "cancel" then
self:onTouchCancelled(event)
end
end)
self:setTouchEnabled(true)
end
function NpcFigure:displayImageView()
if (not self.m_bIsDisplay) then
self.m_bIsDisplay = true
display.addImageAsync(self.m_fileName, function()
local texture = CCTextureCache:sharedTextureCache():textureForKey(self.m_fileName)
self:initWithImageView(texture)
end)
end
end
function NpcFigure:hideImageView()
if (self.m_bIsDisplay) then
self.m_bIsDisplay = false
if (self.m_sprite) then
self.m_sprite:removeFromParent()
self.m_sprite = nil
end
display.removeSpriteFrameByImageName(self.m_fileName)
self.m_arrAction:removeAllObjects()
end
end
function NpcFigure:initWithImageView(texture)
if (not self.m_sprite) then
CCSpriteFrameCache:sharedSpriteFrameCache():addSpriteFramesWithFile(self.m_plistName, texture)
self.m_sprite = CCSprite:create()
self.m_sprite:setAnchorPoint(self.m_fAnchorPoint)
self:addChild(self.m_sprite)
self.m_spriteHigh = CCSprite:create()
self.m_spriteHigh:setAnchorPoint(self.m_fAnchorPoint)
self:addChild(self.m_spriteHigh)
self.m_sprite:runAction(self:getActions())
self.m_spriteHigh:runAction(self:getActions())
self.m_spriteHigh:setVisible(false)
end
end
function NpcFigure:IntelligentDisplay(rcShow, rcHide)
local ptPos = cc.p(self:getPosition())
if (rcShow:containsPoint(ptPos)) then
self:displayImageView()
end
if (not rcHide:containsPoint(ptPos)) then
self:hideImageView()
end
end
function NpcFigure:getActions()
if (self.m_arrAction:count() == 0) then
local flag = 0
while (true) do
local frameName = string.format("npc_%u_1_%d_%02d.png", self.m_npcInfo.m_nRID, self.m_direction, flag)
local frame = CCSpriteFrameCache:sharedSpriteFrameCache():spriteFrameByName(frameName)
if (not frame) then
break
end
self.m_arrAction:addObject(frame)
flag = flag + 1
end
end
if (self.m_arrAction:count() > 0) then
local animation = cc.Animation:createWithSpriteFrames(self.m_arrAction, 1 / 5)
local animate = cc.Animate:create(animation)
local repeatForever = cc.RepeatForever:create(animate)
return repeatForever
end
return nil
end
function NpcFigure:setHighlight()
if (self.m_spriteHigh:isVisible() == false) then
local blendFunc = ccBlendFunc:new()
blendFunc.src = GL_DST_COLOR
blendFunc.dst = GL_ONE
self.m_spriteHigh:setBlendFunc(blendFunc)
self.m_spriteHigh:setVisible(true)
end
end
function NpcFigure:setNormal()
if (self.m_spriteHigh:isVisible() == true) then
self.m_spriteHigh:setVisible(false)
end
end
function NpcFigure:onTouchBegan(event)
if (not self.m_sprite) then
return false
end
local point = cc.p(event.x, event.y)
point = self.m_sprite:convertToNodeSpace(point)
if (not self.m_fSpriteRect:containsPoint(point)) then
return false
end
self:setHighlight()
return true
end
function NpcFigure:onTouchMoved(event)
if (not self.m_fSpriteRect:containsPoint(cc.p(event.x, event.y))) then
self:setNormal()
else
self:setHighlight()
end
end
function NpcFigure:onTouchEnded(event)
self:setNormal()
local alertView = LAlertView.new("", self.m_npcInfo.m_sSentence)
alertView:show(handler(self, self.alertCallBack))
end
function NpcFigure:onTouchCancelled(event)
end
function NpcFigure:alertCallBack(nBtnID)
if (nBtnID == 0) then
end
end
return NpcFigure
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/map/NpcInfo.lua
================================================
-- NPC信息类
local NpcInfo = class("NpcInfo")
function NpcInfo:ctor(json_value)
self.m_nID = json_value["ID"]
self.m_nSID = json_value["SID"]
self.m_nQID = json_value["QID"]
self.m_nRID = json_value["RID"]
self.m_sSentence = json_value["Sentence"]
self.m_sName = json_value["Name"]
end
return NpcInfo
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/map/NpcInfoSystem.lua
================================================
local cjson = require("cjson")
local NpcInfo = require("app.map.NpcInfo")
-- NPC信息系统类
local NpcInfoSystem = class("NpcInfoSystem")
function NpcInfoSystem:ctor()
self.m_mapNpcInfo = {}
local json_str = CCString:createWithContentsOfFile("game_data/npc_info.json")
local json_value = cjson.decode(json_str:getCString())
for i = 1, #json_value do
self:addNpcInfo(json_value[i])
end
end
function NpcInfoSystem:addNpcInfo(json_value)
local npcInfo = NpcInfo.new(json_value)
self.m_mapNpcInfo[npcInfo.m_nID] = npcInfo
end
function NpcInfoSystem:getNpcInfo(nNpcID)
return self.m_mapNpcInfo[nNpcID]
end
return NpcInfoSystem
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/map/PathAStar.lua
================================================
local MapPoint = require("app.map.MapPoint")
local AStarSearch = require("app.map.AStarSearch")
local MapSearchNode = class("MapSearchNode")
local AStarPoint = class("AStarPoint")
local PathAStar = class("PathAStar")
local _roninAStar = nil
local DISORDER = 1
function MapSearchNode:ctor(x, y)
if (x and y) then
self.x = x
self.y = y
else
self.x = 0
self.y = 0
end
end
function MapSearchNode:isSameState(node)
-- same state in a maze search is simply when (x,y) are the same
if((self.x == node.x) and
(self.y == node.y)) then
return true
else
return false
end
end
function MapSearchNode:printNodeInfo()
-- cout << "Node position : (" << x << ", " << y << ")" << endl;
end
-- Here's the heuristic function that estimates the distance from a Node
-- to the Goal.
function MapSearchNode:goalDistanceEstimate(node)
local xd = math.abs(self.x - node.x)
local yd = math.abs(self.y - node.y)
return xd + yd
end
function MapSearchNode:isGoal(node)
if((self.x == node.x) and
(self.y == node.y)) then
return true
end
return false
end
-- This generates the successors to the given Node. It uses a helper function called
-- AddSuccessor to give the successors to the AStar class. The A* specific initialisation
-- is done for each node internally, so here you just set the state information that
-- is specific to the application
function MapSearchNode:getSuccessors(astarsearch, parent_node)
local parent_x = -1
local parent_y = -1
if (parent_node) then
parent_x = parent_node.x
parent_y = parent_node.y
end
local NewNode
-- push each possible move except allowing the search to go backwards
-- 左
if ((PathAStar.getMap(self.x-1, self.y) ~= DISORDER) and
not ((parent_x == self.x-1) and (parent_y == self.y))) then
NewNode = MapSearchNode.new(self.x-1, self.y)
astarsearch:addSuccessor(NewNode)
end
-- 左上
if ((PathAStar.getMap(self.x-1, self.y-1) ~= DISORDER) and
not ((parent_x == self.x-1) and (parent_y == self.y-1))) then
NewNode = MapSearchNode.new(self.x-1, self.y-1)
astarsearch:addSuccessor(NewNode)
end
-- 上
if ((PathAStar.getMap(self.x, self.y-1) ~= DISORDER) and
not ((parent_x == self.x) and (parent_y == self.y-1))) then
NewNode = MapSearchNode.new(self.x, self.y-1)
astarsearch:addSuccessor(NewNode)
end
-- 右上
if ((PathAStar.getMap(self.x+1, self.y-1) ~= DISORDER) and
not ((parent_x == self.x+1) and (parent_y == self.y-1))) then
NewNode = MapSearchNode.new(self.x+1, self.y-1)
astarsearch:addSuccessor(NewNode)
end
-- 右
if ((PathAStar.getMap(self.x+1, self.y) ~= DISORDER) and
not ((parent_x == self.x+1) and (parent_y == self.y))) then
NewNode = MapSearchNode.new(self.x+1, self.y)
astarsearch:addSuccessor(NewNode)
end
-- 右下
if ((PathAStar.getMap(self.x+1, self.y+1) ~= DISORDER) and
not ((parent_x == self.x+1) and (parent_y == self.y+1))) then
NewNode = MapSearchNode.new(self.x+1, self.y+1)
astarsearch:addSuccessor(NewNode)
end
-- 下
if ((PathAStar.getMap(self.x, self.y+1) ~= DISORDER) and
not ((parent_x == self.x) and (parent_y == self.y+1))) then
NewNode = MapSearchNode.new(self.x, self.y+1)
astarsearch:addSuccessor(NewNode)
end
-- 左下
if ((PathAStar.getMap(self.x-1, self.y+1) ~= DISORDER) and
not ((parent_x == self.x-1) and (parent_y == self.y+1))) then
NewNode = MapSearchNode.new(self.x-1, self.y+1)
astarsearch:addSuccessor(NewNode)
end
return true
end
-- given this node, what does it cost to move to successor. In the case
-- of our map the answer is the map terrain value at this node since that is
-- conceptually where we're moving
function MapSearchNode:getCost(node)
return PathAStar.getMap(self.x, self.y)
end
function AStarPoint:ctor(x, y)
self.x = x
self.y = y
end
function PathAStar:ctor()
end
function PathAStar.getMap(x, y)
if (0 > x or x >= _roninAStar.m_nRow or 0 > y or y >= _roninAStar.m_nCol) then
return 1
end
-- if (_roninAStar.m_nMap[y*_roninAStar.m_nRow+x+1] == 1) then
-- return 1
-- end
if (_roninAStar.m_nMap[y][x] == 1) then
return 1
end
if (g_mainScene:getMapPoint(MapPoint.new(x * 65536 + y))) then
return 1
end
return 0
end
function PathAStar:setData(nRow, nCol, map, nMaxNodes)
self.m_nMap = map
self.m_nRow = nRow
self.m_nCol = nCol
self.m_nMaxNodes = nMaxNodes
end
function PathAStar.findPathByAStar(map, nRow, nCol, nMaxNodes, beginMPoint, endMPoint)
if (not _roninAStar) then
_roninAStar = PathAStar.new()
end
_roninAStar:setData(nRow, nCol, map, nMaxNodes)
local dequeMPoint = {}
local dequeAStarPt = _roninAStar:findPathByAStarInternal(beginMPoint, endMPoint)
if (#dequeAStarPt <= 1) then
return dequeMPoint
end
for k, v in ipairs(dequeAStarPt) do
table.insert(dequeMPoint, MapPoint.new(v.x, v.y))
end
return dequeMPoint
end
function PathAStar:findPathByAStarInternal(beginMPoint, endMPoint)
local dequeAStarPt = {}
local filterEnd = self:getFilterEndPoint(beginMPoint, endMPoint)
local astarsearch = AStarSearch.new(self.m_nMaxNodes)
local SearchCount = 0
local NumSearches = 1
while (SearchCount < NumSearches) do
-- Create a start state
local nodeStart = MapSearchNode.new()
nodeStart.x = beginMPoint.x
nodeStart.y = beginMPoint.z
-- Define the goal state
local nodeEnd = MapSearchNode.new()
nodeEnd.x = filterEnd.x
nodeEnd.y = filterEnd.z
-- Set Start and goal states
astarsearch:setStartAndGoalStates(nodeStart, nodeEnd)
local SearchState
local SearchSteps = 0
repeat
SearchState = astarsearch:searchStep()
SearchSteps = SearchSteps + 1
until (not (SearchState == SEARCH_STATE_SEARCHING))
if (SearchState == SEARCH_STATE_SUCCEEDED) then
local node = astarsearch:getSolutionStart()
local steps = 0
node:printNodeInfo()
while (true) do
table.insert(dequeAStarPt, AStarPoint.new(node.x, node.y))
node = astarsearch:getSolutionNext()
if (not node) then
break
end
node:printNodeInfo()
steps = steps + 1
end
-- Once you're done with the solution you can free the nodes up
astarsearch:freeSolutionNodes()
elseif(SearchState == SEARCH_STATE_FAILED) then
end
-- Display the number of loops the search went through
SearchCount = SearchCount + 1
astarsearch:ensureMemoryFreed()
end
return dequeAStarPt
end
function PathAStar:getFilterEndPoint(beginMPoint, endMPoint)
local relust = endMPoint
if (PathAStar.getMap(endMPoint.x, endMPoint.z) ~= DISORDER) then
return relust
end
local count = beginMPoint:getDistance(endMPoint) + 10
for i = 1, count do
local arrMPoint = endMPoint:getMapPointVectorForDistance(i)
local lenght = 0xffff
for k, v in ipairs(arrMPoint) do
local mpoint = v
if (not (PathAStar.getMap(mpoint.x, mpoint.z) == DISORDER or
mpoint:getDistance(beginMPoint) >= lenght or
mpoint:equalsObj(beginMPoint))) then
relust = mpoint
lenght = mpoint:getDistance(beginMPoint)
end
end
if (not relust:equalsObj(endMPoint)) then
break
end
end
return relust
end
return PathAStar
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/map/PortalSprite.lua
================================================
-- 传送门精灵类
local PortalSprite = class("PortalSprite", function()
return display.newSprite()
end)
function PortalSprite:ctor(path)
self.m_path = path
self.m_sprite = nil
display.addSpriteFramesWithFile("texture_set/portal.plist", "texture_set/portal.png")
self:init()
end
function PortalSprite:init()
local size = cc.size(150, 60)
self:setContentSize(size)
self.m_sprite = CCSprite:create()
self.m_sprite:setAnchorPoint(0.5, 0.3)
self.m_sprite:setPosition(size.width/2, size.height/2)
self:addChild(self.m_sprite)
self:playAnimate()
return true
end
-- 播放传送点动画
function PortalSprite:playAnimate()
local i = 1
local array = CCArray:createWithCapacity(8)
while (true) do
local path = string.format("%s%04d.png", self.m_path, i)
local spriteFrame = CCSpriteFrameCache:sharedSpriteFrameCache():spriteFrameByName(path)
if (not spriteFrame) then
break
end
array:addObject(spriteFrame)
i = i + 1
end
local animation = cc.Animation:createWithSpriteFrames(array, 1 / 9)
local animate = cc.Animate:create(animation)
self.m_sprite:runAction(cc.RepeatForever:create(animate))
end
return PortalSprite
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/prop_system/PropIconShow.lua
================================================
-- 属性图标显示类
local PropIconShow = class("PropIconShow", function()
return display.newSprite()
end)
function PropIconShow:ctor(propInfo)
self.m_propInfo = propInfo
self.m_path = string.format("prop_icon/propIcon_%u.png", self.m_propInfo.m_nIconNum)
local pTexture = CCTextureCache:sharedTextureCache():addImage(self.m_path)
self:setTexture(pTexture)
end
return PropIconShow
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/prop_system/PropInfo.lua
================================================
-- 属性信息类
local PropInfo = class("PropInfo")
function PropInfo:ctor(json_value)
self.m_nNum = json_value["ID"]
self.m_nIconNum = json_value["Icon"]
self.m_nAvatarNum = json_value["AvatarID"]
self.m_strName = json_value["Name"]
self.m_nType = json_value["Type"]
self.m_strDepict = json_value["Depict"]
self.m_levelRequirements = json_value["Nlevel"]
self.m_attackRequirements = json_value["Nattack"]
self.m_magicRequirements = json_value["Nmaige"]
self.m_taoismRequirements = json_value["Ntaoism"]
self.m_gender = json_value["Gender"]
self.m_lasting = json_value["Lasting"]
self.m_weight = json_value["Weight"]
self.m_specialRequirements = json_value["Nspecial"]
self.m_coin = json_value["Coin"]
self.m_accurate = json_value["Accurate"]
self.m_dodge = json_value["Dodge"]
self.m_magicDodge = json_value["Mdodge"]
self.m_defenseMax = json_value["MaxDefense"]
self.m_defenseMin = json_value["MinDefense"]
self.m_magicDefenseMax = json_value["MaxMDefense"]
self.m_magicDefenseMin = json_value["MinMDefense"]
self.m_attackMax = json_value["MaxAttack"]
self.m_attackMin = json_value["MinAttack"]
self.m_magicMax = json_value["MaxMaige"]
self.m_magicMin = json_value["MinMaige"]
self.m_taoismMax = json_value["MaxTaoism"]
self.m_taoismMin = json_value["MinTaoism"]
self.m_lucky = json_value["Lucky"]
self.m_SE = json_value["SE"]
self.m_JS = json_value["JS"]
end
return PropInfo
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/prop_system/PropSystem.lua
================================================
local cjson = require("cjson")
local PropInfo = require("app.prop_system.PropInfo")
-- 属性系统类
local PropSystem = class("PropSystem")
-- 构造函数
function PropSystem:ctor()
self.m_mapProp = {}
local json_str = CCString:createWithContentsOfFile("game_data/prop_info.json")
local json_value = cjson.decode(json_str:getCString())
for i = 1, #json_value do
self:addPropInfo(json_value[i])
end
end
function PropSystem:addPropInfo(json_value)
local propInfo = PropInfo.new(json_value)
self.m_mapProp[propInfo.m_nNum] = propInfo
end
function PropSystem:getPropInfo(nPropID)
return self.m_mapProp[nPropID]
end
return PropSystem
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/scenes/GameLoading.lua
================================================
local scheduler = require("framework.scheduler")
local GameLoading = class("GameLoading", function()
return display.newScene("GameLoading")
end)
function GameLoading:ctor()
-- self.m_mapID = mapID
-- self.m_born = born
self:init()
end
function GameLoading:onEnter()
-- if (not g_mainScene) then
-- self.hInitGameScene = scheduler.performWithDelayGlobal(handler(self, self.initGameScene), 0.5)
-- end
--self.hUpdateBgMap = scheduler.performWithDelayGlobal(handler(self, self.updateBgMap), 1.0)
end
function GameLoading:onExit()
CCTextureCache:sharedTextureCache():removeAllTextures()
-- if (self.hInitGameScene) then
-- scheduler.unscheduleGlobal(self.hInitGameScene)
-- self.hInitGameScene = nil
-- end
--
-- if (self.hUpdateBgMap) then
-- scheduler.unscheduleGlobal(self.hUpdateBgMap)
-- self.hUpdateBgMap = nil
-- end
end
function GameLoading.runGameLoading(mapID, born)
GameLoading.m_mapID = mapID
GameLoading.m_born = born
app:enterScene("GameLoading")
-- if (not g_gameLoading) then
-- g_gameLoading = GameLoading.new(mapID, born)
-- CCDirector:sharedDirector():getRunningScene():addChild(g_gameLoading, 100)
-- g_gameLoading:release()
-- end
-- return g_gameLoading
end
function GameLoading:init()
self:setAnchorPoint(cc.p(0, 0))
self.m_sprite = display.newSprite("map/loading.jpg")
self.m_sprite:setPosition(display.cx, display.cy)
self:addChild(self.m_sprite, -1)
local ttf = CCLabelTTF:create("加载中……", "Arial", 30)
ttf:setPosition(display.width-70, 20)
self:addChild(ttf)
-- if (g_mainScene and g_mainScene:getCurrBgMap()) then
-- self:setOpacity(0)
-- local fadeIn = cc.FadeIn:create(0.5)
-- self:runAction(fadeIn)
-- end
self.hInitGameScene = scheduler.performWithDelayGlobal(handler(self, self.initGameScene), 0.5)
return true
end
function GameLoading:initGameScene(fDelay)
-- CCDirector:sharedDirector():getRunningScene():addChild(MainScene.new())
app:enterScene("MainScene", nil, "fade", 0.5)
end
--function GameLoading:updateBgMap(fDelay)
-- CCTextureCache:sharedTextureCache():removeUnusedTextures()
-- g_mainScene:replaceBgMap(self.m_mapID, self.m_born)
-- self:updateFinish()
--end
--
--function GameLoading:updateFinish()
-- local fadeOut = cc.FadeOut:create(0.3)
-- local callFunc = cc.CallFunc:create(handler(self, self.removeFromParent))
-- local array = CCArray:create()
-- array:addObject(fadeOut)
-- array:addObject(callFunc)
-- local sequence = cc.Sequence:create(array)
-- self:runAction(sequence)
--end
return GameLoading
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/scenes/LoginScene.lua
================================================
local LoginScene = class("LoginScene", function()
return display.newScene("LoginScene")
end)
function LoginScene:ctor()
self.m_edtAccount = nil
self.m_edtPwd = nil
self:init()
end
function LoginScene:init()
--#if (CC_TARGET_PLATFORM==CC_PLATFORM_ANDROID)
-- this->setKeypadEnabled(true);
--#endif
local layerColor = CCLayerColor:create(ccc4(200, 200, 200, 200), display.width, display.height)
self:addChild(layerColor)
local account = "请输入您的账号"
local pwd = "请输入您的密码"
local szEditBox = cc.size(360, 50)
local ptEditBox = cc.PointAdd(cc.p(display.cx, display.cy), cc.p(0, 100))
local editBox = ui.newEditBox({
-- image = "EditBoxBg.png",
size = szEditBox,
x = ptEditBox.x,
y = ptEditBox.y,
listener = function(event, editbox)
if event == "began" then
self:onEditBoxBegan(editbox)
elseif event == "ended" then
self:onEditBoxEnded(editbox)
elseif event == "return" then
self:onEditBoxReturn(editbox)
elseif event == "changed" then
self:onEditBoxChanged(editbox)
else
printf("EditBox event %s", tostring(event))
end
end
})
editBox:setPlaceHolder(account)
editBox:setPlaceholderFontColor(ccc3(0, 0, 0))
editBox:setMaxLength(12)
editBox:setInputMode(kEditBoxInputModeAny)
editBox:setReturnType(kKeyboardReturnTypeDone)
self:addChild(editBox)
self.m_edtAccount = editBox
ptEditBox = cc.PointAdd(cc.p(display.cx, display.cy), cc.p(0, 30))
editBox = ui.newEditBox({
-- image = "EditBoxBg.png",
size = szEditBox,
x = ptEditBox.x,
y = ptEditBox.y,
listener = function(event, editbox)
if event == "began" then
self:onEditBoxBegan(editbox)
elseif event == "ended" then
self:onEditBoxEnded(editbox)
elseif event == "return" then
self:onEditBoxReturn(editbox)
elseif event == "changed" then
self:onEditBoxChanged(editbox)
else
printf("EditBox event %s", tostring(event))
end
end
})
editBox:setPlaceHolder(pwd)
editBox:setPlaceholderFontColor(ccc3(0, 0, 0))
editBox:setMaxLength(12)
editBox:setInputMode(kEditBoxInputModeAny)
editBox:setReturnType(kKeyboardReturnTypeDone)
editBox:setInputFlag(kEditBoxInputFlagPassword)
self:addChild(editBox)
self.m_edtPwd = editBox
local accountBg = CCLayerColor:create(ccc4(100, 100, 200, 200), szEditBox.width, szEditBox.height)
accountBg:setPosition(cc.PointSub(cc.p(self.m_edtAccount:getPosition()), cc.p(self.m_edtAccount:getContentSize().width/2, self.m_edtAccount:getContentSize().height/2)))
self:addChild(accountBg, -1)
local cipherBg = CCLayerColor:create(ccc4(100, 100, 200, 200), szEditBox.width, szEditBox.height)
cipherBg:setPosition(cc.PointSub(cc.p(self.m_edtPwd:getPosition()), cc.p(self.m_edtPwd:getContentSize().width/2, self.m_edtPwd:getContentSize().height/2)))
self:addChild(cipherBg, -1)
local PUSH_BUTTON_IMAGES = {
normal = nil,
pressed = nil,
disabled = nil,
}
local btnLogin = cc.ui.UIPushButton.new(PUSH_BUTTON_IMAGES, {scale9 = true})
btnLogin:setAnchorPoint(0.5, 0.5)
btnLogin:setPosition(cc.PointSub(cc.p(display.cx, display.cy), cc.p(80, 60)))
btnLogin:setButtonLabel("normal", ui.newTTFLabel({
text = "登陆",
fontName = "Arial",
size = 50
}))
btnLogin:onButtonClicked(handler(self, self.onBtn_Login))
self:addChild(btnLogin)
local btnReg = cc.ui.UIPushButton.new(PUSH_BUTTON_IMAGES, {scale9 = true})
btnReg:setAnchorPoint(0.5, 0.5)
btnReg:setPosition(cc.PointSub(cc.p(display.cx, display.cy), cc.p(-80, 60)))
btnReg:setButtonLabel("normal", ui.newTTFLabel({
text = "注册",
fontName = "Arial",
size = 50
}))
btnReg:onButtonClicked(handler(self, self.onBtn_Register))
self:addChild(btnReg)
return true
end
-- 登陆按钮
function LoginScene:onBtn_Login(event)
self:joinGame()
end
-- 注册按钮
function LoginScene:onBtn_Register(event)
for i = 0, 7 do
local angle = i * 45 * math.pi / 180
end
end
function LoginScene:joinGame()
app:enterScene("RoleSelScene")
end
function LoginScene:onEditBoxBegan(editbox)
printf("editBox1 event began : text = %s", editbox:getText())
end
function LoginScene:onEditBoxEnded(editbox)
printf("editBox1 event ended : %s", editbox:getText())
end
function LoginScene:onEditBoxReturn(editbox)
printf("editBox1 event return : %s", editbox:getText())
end
function LoginScene:onEditBoxChanged(editbox)
printf("editBox1 event changed : %s", editbox:getText())
end
function LoginScene:keyBackClicked()
end
function LoginScene:keyMenuClicked()
end
return LoginScene
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/scenes/MainScene.lua
================================================
local scheduler = require("framework.scheduler")
local AttackSkillSystem = require("app.skill_system.AttackSkillSystem")
local NpcInfoSystem = require("app.map.NpcInfoSystem")
local PropSystem = require("app.prop_system.PropSystem")
local MapPoint = require("app.map.MapPoint")
local BgMap = require("app.map.BgMap")
local Player = require("app.figure.Player")
local Enemy = require("app.figure.Enemy")
local TextureController = require("app.figure.TextureController")
local PathAStar = require("app.map.PathAStar")
local CCTouchMouse = require("app.game_ui.CCTouchMouse")
local GameInfoUIController = require("app.game_ui.GameInfoUIController")
local GameLoading = require("app.scenes.GameLoading")
local MainScene = class("MainScene", function()
return display.newScene("MainScene")
end)
function MainScene:ctor()
-- ui.newTTFLabel({text = "Hello, World", size = 64, align = ui.TEXT_ALIGN_CENTER})
-- :pos(display.cx, display.cy)
-- :addTo(self)
self.m_ptPlayerDirection = cc.p(0, 0)
self.m_touchMouse = nil
self.m_bTouchProtected = false
self.m_bIsPlayerMoveActions = false
self.m_bgMap = nil
self.m_gameInfoUIController = nil
self.m_mapEnemy = {}
self.m_mapOtherPlayer = {}
self.m_mapMPoint = {}
self.m_waitReincarnationEnemy = nil
self.m_mapProp = {}
self.m_enemyDictionary = {}
self:init()
end
function MainScene:onEnter()
self.hPlayerMovement = scheduler.scheduleGlobal(handler(self, self.playerMovement), 0.5)
end
function MainScene:onExit()
if (self.hPlayerMovement) then
scheduler.unscheduleGlobal(self.hPlayerMovement)
self.hPlayerMovement = nil
end
end
function MainScene:init()
g_mainScene = self
self.m_mapPoint = {}
self.m_bgMap = nil
display.addSpriteFramesWithFile("texture_set/blood_return.plist", "texture_set/blood_return.png")
g_attackSkillSystem = AttackSkillSystem.new()
g_npcInfoSystem = NpcInfoSystem.new()
g_propSystem = PropSystem.new()
g_player = Player.new()
g_player:retain()
-- create touch layer
self.layer = display.newLayer()
self.layer:addNodeEventListener(cc.NODE_TOUCH_EVENT, function(event)
if event.name == "began" then
return self:onTouchBegan(event)
elseif event.name == "moved" then
self:onTouchMoved(event)
elseif event.name == "ended" then
self:onTouchEnded(event)
elseif event.name == "cancel" then
self:onTouchCancelled(event)
end
end)
self:addChild(self.layer, -10000)
self.layer:setTouchEnabled(true)
self.m_spSel = display.newSprite("ui/tray_self.png")
self.m_spSel:retain()
self.m_touchMouse = CCTouchMouse.new()
self.m_touchMouse:retain()
self:replaceBgMap(GameLoading.m_mapID, GameLoading.m_born)
--self:replaceBgMap(200, 1)
--self:replaceBgMap(100, 4)
self.m_gameInfoUIController = GameInfoUIController.new()
self:addChild(self.m_gameInfoUIController)
return true
end
function MainScene:replaceBgMap(nMapID, nBorn)
self.m_mapMPoint = {}
if (self.m_bgMap) then
self.m_mapMPoint = {}
self.m_bgMap:unloadMap()
self.m_bgMap:removeFromParent()
end
--g_player = nil
--g_player = Player.new()
local player = g_player
player:stand()
self.m_enemyDictionary = {}
-- m_otherDictionary->removeAllObjects();
local bgMap = BgMap.new()
self:setCurrBgMap(bgMap)
bgMap:loadMap(nMapID)
bgMap:setDelegate(self)
self:addChild(bgMap, -1)
bgMap:addChildPlayerLead(player, nBorn)
self.m_touchMouse:setPosition(-100, -100)
bgMap:addChild(self.m_touchMouse, BgMap.getZOrderZero(bgMap))
self.m_waitReincarnationEnemy = bgMap:getEnemeyMap()
self.m_nEnemyID = 1000
for i = 1, #self.m_waitReincarnationEnemy do
local t = self.m_waitReincarnationEnemy[i]
self:addEnemy(t.key, t.mpoint, self.m_nEnemyID)
self.m_nEnemyID = self.m_nEnemyID + 1
end
self.m_waitReincarnationEnemy = {}
end
function MainScene:setCurrBgMap(bgMap)
self.m_bgMap = bgMap
end
function MainScene:getCurrBgMap()
return self.m_bgMap
end
-- 脱离战斗
function MainScene:OutOfCombat()
self:showSelected(nil)
self.m_gameInfoUIController:getOperationMenu():cancelHangUP()
end
function MainScene:isPointValid(mpoint)
if (self.m_bgMap:getCurrentGridValue(mpoint) == 1) then
return false
end
if (self:getMapPoint(mpoint)) then
return false
end
return true
end
function MainScene:touchProtected()
if (self.m_bTouchProtected == false) then
return
end
self:stopActionByTag(0xff99)
self.m_bTouchProtected = true
local delayTime = cc.DelayTime:create(0.5)
local callFunc = cc.CallFunc:create(handler(self, self.untouchProtected))
local array = CCArray:create()
array:addObject(delayTime)
array:addObject(callFunc)
local sequence = cc.Sequence:create(array)
sequence:setTag(0xff99)
self:runAction(sequence)
end
function MainScene:untouchProtected()
self.m_bTouchProtected = false
end
function MainScene:updateImageDisplay(rcShow, rcHide)
for key, enemy in pairs(self.m_enemyDictionary) do
if (rcShow:containsPoint(cc.p(enemy:getPosition()))) then
enemy:showFigure()
end
if (not rcHide:containsPoint(cc.p(enemy:getPosition()))) then
enemy:hideFigure()
end
end
-- CCArray* otherPlayerKeys = m_otherDictionary->allKeys();
-- if (otherPlayerKeys)
-- {
-- for (unsigned int i=0; icount(); i++)
-- {
-- int key = ((CCInteger*)otherPlayerKeys->objectAtIndex(i))->getValue();
-- OtherPlayer* otherPlayer = (OtherPlayer*)m_otherDictionary->objectForKey(key);
-- if (showRect.containsPoint(otherPlayer->getPosition()))
-- {
-- otherPlayer->showFigure();
-- }
-- if (!hideRect.containsPoint(otherPlayer->getPosition()))
-- {
-- otherPlayer->hideFigure();
-- }
-- }
-- }
end
function MainScene:insterMapPoint(monomer, mpoint)
self.m_mapMPoint[monomer] = mpoint:getValue()
end
function MainScene:eraseMapPoint(monomer)
self.m_mapMPoint[monomer] = nil
end
function MainScene:getMapPoint(mpoint)
local bRet = false
local value = mpoint:getValue()
for k, v in pairs(self.m_mapMPoint) do
if (v == value) then
bRet = true
break
end
end
return bRet
end
function MainScene:insterMapPointForProp(var, mpoint)
local value = mpoint:getValue()
if (not self.m_mapProp[value]) then
return false
end
self.m_mapProp[value] = var
return true
end
function MainScene:eraseMapPointForProp(mpoint)
self.m_mapProp[mpoint:getValue()] = nil
end
function MainScene:getMapPointForProp(mpoint)
return self.m_mapProp[mpoint:getValue()]
end
function MainScene:getPath(beginMPoint, endMPoint)
local dequeMPoint = PathAStar.findPathByAStar(
self.m_bgMap:getMapGrid(),
self.m_bgMap:getGridRow(),
self.m_bgMap:getGridCol(),
4096, beginMPoint, endMPoint)
local relust = {}
local i = 1
local endIndex = (#dequeMPoint) + 1
while (i ~= endIndex) do
if (i + 1 == endIndex) then
table.insert(relust, dequeMPoint[i])
break
end
local p1 = dequeMPoint[i]
local p2 = dequeMPoint[i+1]
if (#relust > 0 and MapPoint.equals(MapPoint.mul(MapPoint.sub(p1, relust[#relust]), 2), MapPoint.sub(p2, relust[#relust]))) then
table.insert(relust, p2)
i = i + 2
else
table.insert(relust, p1)
i = i + 1
end
end
return relust
end
function MainScene:getPathNextRunGrid(beginMPoint, endMPoint)
local dequeMPoint = PathAStar.findPathByAStar(
self.m_bgMap:getMapGrid(),
self.m_bgMap:getGridRow(),
self.m_bgMap:getGridCol(),
64, beginMPoint, endMPoint)
local relust = {}
table.insert(relust, dequeMPoint[1])
while (#dequeMPoint > 3) do
table.remove(dequeMPoint)
end
if (#dequeMPoint == 2) then
local p = dequeMPoint[2]
table.insert(relust, p)
elseif (#dequeMPoint > 2) then
local p1 = dequeMPoint[2]
local p2 = dequeMPoint[3]
if (MapPoint.sub(p2, dequeMPoint[1]):equalsObj(MapPoint.sub(p1, dequeMPoint[1]):mul(2))) then
table.insert(relust, p2)
else
table.insert(relust, p1)
end
end
return relust
end
function MainScene:getPathNextWalkGrid(beginMPoint, endMPoint)
local dequeMPoint = PathAStar.findPathByAStar(
self.m_bgMap:getMapGrid(),
self.m_bgMap:getGridRow(),
self.m_bgMap:getGridCol(),
64, beginMPoint, endMPoint)
while (#dequeMPoint > 2) do
table.remove(dequeMPoint)
end
return dequeMPoint
end
function MainScene:onTouchBegan(event)
local point = cc.p(event.x, event.y)
point = self.m_bgMap:convertToNodeSpace(point)
if (not self:isVisible()) then
return false
end
if (self.m_bTouchProtected) then
return false
end
if (self:getSelected()) then
if (self:getSelected():getRect():containsPoint(point)) then
self.m_gameInfoUIController:getOperationMenu():commonAttack()
return true
else
self:showSelected(nil)
end
end
-- CCArray* otherKeys = m_otherDictionary->allKeys()
-- if (otherKeys)
-- {
-- for (int i=0; icount(); i++)
-- {
-- int key = ((CCInteger*)otherKeys->objectAtIndex(i))->getValue();
-- Monomer* mon = (Monomer*)m_otherDictionary->objectForKey(key);
-- if (mon->getRect().containsPoint(point))
-- {
-- this->showSelected(mon);
-- break;
-- }
-- }
-- }
if (self.m_enemyDictionary) then
for key, enemy in pairs(self.m_enemyDictionary) do
if (enemy:getRect():containsPoint(point)) then
self:showSelected(enemy)
g_player:setAttackMonomerMajor(enemy)
return true
end
end
end
if (not self:getSelected()) then
self.m_ptPlayerDirection = self.m_bgMap:convertToWorldSpace(point)
self:beginMoveActions()
self:touchProtected()
self.m_gameInfoUIController:getOperationMenu():cancelHangUP()
end
-- this->unschedule(schedule_selector(MainScene:log));
-- this->schedule(schedule_selector(MainScene:log));
return true
end
function MainScene:onTouchMoved(event)
if (not self.m_bIsPlayerMoveActions) then
return
end
local point = cc.p(event.x, event.y)
point = self.m_bgMap:convertToNodeSpace(point)
self.m_ptPlayerDirection = self.m_bgMap:convertToWorldSpace(point)
if (g_player:getState() ~= FigureState.Stand) then
return
end
self:beginMoveActions()
end
function MainScene:onTouchEnded(event)
self:stopMoveActions()
end
function MainScene:onTouchCancelled(event)
end
function MainScene:removeEnemy(enemy)
table.insert(self.m_waitReincarnationEnemy, {["key"] = enemy:getRoleNumber(), ["mpoint"] = enemy:getDenPos()})
self.m_mapMPoint[enemy] = nil
self.m_enemyDictionary[enemy:getEnemyID()] = nil
if (enemy == self:getSelected()) then
self:showSelected(nil)
end
local fTime = math.random() * 5 + 3
local callFunc = cc.CallFunc:create(handler(self, self.addEnemy_))
local array = CCArray:create()
array:addObject(cc.DelayTime:create(fTime))
array:addObject(callFunc)
local sequence = cc.Sequence:create(array)
self:runAction(sequence)
self.m_gameInfoUIController:getOperationMenu():intelligentSearch()
end
function MainScene:addEnemy(num, mpoint, tag)
local enemy = Enemy.new(tag, num, 0)
enemy:setPosition(mpoint:getCCPointValue())
enemy:setDenPos(MapPoint.new(cc.p(enemy:getPosition())))
self.m_bgMap:addChild(enemy)
enemy:updateVertexZ()
enemy:setAttackTime(1.0)
if (num == 11000) then
enemy:setBlood(32000)
enemy:setBloodCap(32000)
enemy:setTheAttack(500)
elseif (num == 12000) then
enemy:setBlood(128000)
enemy:setBloodCap(128000)
enemy:setTheAttack(1500)
elseif (num == 30000) then
enemy:setBlood(4000)
enemy:setBloodCap(4000)
enemy:setTheAttack(50)
enemy:setActive(false)
elseif (num == 26000) then
enemy:setBlood(16000)
enemy:setBloodCap(16000)
enemy:setTheAttack(100)
enemy:setCanMoved(false)
else
enemy:setBlood(8000)
enemy:setBloodCap(8000)
enemy:setTheAttack(30)
enemy:setActive(false)
end
enemy:patrol()
self.m_enemyDictionary[enemy:getEnemyID()] = enemy
enemy:setTag(tag)
end
function MainScene:addEnemy_()
local t = self.m_waitReincarnationEnemy[1]
self:addEnemy(t.key, t.mpoint, self.m_nEnemyID)
self.m_nEnemyID = self.m_nEnemyID + 1
table.remove(self.m_waitReincarnationEnemy, 1)
end
function MainScene:getMonmerVecIsLenght(point, lenght)
local arrEnemy = {}
local mapEnemy = self.m_enemyDictionary
if (mapEnemy) then
for key, enemy in pairs(mapEnemy) do
local x = point.x - enemy:getHurtPoint().x
local y = point.y - enemy:getHurtPoint().y
y = y / math.sqrt(2)
if (math.sqrt(x * x + y * y) <= lenght) then
table.insert(arrEnemy, enemy)
end
end
end
return arrEnemy
end
function MainScene:playerMovement(dt)
if (not self.m_bgMap) then
return
end
local arrEnemy = self:getMonmerVecIsLenght(cc.p(g_player:getPosition()), MapPoint.new(6, 1):getCCSizeValue().width)
for i = 1, #arrEnemy do
local enemy = arrEnemy[i]
if ((enemy:getAttackMonomerMajor()) or (enemy:getActive() == false)) then
else
enemy:followAttackAndSetAttackMethods(g_player, 0)
end
end
end
-- 获取玩家的方向
function MainScene:getPlayerDirection()
local relust
local ptBegin = cc.p(g_player:getPosition())
local ptEnd = cc.p(self.m_bgMap:convertToNodeSpace(self.m_ptPlayerDirection))
local lenghtX = ptEnd.x - ptBegin.x
local lenghtY = ptEnd.y - ptBegin.y
local lenght = cc.PointDistance(ptBegin, ptEnd)
local angle_X = math.acos(lenghtX / lenght) * 180 / math.pi
local angle_Y = math.acos(lenghtY / lenght) * 180 / math.pi
local angle = angle_X
if (angle_Y > 90) then
angle = 360 - angle_X
end
angle = angle * (math.pi / 180)
local x = math.cos(angle)
local y = math.sin(angle)
local tan = math.abs(math.tan(angle))
local tanMin = math.tan(22.5 * math.pi / 180)
local tanMax = math.tan(67.5 * math.pi / 180)
if (tanMin <= tan and tan < tanMax) then
relust = MapPoint.new(x / math.abs(x), y / math.abs(y))
elseif (tan < tanMin) then
relust = MapPoint.new(x / math.abs(x), 0)
else
relust = MapPoint.new(0, y / math.abs(y))
end
relust = relust:mul(2)
return relust
end
function MainScene:playerRunning(fDelay)
if (self.m_gameInfoUIController:getOperationMenu():getMoveMethods() == 0) then
g_player:runBy(self:getPlayerDirection())
elseif (self.m_gameInfoUIController:getOperationMenu():getMoveMethods() == 1) then
g_player:walkBy(self:getPlayerDirection())
end
end
function MainScene:beginMoveActions()
if (self.m_gameInfoUIController:getOperationMenu():getMoveMethods() == 2) then
local point = self.m_bgMap:convertToNodeSpace(self.m_ptPlayerDirection)
local mpoint = MapPoint.new(point)
g_player:goTo(mpoint)
self.m_touchMouse:playEffect(mpoint:getCCPointValue())
return
end
if (g_player:isMoveRunning()) then
return
end
self.m_bIsPlayerMoveActions = true
g_player:setAttackMonomerMajor(nil)
self:OutOfCombat()
self:playerRunning()
end
function MainScene:stopMoveActions()
self.m_bIsPlayerMoveActions = false
self.m_ptPlayerDirection = cc.p(0, 0)
end
--function MainScene:AccurateMoveActions(point)
-- if (not m_isPlayerMoveActions) then
-- return
-- end
-- if (Player.sharePlayer():isMoveRunning()) then
-- return
-- end
-- self.m_playerDirection = point:getCCPointValue()
-- if (Player.sharePlayer():getState() ~= FigureState.Stand) then
-- return
-- end
-- self:beginMoveActions()
--end
--
--function MainScene:keyBackClicked()
---- if (CCDirector::sharedDirector()->getRunningScene()->getChildByTag(0xffffff)) then
---- return;
---- end
----
---- LAlertView* alert = LAlertView::create("提示", "是否退出游戏?");
---- alert->addButtonWithTitle("是");
---- alert->addButtonWithTitle("否");
---- alert->show(this, Alert_selector(MainScene:alertCallBack));
---- alert->setTag(0xffffff);
--end
--
--function MainScene:keyMenuClicked()
--
--end
--
--function MainScene:alertCallBack(nNum)
-- if (nNum == 0) then
-- CCDirector::sharedDirector()->end()
-- end
--end
--
--function MainScene:log(dt)
-- --MapPoint p = MapPoint(m_gMapPoint[Player::sharePlayer()])
-- --MapPoint q = MapPoint(Player::sharePlayer()->getPosition())
-- -- CCLog("playerRunning x=%d, z=%d, x=%d, z=%d ", p.x, p.z, q.x ,q.z)
--end
function MainScene:showSelected(monomer)
if (self.m_spSel:getParent()) then
self.m_spSel:removeFromParent()
end
if (monomer) then
local x = monomer:getAnchorPoint().x * monomer:getContentSize().width
local y = monomer:getAnchorPoint().y * monomer:getContentSize().height
self.m_spSel:setPosition(x, y)
monomer:addChild(self.m_spSel, -1)
self.m_gameInfoUIController:getAttackEnemyInfo():showAttackInfo(monomer)
end
end
function MainScene:getSelected()
local monomer = self.m_spSel:getParent()
if (not monomer) then
if (self.m_gameInfoUIController:getAttackEnemyInfo()) then
self.m_gameInfoUIController:getAttackEnemyInfo():hide()
end
end
return monomer
end
function MainScene:getPlayerMoveActions()
return self.m_bIsPlayerMoveActions
end
function MainScene:getEnemyDictionary()
return self.m_enemyDictionary
end
function MainScene:getGameInfoUIController()
return self.m_gameInfoUIController
end
return MainScene
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/scenes/RoleSelScene.lua
================================================
local GameSocket = require("app.GameSocket")
local GameLoading = require("app.scenes.GameLoading")
local Figure = require("app.figure.Figure")
local RoleSelScene = class("RoleSelScene", function()
return display.newScene("RoleSelScene")
end)
function RoleSelScene:ctor()
self.m_btnBegin = nil
self.m_edtNickName = nil
self.m_nickName = ""
self.m_selected = nil
self.m_arrRole = {}
self:init()
end
function RoleSelScene:init()
local layerColor = CCLayerColor:create(ccc4(140, 150, 180, 255), display.width, display.height)
self:addChild(layerColor, -1)
local label = cc.ui.UILabel.new({
text = "傲来国",
size = 35,
color = ccc3(255,255,255),
fontName = "黑体"
}):pos(480, 576):addTo(self)
label:setAnchorPoint(0.5, 0.5)
label = cc.ui.UILabel.new({
text = "血腥、暴力、耐打",
size = 25,
color = ccc3(255,255,255),
fontName = "宋体"
}):pos(192, 179):addTo(self)
label:setAnchorPoint(0.5, 0.5)
label = cc.ui.UILabel.new({
text = "召唤、辅助、周旋",
size = 25,
color = ccc3(255,255,255),
fontName = "宋体"
}):pos(480, 179):addTo(self)
label:setAnchorPoint(0.5, 0.5)
label = cc.ui.UILabel.new({
text = "强力、强力、还是强力",
size = 25,
color = ccc3(255,255,255),
fontName = "宋体"
}):pos(768, 179):addTo(self)
label:setAnchorPoint(0.5, 0.5)
local editBox = ui.newEditBox({
-- image = "EditBoxBg.png",
size = cc.size(200, 50),
x = 480,
y = 96,
listener = function(event, editbox)
if event == "began" then
self:onEditBoxBegan(editbox)
elseif event == "ended" then
self:onEditBoxEnded(editbox)
elseif event == "return" then
self:onEditBoxReturn(editbox)
elseif event == "changed" then
self:onEditBoxChanged(editbox)
else
printf("EditBox event %s", tostring(event))
end
end
})
editBox:setFontSize(25)
editBox:setFontName("宋体")
editBox:setPlaceHolder("从这里输入昵称")
editBox:setPlaceholderFontColor(ccc3(0, 0, 0))
editBox:setMaxLength(14)
editBox:setInputMode(kEditBoxInputModeAny)
editBox:setReturnType(kKeyboardReturnTypeDone)
self:addChild(editBox)
self.m_edtNickName = editBox
local PUSH_BUTTON_IMAGES = {
normal = "ui/role_create/GUI/button.png",
pressed = nil,
disabled = nil,
}
local btn = cc.ui.UIPushButton.new(PUSH_BUTTON_IMAGES, {scale9 = true})
btn:setAnchorPoint(0.5, 0.5)
btn:setButtonSize(40, 40)
btn:setPosition(604, 96)
btn:onButtonClicked(handler(self, self.randomNickName))
self:addChild(btn)
btn = cc.ui.UIPushButton.new(PUSH_BUTTON_IMAGES, {scale9 = true})
btn:setAnchorPoint(1, 0.5)
btn:setButtonSize(150, 80)
btn:setPosition(910, 80)
btn:setColor(ccc3(127, 127, 127))
btn:setTouchEnabled(false)
btn:setButtonLabel("normal", ui.newTTFLabel({
text = "进入游戏",
fontName = "宋体",
size = 25
}))
btn:onButtonClicked(handler(self, self.sendMessage))
self:addChild(btn)
self.m_btnBegin = btn
PUSH_BUTTON_IMAGES = {
normal = nil,
pressed = nil,
disabled = nil,
}
local szBtn = cc.size(120, 200)
local figureId = {11001, 11002, 12001, 12002, 13001, 13002, 14001, 14002, 15001, 15002, 16001, 16002}
local hairId = {1000, 1000, 1100, 1100, 1200, 1200}
local pt = {
cc.p(115, 320),
cc.p(268, 320),
cc.p(403, 320),
cc.p(556, 320),
cc.p(691, 320),
cc.p(844, 320)
}
for i = 1, 6 do
local btn = cc.ui.UIPushButton.new(PUSH_BUTTON_IMAGES, {scale9 = true})
btn:setAnchorPoint(0.5, 0.5)
btn:setButtonSize(szBtn.width, szBtn.height)
btn:setPosition(cc.PointAdd(cc.p(0, 0), pt[i]))
btn:setTag(figureId[i])
btn:onButtonClicked(handler(self, self.setSelector))
self:addChild(btn)
local monomer = Figure.new(TexturePathType.Figure, figureId[i])
monomer:setHair(hairId[i])
monomer:setWeapon(1000)
--monomer:setPosition(btn:getContentSize().width/2, btn:getContentSize().height/2)
monomer:setColor(ccc3(127, 127, 127))
btn:addChild(monomer)
table.insert(self.m_arrRole, monomer)
end
return true
end
function RoleSelScene:onExit()
CCTextureCache:sharedTextureCache():removeAllTextures()
end
function RoleSelScene:runActionsForFigure(monomer)
monomer:setFigureState(FigureState.Attack, FigureDirection.Down)
local delayTime = cc.DelayTime:create(2.0)
local finish = cc.CallFunc:create(function()
self:runActionsForFigure(monomer)
end)
local array = CCArray:create()
array:addObject(delayTime)
array:addObject(finish)
local sequence = cc.Sequence:create(array)
monomer:runAction(sequence)
end
function RoleSelScene:setSelector(event)
local btn = event.target
if (btn) then
self.m_roleID = btn:getTag()
if (self.m_selected) then
local monomer = self.m_selected
local button = monomer:getParent()
monomer:setFigureState(FigureState.Stand, FigureDirection.Down)
monomer:setColor(ccc3(127, 127, 127))
local scaleTo = cc.ScaleTo:create(0.15, 1.0)
local finish = cc.CallFunc:create(function()
monomer:stopAllActions()
end)
local finish2 = cc.CallFunc:create(function()
monomer:getWeaponSprite():stopAllActions()
end)
local array = CCArray:create()
array:addObject(scaleTo)
array:addObject(finish)
array:addObject(finish2)
local sequence = cc.Sequence:create(array)
monomer:runAction(sequence)
button:setTouchEnabled(true)
end
for i = 1, #self.m_arrRole do
local monomer = self.m_arrRole[i]
local button = monomer:getParent()
if (btn == button) then
button:setTouchEnabled(false)
local scaleTo = cc.ScaleTo:create(0.15, 1.2)
monomer:runAction(scaleTo)
monomer:setColor(ccc3(255,255,255))
self:runActionsForFigure(monomer)
self.m_selected = monomer
end
end
end
if (self.m_btnBegin) then
self.m_btnBegin:setColor(ccc3(255,255,255))
self.m_btnBegin:setTouchEnabled(true)
end
end
function RoleSelScene:randomNickName(event)
if (self.m_edtNickName) then
local num = math.random(1, 1000)
local str = string.format("player_%03d", num)
self.m_edtNickName:setText("")
self.m_edtNickName:setText(str)
end
end
function RoleSelScene:sendMessage(event)
if (self.m_edtNickName:getText() == "") then
CCMessageBox("Nickname is null!", "Tip")
return
end
self.m_edtNickName:setTouchEnabled(false)
GameSocket.sendRoleCreate(self, self.m_roleID, self.m_edtNickName:getText()) -- SOCKET
end
function RoleSelScene:joinGame()
GameLoading.runGameLoading(200, 1)
end
function RoleSelScene:onEditBoxBegan(editbox)
printf("editBox1 event began : text = %s", editbox:getText())
end
function RoleSelScene:onEditBoxEnded(editbox)
printf("editBox1 event ended : %s", editbox:getText())
end
function RoleSelScene:onEditBoxReturn(editbox)
printf("editBox1 event return : %s", editbox:getText())
end
function RoleSelScene:onEditBoxChanged(editbox)
printf("editBox1 event changed : %s", editbox:getText())
end
return RoleSelScene
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/skill_system/AttackSkillInfo.lua
================================================
-- 攻击技能信息类
local AttackSkillInfo = class("AttackSkillInfo")
function AttackSkillInfo:ctor(json_value)
self.m_nNum = json_value["skillNumber"]
self.m_strName = json_value["skillName"]
self.m_nType = json_value["skillType"]
self.m_nAttackType = json_value["attackType"]
self.m_skillLevel = json_value["skillLevel"]
self.m_upgradeTrainingPoint = json_value["upgradeTrainingPoint"]
self.m_openLevel = json_value["openLevel"]
self.m_magicConsumption = json_value["magicConsumption"]
self.m_coolingTime = json_value["coolingTime"]
self.m_attackDistance = json_value["attackDistance"]
self.m_isAttackBody = json_value["isAttackBody"]
self.m_flightSpeed = json_value["flightSpeed"]
self.m_isTailing = json_value["isTailing"]
self.m_explosionRadius = json_value["explosionRadius"]
self.m_explosionFanAngle = json_value["explosionFanAngle"]
self.m_bIsThirdParty = json_value["isThirdParty"]
self.m_effectiveTime = json_value["effectiveTime"]
self.m_effectOfCamp = json_value["effectOfCamp"]
self.m_casterSpecificID = json_value["casterSpecificID"]
self.m_locusSpecificID = json_value["locusSpecificID"]
self.m_explosionSpecificID = json_value["explosionSpecificID"]
end
return AttackSkillInfo
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/skill_system/AttackSkillSystem.lua
================================================
local cjson = require("cjson")
local AttackSkillInfo = require("app.skill_system.AttackSkillInfo")
-- 攻击技能系统类
local AttackSkillSystem = class("AttackSkillSystem")
-- 构造函数
function AttackSkillSystem:ctor()
self.m_mapAttackSkill = {}
local json_str = CCString:createWithContentsOfFile("game_data/skill_info.json")
local json_value = cjson.decode(json_str:getCString())
for i = 1, #json_value do
self:addAttackSkillInfo(json_value[i])
end
end
function AttackSkillSystem:addAttackSkillInfo(json_value)
local attackSkillInfo = AttackSkillInfo.new(json_value)
attackSkillInfo.m_coolingTime = 1.5
self.m_mapAttackSkill[attackSkillInfo.m_nNum] = attackSkillInfo
end
function AttackSkillSystem:getAttackSkillInfo(nSkillID)
return self.m_mapAttackSkill[nSkillID]
end
return AttackSkillSystem
================================================
FILE: 源代码/2.2.5/mir9/scripts/app/skill_system/SkillEffectShow.lua
================================================
local scheduler = require("framework.scheduler")
local BgMap = require("app.map.BgMap")
local GameSocket = require("app.GameSocket")
local TextureController = require("app.figure.TextureController")
-- 技能特效显示类
local SkillEffectShow = class("SkillEffectShow", function()
return display.newNode()
end)
function SkillEffectShow:ctor(skillInfo, fHitDelay)
self.m_skillInfo = skillInfo
self.m_attacker = nil
self.m_victim = nil
self.m_spShow = nil
self.m_spExplosion = nil
self.m_spTail = nil
self.m_fHitDelay = fHitDelay
self.m_attacker = display.newNode()
self.m_victim = display.newNode()
self:setNodeEventEnabled(true)
end
function SkillEffectShow:onEnter()
end
function SkillEffectShow:onExit()
if (self.m_attacker:getParent()) then
self.m_attacker:removeFromParent()
end
if (self.m_victim:getParent()) then
self.m_victim:removeFromParent()
end
end
function SkillEffectShow.playSkillEffect(skillInfo, attacker, victim, fHitDelay)
local skillEffectShow = SkillEffectShow.new(skillInfo, fHitDelay)
if (skillEffectShow and skillEffectShow:init(attacker, victim)) then
g_mainScene:getCurrBgMap():addChild(skillEffectShow)
-- skillEffectShow:release()
return skillEffectShow
end
return nil
end
function SkillEffectShow:init(attacker, victim)
if (not attacker or not victim) then
return false
end
attacker:addChild(self.m_attacker)
victim:addChild(self.m_victim)
self:initWithShowSprite()
if (self.m_skillInfo.m_casterSpecificID ~= 0) then
local path = TextureController.getTexturePath(TexturePathType.SkillCaster, self.m_skillInfo.m_casterSpecificID)
self:playCasterSpecific(path)
end
scheduler.performWithDelayGlobal(handler(self, self.emission), self.m_fHitDelay)
return true
end
function SkillEffectShow:initWithShowSprite()
self.m_spShow = CCSprite:create()
self.m_spShow:setPosition(self.m_attacker:getParent():getHandPoint())
g_mainScene:getCurrBgMap():addChild(self.m_spShow)
end
function SkillEffectShow:playCasterSpecific(path)
local figure = self.m_attacker:getParent():getFigure()
local spWeapon = figure:getWeaponSprite()
if (not spWeapon) then
return
end
local sprite = CCSprite:create()
local szWeapon = spWeapon:getContentSize()
sprite:setPosition(szWeapon.width/2, szWeapon.height/2)
szWeapon:addChild(sprite)
local array = CCArray:createWithCapacity(4)
local flag = 0
while (true) do
local frameName = string.format("%s_%d0_%02d.png", path, figure:getDirection(), flag)
local spriteFrame = CCSpriteFrameCache:sharedSpriteFrameCache():spriteFrameByName(frameName)
if (not spriteFrame) then
break
end
array:addObject(spriteFrame)
flag = flag + 1
end
if (array:count() > 0) then
local animation = cc.Animation:createWithSpriteFrames(array, 1 / 10)
local animate = cc.Animate:create(animation)
local callFunc = cc.CallFunc:create(handler(self, self.removeFromParent))
local Sequence = cc.Sequence:create(animate, callFunc, nil)
sprite:runAction(Sequence)
else
sprite:removeFromParent()
end
end
function SkillEffectShow:emission(fDelay)
self.hTrack = scheduler.scheduleGlobal(handler(self, self.track), 0)
if (self.m_skillInfo.m_locusSpecificID ~= 0) then
local path = TextureController.getTexturePath(TexturePathType.SkillLocus, self.m_skillInfo.m_locusSpecificID)
self:playLocusSpecific(path)
if (self.m_skillInfo.m_isTailing) then
self:playTailing()
end
end
end
function SkillEffectShow:track(fDelay)
local speed = self.m_skillInfo.m_flightSpeed / 60.0
if (self.m_skillInfo.m_flightSpeed == 0) then
speed = 0xffffffff
end
local lenght = cc.PointDistance(cc.p(self.m_spShow:getPosition()), self:getDestination())
local lenghtX = self:getDestination().x - self.m_spShow:getPositionX()
local lenghtY = self:getDestination().y - self.m_spShow:getPositionY()
local x = self.m_spShow:getPositionX() + speed * lenghtX / lenght
local y = self.m_spShow:getPositionY() + speed * lenghtY / lenght
local point = cc.p(x, y)
if (lenght <= 64) then
self.m_spShow:setVisible(false)
end
if (cc.PointDistance(point, self:getDestination()) > speed) then
self.m_spShow:setPosition(point)
local high = self.m_attacker:getParent():getHandPointRelativeFootOffset()
self.m_spShow:setZOrder(BgMap.getZOrder(cc.PointSub(point, high)) + 1)
else
self.m_spShow:setPosition(self:getDestination())
if (self.hTrack) then
scheduler.unscheduleGlobal(self.hTrack)
self.hTrack = nil
end
self:hit()
end
end
function SkillEffectShow:hit()
if (self.m_skillInfo.m_explosionSpecificID ~= 0) then
local path = TextureController.getTexturePath(TexturePathType.SkillExplosion, self.m_skillInfo.m_explosionSpecificID)
self:playExplosionSpecific(path)
else
self:sendMessage()
self:releaseThis()
end
end
function SkillEffectShow:updateTailing(fDelay)
local lenght = cc.PointDistance(self:getDeparture(), cc.p(self.m_spShow:getPosition()))
local lenghtX = self.m_spShow:getPositionX() - self:getDeparture().x
local lenghtY = self.m_spShow:getPositionY() - self:getDeparture().y
local angle_X = math.asin(lenghtY / lenght) * 180 / math.pi
local angle_Y = math.asin(lenghtX / lenght) * 180 / math.pi
local rotation = 0
if (angle_X >= 0) then
rotation = angle_Y - 90
else
rotation = 90 - angle_Y
end
local preferredSize = cc.size(0, 0)
if (lenght < 30) then
preferredSize.width = 0
else
preferredSize.width = lenght - 30
end
preferredSize.height = 5
self.m_spTail:setPreferredSize(preferredSize)
self.m_spTail:setRotation(rotation)
end
-- 播放拖尾特效
function SkillEffectShow:playTailing()
self.m_spTail = CCScale9Sprite:create("ui/red.png")
self.m_spTail:setPreferredSize(cc.size(0, 0))
self.m_spTail:setAnchorPoint(1, 0.5)
self.m_spTail:setPosition(0, 0)
self.m_spShow:addChild(self.m_spTail, -1)
self.hUpdateTailing = scheduler.scheduleGlobal(handler(self, self.updateTailing), 0)
end
function SkillEffectShow:playLocusSpecific(path)
local rotation = self:getRotationWithLocusSpecific()
local flag = 0
local array = CCArray:createWithCapacity(4)
while (true) do
local frameName = string.format("%s_%d_%02d.png", path, rotation, flag)
local spriteFrame = CCSpriteFrameCache:sharedSpriteFrameCache():spriteFrameByName(frameName)
if (not spriteFrame) then
break
end
array:addObject(spriteFrame)
flag = flag + 1
end
if (array:count() > 0) then
local animation = cc.Animation:createWithSpriteFrames(array, 1 / 24)
local animate = cc.Animate:create(animation)
local repeatForever = cc.RepeatForever:create(animate)
self.m_spShow:runAction(repeatForever)
end
end
function SkillEffectShow:playExplosionSpecific(path)
self.m_spExplosion = CCSprite:create()
if (self.m_skillInfo.m_bIsThirdParty == true) then
local point = cc.p(self.m_spShow:getPosition())
self.m_spExplosion:setPosition(point)
g_mainScene:getCurrBgMap():addChild(self.m_spExplosion)
local high = self.m_attacker:getParent():getHurtPointRelativeFootOffset()
self.m_spExplosion:setZOrder(BgMap.getZOrder(cc.PointSub(point, high)) + 1)
else
local victim = self.m_victim:getParent()
if (not victim) then
self:releaseThis()
return
end
local x = victim:getContentSize().width * victim:getFigure():getAnchorPointCenter().x
local y = victim:getContentSize().height * victim:getFigure():getAnchorPointCenter().y
self.m_spExplosion:setPosition(x, y)
self.m_victim:addChild(self.m_spExplosion)
end
local flag = 0
local array = CCArray:createWithCapacity(4)
while (true) do
local frameName = string.format("%s_%02d.png", path, flag)
local spriteFrame = CCSpriteFrameCache:sharedSpriteFrameCache():spriteFrameByName(frameName)
if (not spriteFrame) then
break
end
array:addObject(spriteFrame)
flag = flag + 1
end
if (array:count() > 0) then
local animation = cc.Animation:createWithSpriteFrames(array, 1 / 24)
local animate = cc.Animate:create(animation)
local finish = cc.CallFunc:create(handler(self, self.releaseThis))
local array = CCArray:create()
array:addObject(animate)
array:addObject(finish)
local sequence1 = cc.Sequence:create(array)
local delay = cc.DelayTime:create(animate:getDuration()/2)
local callFunc = cc.CallFunc:create(handler(self, self.sendMessage))
array = CCArray:create()
array:addObject(delay)
array:addObject(callFunc)
local sequence2 = cc.Sequence:create(array)
array = CCArray:create()
array:addObject(sequence1)
array:addObject(sequence2)
local spawn = cc.Spawn:create(array)
self.m_spExplosion:runAction(spawn)
else
self:sendMessage()
self:releaseThis()
end
end
function SkillEffectShow:getRotationWithLocusSpecific()
local lenghtX = self:getDestination().x - self.m_spShow:getPositionX()
local lenghtY = self:getDestination().y - self.m_spShow:getPositionY()
lenghtY = lenghtY * math.sqrt(2)
local lenght = math.sqrt(lenghtX * lenghtX + lenghtY * lenghtY)
local angle_X = math.acos(lenghtX / lenght) * 180 / math.pi
local angle_Y = math.acos(lenghtY / lenght) * 180 / math.pi
local angle = angle_X
if (angle_Y > 90) then
angle = 360 - angle_X
end
local relust = 0
if (math.abs(67.5 - angle) <= 11.25) then
-- up2 right1
relust = 5
elseif (math.abs(45 - angle) <= 11.25) then
-- up2 right2
relust = 10
elseif (math.abs(22.5 - angle) <= 11.25) then
-- up1 right2
relust = 15
elseif (math.abs(0 - angle) <= 11.25) then
-- right2
relust = 20
elseif (math.abs(337.5 - angle) <= 11.25) then
-- right2 down1
relust = 25
elseif (math.abs(315 - angle) <= 11.25) then
-- right2 down2
relust = 30
elseif (math.abs(292.5 - angle) <= 11.25) then
-- right1 down2
relust = 35
elseif (math.abs(270 - angle) <= 11.25) then
-- down2
relust = 40
elseif (math.abs(247.5 - angle) <= 11.25) then
-- down2 left
relust = 45
elseif (math.abs(225 - angle) <= 11.25) then
-- down2 left2
relust = 50
elseif (math.abs(202.5 - angle) <= 11.25) then
-- down1 left2
relust = 55
elseif (math.abs(180 - angle) <= 11.25) then
-- left2
relust = 60
elseif (math.abs(157.5 - angle) <= 11.25) then
-- left2 up1
relust = 65
elseif (math.abs(135 - angle) <= 11.25) then
-- left2 up2
relust = 70
elseif (math.abs(112.5 - angle) <= 11.25) then
-- left up2
relust = 75
elseif (math.abs(90 - angle) <= 11.25) then
-- up2
relust = 80
end
return relust
end
function SkillEffectShow:getDestination()
local point = cc.p(0, 0)
if (not self.m_victim:getParent()) then
self:releaseThis()
return point
end
return self.m_victim:getParent():getHurtPoint()
end
function SkillEffectShow:getDeparture()
if (not self.m_attacker:getParent()) then
self:releaseThis()
return cc.p(0, 0)
end
return self.m_attacker:getParent():getHandPoint()
end
function SkillEffectShow:sendMessage()
if (self.m_skillInfo.m_bIsThirdParty) then
if (self.m_skillInfo.m_explosionFanAngle == 360) then
local arrMonomer = g_mainScene:getMonmerVecIsLenght(cc.p(self.m_spShow:getPosition()), self.m_skillInfo.m_explosionRadius)
if (#arrMonomer == 0) then
table.insert(arrMonomer, self.m_victim:getParent())
end
GameSocket.attackGroup(self.m_attacker:getParent(), arrMonomer, self.m_skillInfo.m_nNum)
else
end
else
GameSocket.attack(self.m_attacker:getParent(), self.m_victim:getParent(), self.m_skillInfo.m_nNum)
end
end
function SkillEffectShow:releaseThis()
if (self.m_spShow and self.m_spShow:getParent()) then
self.m_spShow:removeFromParent()
self.m_spShow = nil
end
if (self.m_spExplosion and self.m_spExplosion:getParent()) then
self.m_spExplosion:removeFromParent()
self.m_spExplosion = nil
end
if (self:getParent()) then
self:removeFromParent()
end
end
return SkillEffectShow
================================================
FILE: 源代码/2.2.5/mir9/scripts/config.lua
================================================
-- 0 - disable debug info, 1 - less debug info, 2 - verbose debug info
DEBUG = 1
-- display FPS stats on screen
DEBUG_FPS = true
-- dump memory info every 10 seconds
DEBUG_MEM = false
-- load deprecated API
LOAD_DEPRECATED_API = false
-- load shortcodes API
LOAD_SHORTCODES_API = true
-- screen orientation
CONFIG_SCREEN_ORIENTATION = "landscape" -- portrait:竖屏、landscape:横屏
-- design resolution
CONFIG_SCREEN_WIDTH = 960
CONFIG_SCREEN_HEIGHT = 640
-- auto scale mode
CONFIG_SCREEN_AUTOSCALE = "FIXED_HEIGHT"
================================================
FILE: 源代码/2.2.5/mir9/scripts/main.lua
================================================
function __G__TRACKBACK__(errorMessage)
print("----------------------------------------")
print("LUA ERROR: " .. tostring(errorMessage) .. "\n")
print(debug.traceback("", 2))
print("----------------------------------------")
end
collectgarbage("setpause", 100)
collectgarbage("setstepmul", 5000)
require("app.MyApp").new():run()
================================================
FILE: 源代码/2.2.5/mir9/sources/AppDelegate.cpp
================================================
#include "cocos2d.h"
#include "AppDelegate.h"
#include "SimpleAudioEngine.h"
#include "support/CCNotificationCenter.h"
#include "CCLuaEngine.h"
#include
using namespace std;
using namespace cocos2d;
using namespace CocosDenshion;
AppDelegate::AppDelegate()
{
// fixed me
//_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF|_CRTDBG_LEAK_CHECK_DF);
}
AppDelegate::~AppDelegate()
{
// end simple audio engine here, or it may crashed on win32
SimpleAudioEngine::sharedEngine()->end();
}
bool AppDelegate::applicationDidFinishLaunching()
{
// initialize director
CCDirector *pDirector = CCDirector::sharedDirector();
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
pDirector->setProjection(kCCDirectorProjection2D);
// set FPS. the default value is 1.0/60 if you don't call this
pDirector->setAnimationInterval(1.0 / 60);
CCTexture2D::PVRImagesHavePremultipliedAlpha(true);
// register lua engine
CCLuaEngine *pEngine = CCLuaEngine::defaultEngine();
CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine);
CCLuaStack *pStack = pEngine->getLuaStack();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
// load framework
pStack->loadChunksFromZIP("res/framework_precompiled.zip");
// set script path
string path = CCFileUtils::sharedFileUtils()->fullPathForFilename("scripts/main.lua");
#else
#ifdef DEBUG
// load framework
if (m_projectConfig.isLoadPrecompiledFramework())
{
const string precompiledFrameworkPath = SimulatorConfig::sharedDefaults()->getPrecompiledFrameworkPath();
pStack->loadChunksFromZIP(precompiledFrameworkPath.c_str());
}
#else
// load framework
pStack->loadChunksFromZIP("res/framework_precompiled.zip");
#endif
// set script path
string path = CCFileUtils::sharedFileUtils()->fullPathForFilename(m_projectConfig.getScriptFileRealPath().c_str());
#endif
#ifdef ENCRYPT_LUA
pStack->setXXTEAKeyAndSign(ENCRYPT_KEY, strlen(ENCRYPT_KEY), "XXTEA", strlen("XXTEA"));
pStack->loadChunksFromZIP("res/game.zip");
pStack->executeString("require 'main'");
#else
#ifdef ENCRYPT_PIC
pStack->setXXTEAKeyAndSign(ENCRYPT_KEY, strlen(ENCRYPT_KEY), "XXTEA", strlen("XXTEA"));
#endif
size_t pos;
while ((pos = path.find_first_of("\\")) != std::string::npos)
{
path.replace(pos, 1, "/");
}
size_t p = path.find_last_of("/\\");
if (p != path.npos)
{
const string dir = path.substr(0, p);
pStack->addSearchPath(dir.c_str());
p = dir.find_last_of("/\\");
if (p != dir.npos)
{
pStack->addSearchPath(dir.substr(0, p).c_str());
}
}
string env = "__LUA_STARTUP_FILE__=\"";
env.append(path);
env.append("\"");
pEngine->executeString(env.c_str());
CCLOG("------------------------------------------------");
CCLOG("LOAD LUA FILE: %s", path.c_str());
CCLOG("------------------------------------------------");
pEngine->executeScriptFile(path.c_str());
#endif
return true;
}
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::applicationDidEnterBackground()
{
CCDirector::sharedDirector()->stopAnimation();
CCDirector::sharedDirector()->pause();
SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
SimpleAudioEngine::sharedEngine()->pauseAllEffects();
CCNotificationCenter::sharedNotificationCenter()->postNotification("APP_ENTER_BACKGROUND_EVENT");
}
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
CCDirector::sharedDirector()->startAnimation();
CCDirector::sharedDirector()->resume();
SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
SimpleAudioEngine::sharedEngine()->resumeAllEffects();
CCNotificationCenter::sharedNotificationCenter()->postNotification("APP_ENTER_FOREGROUND_EVENT");
}
void AppDelegate::setProjectConfig(const ProjectConfig& config)
{
m_projectConfig = config;
}
================================================
FILE: 源代码/2.2.5/mir9/sources/AppDelegate.h
================================================
#ifndef _APP_DELEGATE_H_
#define _APP_DELEGATE_H_
#include "CCApplication.h"
#include "ProjectConfig/SimulatorConfig.h"
//#define ENCRYPT_LUA
//#define ENCRYPT_PIC
//#define ENCRYPT_KEY "XXTEA_KEY"
//#define DEBUG_WORK_DIR "E:/Demo/cocos2d-x/quick-cocos2d-x-2.2.5/projects/mir9"
/**
@brief The cocos2d Application.
The reason for implement as private inheritance is to hide some interface call by CCDirector.
*/
class AppDelegate : public cocos2d::CCApplication
{
public:
AppDelegate();
virtual ~AppDelegate();
/**
@brief Implement CCDirector and CCScene init code here.
@return true Initialize success, app continue.
@return false Initialize failed, app terminate.
*/
virtual bool applicationDidFinishLaunching();
/**
@brief The function be called when the application enter background
@param the pointer of the application
*/
virtual void applicationDidEnterBackground();
/**
@brief The function be called when the application enter foreground
@param the pointer of the application
*/
virtual void applicationWillEnterForeground();
void setProjectConfig(const ProjectConfig& config);
private:
ProjectConfig m_projectConfig;
};
#endif // _APP_DELEGATE_H_
================================================
FILE: 源代码/mir9/.project
================================================
mir9
org.ccdt.cocosproject
org.ccdt.cocosquickproject
org.eclipse.koneki.ldt.nature
================================================
FILE: 源代码/mir9/config.json
================================================
{
"init_cfg":{
"isLandscape": true,
"isWindowTop": false,
"name": "mir9",
"width": 960,
"height": 640,
"entry": "src/main.lua",
"consolePort": 6010,
"uploadPort": 6020
},
"simulator_screen_size": [
{
"title": "iPhone 3Gs (480x320)",
"width": 480,
"height": 320
},
{
"title": "iPhone 4 (960x640)",
"width": 960,
"height": 640
},
{
"title": "iPhone 5 (1136x640)",
"width": 1136,
"height": 640
},
{
"title": "iPad (1024x768)",
"width": 1024,
"height": 768
},
{
"title": "iPad Retina (2048x1536)",
"width": 2048,
"height": 1536
},
{
"title": "Android (800x480)",
"width": 800,
"height": 480
},
{
"title": "Android (854x480)",
"width": 854,
"height": 480
},
{
"title": "Android (1280x720)",
"width": 1280,
"height": 720
},
{
"title": "Android (1920x1080)",
"width": 1920,
"height": 1080
}
]
}
================================================
FILE: 源代码/mir9/frameworks/runtime-src/Classes/AppDelegate.cpp
================================================
#include "AppDelegate.h"
#include "CCLuaEngine.h"
#include "SimpleAudioEngine.h"
#include "cocos2d.h"
#if (CC_TARGET_PLATFORM != CC_PLATFORM_WP8)
#include "CodeIDESupport.h"
#include "Runtime.h"
#endif
#include "ConfigParser.h"
#include "lua_module_register.h"
// extra lua module
#include "cocos2dx_extra.h"
#include "lua_extensions/lua_extensions_more.h"
#include "luabinding/lua_cocos2dx_extension_filter_auto.hpp"
#include "luabinding/lua_cocos2dx_extension_nanovg_auto.hpp"
#include "luabinding/lua_cocos2dx_extension_nanovg_manual.hpp"
#include "luabinding/cocos2dx_extra_luabinding.h"
#include "luabinding/HelperFunc_luabinding.h"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
#include "luabinding/cocos2dx_extra_ios_iap_luabinding.h"
#endif
#if ANYSDK_DEFINE > 0
#include "anysdkbindings.h"
#include "anysdk_manual_bindings.h"
#endif
using namespace CocosDenshion;
USING_NS_CC;
using namespace std;
static void quick_module_register(lua_State *L)
{
luaopen_lua_extensions_more(L);
lua_getglobal(L, "_G");
if (lua_istable(L, -1))//stack:...,_G,
{
register_all_quick_manual(L);
// extra
luaopen_cocos2dx_extra_luabinding(L);
register_all_cocos2dx_extension_filter(L);
register_all_cocos2dx_extension_nanovg(L);
register_all_cocos2dx_extension_nanovg_manual(L);
luaopen_HelperFunc_luabinding(L);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
luaopen_cocos2dx_extra_ios_iap_luabinding(L);
#endif
}
lua_pop(L, 1);
}
//
AppDelegate::AppDelegate()
:_launchMode(1)
{
}
AppDelegate::~AppDelegate()
{
SimpleAudioEngine::end();
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
endRuntime();
#elif (COCOS2D_DEBUG > 0 && CC_CODE_IDE_DEBUG_SUPPORT > 0)
// NOTE:Please don't remove this call if you want to debug with Cocos Code IDE
if (_launchMode)
{
endRuntime();
}
#endif
ConfigParser::purge();
}
//if you want a different context,just modify the value of glContextAttrs
//it will takes effect on all platforms
void AppDelegate::initGLContextAttrs()
{
//set OpenGL context attributions,now can only set six attributions:
//red,green,blue,alpha,depth,stencil
GLContextAttrs glContextAttrs = { 8, 8, 8, 8, 24, 8 };
GLView::setGLContextAttrs(glContextAttrs);
}
bool AppDelegate::applicationDidFinishLaunching()
{
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
initRuntime();
#elif (COCOS2D_DEBUG > 0 && CC_CODE_IDE_DEBUG_SUPPORT > 0)
// NOTE:Please don't remove this call if you want to debug with Cocos Code IDE
if (_launchMode)
{
initRuntime();
}
#endif
// initialize director
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if(!glview) {
Size viewSize = ConfigParser::getInstance()->getInitViewSize();
string title = ConfigParser::getInstance()->getInitViewName();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
extern void createSimulator(const char* viewName, float width, float height, bool isLandscape = true, float frameZoomFactor = 1.0f);
bool isLanscape = ConfigParser::getInstance()->isLanscape();
createSimulator(title.c_str(),viewSize.width,viewSize.height, isLanscape);
#else
glview = cocos2d::GLViewImpl::createWithRect(title.c_str(), Rect(0, 0, viewSize.width, viewSize.height));
director->setOpenGLView(glview);
#endif
director->startAnimation();
}
auto engine = LuaEngine::getInstance();
ScriptEngineManager::getInstance()->setScriptEngine(engine);
lua_State* L = engine->getLuaStack()->getLuaState();
lua_module_register(L);
// use Quick-Cocos2d-X
quick_module_register(L);
LuaStack* stack = engine->getLuaStack();
#if ANYSDK_DEFINE > 0
lua_getglobal(stack->getLuaState(), "_G");
tolua_anysdk_open(stack->getLuaState());
tolua_anysdk_manual_open(stack->getLuaState());
lua_pop(stack->getLuaState(), 1);
#endif
stack->setXXTEAKeyAndSign("2dxLua", strlen("2dxLua"), "XXTEA", strlen("XXTEA"));
//register custom function
//LuaStack* stack = engine->getLuaStack();
//register_custom_function(stack->getLuaState());
#if (COCOS2D_DEBUG > 0 && CC_CODE_IDE_DEBUG_SUPPORT > 0)
// NOTE:Please don't remove this call if you want to debug with Cocos Code IDE
if (_launchMode)
{
startRuntime();
}
else
{
engine->executeScriptFile(ConfigParser::getInstance()->getEntryFile().c_str());
}
#else
engine->executeScriptFile(ConfigParser::getInstance()->getEntryFile().c_str());
#endif
return true;
}
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::applicationDidEnterBackground()
{
Director::getInstance()->stopAnimation();
Director::getInstance()->pause();
SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
SimpleAudioEngine::getInstance()->pauseAllEffects();
Director::getInstance()->getEventDispatcher()->dispatchCustomEvent("APP_ENTER_BACKGROUND_EVENT");
}
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
Director::getInstance()->resume();
Director::getInstance()->startAnimation();
SimpleAudioEngine::getInstance()->resumeBackgroundMusic();
SimpleAudioEngine::getInstance()->resumeAllEffects();
Director::getInstance()->getEventDispatcher()->dispatchCustomEvent("APP_ENTER_FOREGROUND_EVENT");
}
void AppDelegate::setLaunchMode(int mode)
{
_launchMode = mode;
}
================================================
FILE: 源代码/mir9/frameworks/runtime-src/Classes/AppDelegate.h
================================================
#ifndef __APP_DELEGATE_H__
#define __APP_DELEGATE_H__
#include "cocos2d.h"
/**
@brief The cocos2d Application.
The reason for implement as private inheritance is to hide some interface call by Director.
*/
class AppDelegate : private cocos2d::Application
{
public:
AppDelegate();
virtual ~AppDelegate();
virtual void initGLContextAttrs();
/**
@brief Implement Director and Scene init code here.
@return true Initialize success, app continue.
@return false Initialize failed, app terminate.
*/
virtual bool applicationDidFinishLaunching();
/**
@brief The function be called when the application enter background
@param the pointer of the application
*/
virtual void applicationDidEnterBackground();
/**
@brief The function be called when the application enter foreground
@param the pointer of the application
*/
virtual void applicationWillEnterForeground();
void setLaunchMode(int mode);
private:
int _launchMode;
};
#endif // __APP_DELEGATE_H__
================================================
FILE: 源代码/mir9/frameworks/runtime-src/Classes/CodeIDESupport.h
================================================
#ifndef __CODE_IDE_SUPPORT_H__
#define __CODE_IDE_SUPPORT_H__
// define 1 to open Cocos Code IDE support, 0 to disable
#ifndef CC_CODE_IDE_DEBUG_SUPPORT
#define CC_CODE_IDE_DEBUG_SUPPORT 1
#endif
#endif /* __CODE_IDE_SUPPORT_H__ */
================================================
FILE: 源代码/mir9/frameworks/runtime-src/Classes/ConfigParser.cpp
================================================
#include "json/document.h"
#include "json/filestream.h"
#include "json/stringbuffer.h"
#include "json/writer.h"
#include "ConfigParser.h"
#include "FileServer.h"
#define CONFIG_FILE "config.json"
#define CONSOLE_PORT 6010
#define UPLOAD_PORT 6020
#define WIN_WIDTH 960
#define WIN_HEIGHT 640
// ConfigParser
ConfigParser *ConfigParser::s_sharedConfigParserInstance = NULL;
ConfigParser *ConfigParser::getInstance(void)
{
if (!s_sharedConfigParserInstance)
{
s_sharedConfigParserInstance = new ConfigParser();
s_sharedConfigParserInstance->readConfig();
}
return s_sharedConfigParserInstance;
}
void ConfigParser::purge()
{
CC_SAFE_DELETE(s_sharedConfigParserInstance);
}
void ConfigParser::readConfig()
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
// add writable path to search path temporarily for reading config file
vector searchPathArray = FileUtils::getInstance()->getSearchPaths();
#if COCOS2D_DEBUG > 0
std::string writePath = FileServer::getShareInstance()->getWritePath();
#else
std::string writePath = FileUtils::getInstance()->getWritablePath();
#endif
searchPathArray.insert(searchPathArray.begin(), writePath);
FileUtils::getInstance()->setSearchPaths(searchPathArray);
#endif
// read config file
string fullPathFile = FileUtils::getInstance()->fullPathForFilename(CONFIG_FILE);
string fileContent = FileUtils::getInstance()->getStringFromFile(fullPathFile);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
// revert search path
searchPathArray.erase(searchPathArray.end() - 1);
FileUtils::getInstance()->setSearchPaths(searchPathArray);
#endif
if(fileContent.empty())
return;
if (_docRootjson.Parse<0>(fileContent.c_str()).HasParseError()) {
cocos2d::log("read json file %s failed because of %s", fullPathFile.c_str(), _docRootjson.GetParseError());
return;
}
if (_docRootjson.HasMember("init_cfg"))
{
if(_docRootjson["init_cfg"].IsObject())
{
const rapidjson::Value& objectInitView = _docRootjson["init_cfg"];
if (objectInitView.HasMember("width") && objectInitView.HasMember("height"))
{
_initViewSize.width = objectInitView["width"].GetUint();
_initViewSize.height = objectInitView["height"].GetUint();
if (_initViewSize.height>_initViewSize.width)
{
float tmpvalue = _initViewSize.height;
_initViewSize.height = _initViewSize.width;
_initViewSize.width = tmpvalue;
}
}
if (objectInitView.HasMember("name") && objectInitView["name"].IsString())
{
_viewName = objectInitView["name"].GetString();
}
if (objectInitView.HasMember("isLandscape") && objectInitView["isLandscape"].IsBool())
{
_isLandscape = objectInitView["isLandscape"].GetBool();
}
if (objectInitView.HasMember("entry") && objectInitView["entry"].IsString())
{
_entryfile = objectInitView["entry"].GetString();
}
if (objectInitView.HasMember("consolePort"))
{
_consolePort = objectInitView["consolePort"].GetUint();
if(_consolePort <= 0)
_consolePort = CONSOLE_PORT;
}
if (objectInitView.HasMember("uploadPort"))
{
_uploadPort = objectInitView["uploadPort"].GetUint();
if(_uploadPort <= 0)
_uploadPort = UPLOAD_PORT;
}
if (objectInitView.HasMember("isWindowTop") && objectInitView["isWindowTop"].IsBool())
{
_isWindowTop= objectInitView["isWindowTop"].GetBool();
}
}
}
if (_docRootjson.HasMember("simulator_screen_size"))
{
const rapidjson::Value& ArrayScreenSize = _docRootjson["simulator_screen_size"];
if (ArrayScreenSize.IsArray())
{
for (int i = 0; i < ArrayScreenSize.Size(); i++)
{
const rapidjson::Value& objectScreenSize = ArrayScreenSize[i];
if (objectScreenSize.HasMember("title") && objectScreenSize.HasMember("width") && objectScreenSize.HasMember("height"))
{
_screenSizeArray.push_back(SimulatorScreenSize(objectScreenSize["title"].GetString(), objectScreenSize["width"].GetUint(), objectScreenSize["height"].GetUint()));
}
}
}
}
}
ConfigParser::ConfigParser(void) :
_isLandscape(true),
_isWindowTop(false),
_consolePort(CONSOLE_PORT),
_uploadPort(UPLOAD_PORT),
_viewName("mir9"),
_entryfile("src/main.lua"),
_initViewSize(WIN_WIDTH, WIN_HEIGHT)
{
}
rapidjson::Document& ConfigParser::getConfigJsonRoot()
{
return _docRootjson;
}
string ConfigParser::getInitViewName()
{
return _viewName;
}
string ConfigParser::getEntryFile()
{
return _entryfile;
}
Size ConfigParser::getInitViewSize()
{
return _initViewSize;
}
bool ConfigParser::isLanscape()
{
return _isLandscape;
}
bool ConfigParser::isWindowTop()
{
return _isWindowTop;
}
int ConfigParser::getConsolePort()
{
return _consolePort;
}
int ConfigParser::getUploadPort()
{
return _uploadPort;
}
int ConfigParser::getScreenSizeCount(void)
{
return (int)_screenSizeArray.size();
}
const SimulatorScreenSize ConfigParser::getScreenSize(int index)
{
return _screenSizeArray.at(index);
}
================================================
FILE: 源代码/mir9/frameworks/runtime-src/Classes/ConfigParser.h
================================================
#ifndef __CONFIG_PARSER_H__
#define __CONFIG_PARSER_H__
#include
#include
#include "cocos2d.h"
#include "json/document.h"
using namespace std;
USING_NS_CC;
// ConfigParser
typedef struct _SimulatorScreenSize {
string title;
int width;
int height;
_SimulatorScreenSize(const string title_, int width_, int height_)
{
title = title_;
width = width_;
height = height_;
}
} SimulatorScreenSize;
typedef vector ScreenSizeArray;
class ConfigParser
{
public:
static ConfigParser *getInstance(void);
static void purge();
// predefined screen size
int getScreenSizeCount(void);
cocos2d::Size getInitViewSize();
string getInitViewName();
string getEntryFile();
rapidjson::Document& getConfigJsonRoot();
const SimulatorScreenSize getScreenSize(int index);
int getConsolePort();
int getUploadPort();
bool isLanscape();
bool isWindowTop();
private:
void readConfig();
ConfigParser(void);
static ConfigParser *s_sharedConfigParserInstance;
ScreenSizeArray _screenSizeArray;
cocos2d::Size _initViewSize;
string _viewName;
string _entryfile;
bool _isLandscape;
bool _isWindowTop;
int _consolePort;
int _uploadPort;
rapidjson::Document _docRootjson;
};
#endif // __CONFIG_PARSER_H__
================================================
FILE: 源代码/mir9/frameworks/runtime-src/Classes/VisibleRect.cpp
================================================
/****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc.
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 "VisibleRect.h"
USING_NS_CC;
Rect VisibleRect::s_visibleRect;
void VisibleRect::lazyInit()
{
// no lazy init
// Useful if we change the resolution in runtime
s_visibleRect = Director::getInstance()->getOpenGLView()->getVisibleRect();
}
Rect VisibleRect::getVisibleRect()
{
lazyInit();
return s_visibleRect;
}
Vec2 VisibleRect::left()
{
lazyInit();
return Vec2(s_visibleRect.origin.x, s_visibleRect.origin.y+s_visibleRect.size.height/2);
}
Vec2 VisibleRect::right()
{
lazyInit();
return Vec2(s_visibleRect.origin.x+s_visibleRect.size.width, s_visibleRect.origin.y+s_visibleRect.size.height/2);
}
Vec2 VisibleRect::top()
{
lazyInit();
return Vec2(s_visibleRect.origin.x+s_visibleRect.size.width/2, s_visibleRect.origin.y+s_visibleRect.size.height);
}
Vec2 VisibleRect::bottom()
{
lazyInit();
return Vec2(s_visibleRect.origin.x+s_visibleRect.size.width/2, s_visibleRect.origin.y);
}
Vec2 VisibleRect::center()
{
lazyInit();
return Vec2(s_visibleRect.origin.x+s_visibleRect.size.width/2, s_visibleRect.origin.y+s_visibleRect.size.height/2);
}
Vec2 VisibleRect::leftTop()
{
lazyInit();
return Vec2(s_visibleRect.origin.x, s_visibleRect.origin.y+s_visibleRect.size.height);
}
Vec2 VisibleRect::rightTop()
{
lazyInit();
return Vec2(s_visibleRect.origin.x+s_visibleRect.size.width, s_visibleRect.origin.y+s_visibleRect.size.height);
}
Vec2 VisibleRect::leftBottom()
{
lazyInit();
return s_visibleRect.origin;
}
Vec2 VisibleRect::rightBottom()
{
lazyInit();
return Vec2(s_visibleRect.origin.x+s_visibleRect.size.width, s_visibleRect.origin.y);
}
================================================
FILE: 源代码/mir9/frameworks/runtime-src/Classes/VisibleRect.h
================================================
#ifndef __VISIBLERECT_H__
#define __VISIBLERECT_H__
#include "cocos2d.h"
class VisibleRect
{
public:
static cocos2d::Rect getVisibleRect();
static cocos2d::Vec2 left();
static cocos2d::Vec2 right();
static cocos2d::Vec2 top();
static cocos2d::Vec2 bottom();
static cocos2d::Vec2 center();
static cocos2d::Vec2 leftTop();
static cocos2d::Vec2 rightTop();
static cocos2d::Vec2 leftBottom();
static cocos2d::Vec2 rightBottom();
private:
static void lazyInit();
static cocos2d::Rect s_visibleRect;
};
#endif /* __VISIBLERECT_H__ */
================================================
FILE: 源代码/mir9/frameworks/runtime-src/Classes/anysdk_manual_bindings.cpp
================================================
/*
** Lua binding: anysdk
** Generated automatically by tolua++-1.0.92 on Wed Jul 2 14:12:17 2014.
*/
/****************************************************************************
Copyright (c) 2011 cocos2d-x.org
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.
****************************************************************************/
// extern "C" {
#include "tolua_fix.h"
// }
#include