• 大小: 11.22MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-07-01
  • 语言: Java
  • 标签: CocosCreator  源码  

资源简介

使用CocosCreator,javacripts语言制作的仿小人过桥小游戏源码

资源截图

代码片段和文件信息

#include “AppDelegate.h“

#include “cocos2d.h“

#include “cocos/scripting/js-bindings/manual/scriptingCore.h“
#include “cocos/scripting/js-bindings/manual/jsb_module_register.hpp“
#include “cocos/scripting/js-bindings/manual/jsb_global.h“
#include “cocos/scripting/js-bindings/jswrapper/SeApi.h“

#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && PACKAGE_AS
#include “SDKManager.h“
#include “jsb_anysdk_protocols_auto.hpp“
#include “manualanysdkbindings.hpp“
using namespace anysdk::framework;
#endif

USING_NS_CC;

AppDelegate::AppDelegate()
{
}

AppDelegate::~AppDelegate()
{
    scriptEngineManager::destroyInstance();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && PACKAGE_AS
    SDKManager::getInstance()->purge();
#endif
}

void AppDelegate::initGLContextAttrs()
{
    GLContextAttrs glContextAttrs = {8 8 8 8 24 8};
    
    GLView::setGLContextAttrs(glContextAttrs);
}

bool AppDelegate::applicationDidFinishLaunching()
{
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS && PACKAGE_AS
    SDKManager::getInstance()->loadAllPlugins();
#endif
    // initialize director
    auto director = Director::getInstance();
    auto glview = director->getOpenGLView();
    if(!glview) {
#if(CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
        glview = GLViewImpl::create(“snail“);
#else
        glview = GLViewImpl::createWithRect(“snail“ cocos2d::Rect(00900640));
#endif
        director->setOpenGLView(glview);
    }
    
    // set FPS. the default value is 1.0/60 if you don‘t call this
    director->setAnimationInterval(1.0 / 60);

    scriptingCore* sc = scriptingCore::getInstance();
    scriptEngineManager::getInstance()->setscriptEngine(sc);

    se::scriptEngine* se = se::scriptEngine::getInstance();

    jsb_set_xxtea_key(“84fe9266-379d-46“);
    jsb_init_file_operation_delegate();

#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0)
    // Enable debugger here
    jsb_enable_debugger(“0.0.0.0“ 5086);
#endif

    se->setExceptionCallback([](const char* location const char* message const char* stack){
        // Send exception information to server like Tencent Bugly.

    });

    jsb_register_all_modules();

#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && PACKAGE_AS
    se->addRegisterCallback(register_all_anysdk_framework);
    se->addRegisterCallback(register_all_anysdk_manual);
#endif

    se->start();

    jsb_run_script(“main.js“);

    return true;
}

// This function will be called when the app is inactive. When comes a phone callit‘s be invoked too
void AppDelegate::applicationDidEnterBackground()
{
    auto director = Director::getInstance();
    director->stopAnimation();
    director->getEventDispatcher()->dispatchCustomEvent(“game_on_hide“);
}

// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
    auto director = Dir

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        1558  2018-03-02 09:02  .gitignore
     目录           0  2018-03-07 20:32  assets\
     目录           0  2018-03-07 20:32  assets\fonts\
     文件          88  2018-03-03 22:34  assets\fonts.meta
     文件     2862532  2018-03-03 22:35  assets\fonts\FZKATJW.TTF
     文件          88  2018-03-03 22:35  assets\fonts\FZKATJW.TTF.meta
     目录           0  2018-03-07 20:32  assets\Prefab\
     文件          88  2018-03-02 10:08  assets\Prefab.meta
     文件        3465  2018-03-02 16:05  assets\Prefab\stick_rotate.prefab
     文件         116  2018-03-02 16:05  assets\Prefab\stick_rotate.prefab.meta
     目录           0  2018-03-07 20:32  assets\Scene\
     文件         108  2018-03-02 09:02  assets\Scene.meta
     文件      155339  2018-03-03 23:00  assets\Scene\game_scene.fire
     文件         146  2018-03-03 23:00  assets\Scene\game_scene.fire.meta
     目录           0  2018-03-07 20:32  assets\script\
     文件         108  2018-03-02 09:02  assets\script.meta
     文件        1011  2018-03-02 21:54  assets\script\camera-control.js
     文件         197  2018-03-02 21:58  assets\script\camera-control.js.meta
     文件        1062  2018-03-02 15:35  assets\script\enable_col.js
     文件         197  2018-03-02 15:35  assets\script\enable_col.js.meta
     文件        3234  2018-03-03 22:59  assets\script\game_scene.js
     文件         197  2018-03-03 23:00  assets\script\game_scene.js.meta
     文件        1505  2018-03-02 19:36  assets\script\ground.js
     文件         197  2018-03-02 19:36  assets\script\ground.js.meta
     文件        1491  2018-03-02 22:32  assets\script\player.js
     文件         197  2018-03-03 12:52  assets\script\player.js.meta
     文件        2964  2018-03-02 22:22  assets\script\stick.js
     文件         197  2018-03-02 22:22  assets\script\stick.js.meta
     目录           0  2018-03-07 20:32  assets\Texture\
     文件         108  2018-03-02 09:02  assets\Texture.meta
     文件       21345  2018-03-02 19:34  assets\Texture\restart.png
............此处省略505个文件信息

评论

共有 条评论