2014-07-17 17:16:29 l863784757 阅读数 11006

    前些天下载了个cocos2dx,用vs2010运行cocos2d后,尝试了一下用Eclipse导入cocos2d项目,结果出现蛮多状况,因为我的环境是vs2010,cocos2dx2.2.4。搭建环境前也去网上看了些博客,有的资料显示要安装python ,cygwin(2.2以后的不需要)。但是后来我发现这两个软件都没安装,也可以配置成功。

   下面是用Eclipse导入cocos2dx安装包里的Android工程


1.导入proj.Android项目

2.拷贝cocos2dx目录cocos2dx/platform/android/java/src目录下的org包到android项目的src下。
3.修改项目属性C/C++ builder的build command和build directory。分别为NDK目录下的ndk-builder和当前项目文件夹
D:\Android\android-ndk-r9d\ndk-build.cmd(我的NDK路径)
Build Location选择当前项目
4.添加C/C++ Builder Environment NDK_MODULE_PATH,值为cocos2dx目录和cocos2dx目录cocos2dx/platform/hird_party/android/prebuilt。
5.拷贝Resource目录下的资源到安卓目录下的assets中(如果使用Cygwin编译就不需要拷贝资源,build_native.sh帮我们做了这一步)。


6.run as android app




如果运行还有地方报错,检查第3,4步,右键项目名:build path-》configture build path-》Java build path-》Libraries,remove最下面两个


可能出现的情况:
闪退
:resourse文件不对会导致闪退
2014-10-30 20:15:16 fnzsjt 阅读数 638

1.首先终端进入proj.android


2.执行./build_native.py


执行结束以后,用eclipse打开安卓工程

3.然后将 工程目录/cocos2d/cocos/platform/android/java/src/org文件拖入到安卓工程的src



4.打开工程jni的Android.mk将自己写的cpp加入


5.再执行一遍./build_native.py(或者将第4步放到第2步之前,则不用再执行./build_native.py)

2014-09-28 16:59:54 u012419410 阅读数 640

/****************************************************************************

Copyright (c) 2010-2012 cocos2d-x.org

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 "platform/CCGLViewProtocol.h"


#include "base/CCTouch.h"

#include "base/CCDirector.h"

#include "base/CCEventDispatcher.h"


NS_CC_BEGIN


namespace {

    

    static Touch* g_touches[EventTouch::MAX_TOUCHES] = { nullptr };

    static unsigned int g_indexBitsUsed = 0;

    // System touch pointer ID (It may not be ascending order number) <-> Ascending order number from 0

    static std::map<intptr_t, int> g_touchIdReorderMap;

    

    static int getUnUsedIndex()

    {

        int i;

        int temp = g_indexBitsUsed;

        

        for (i = 0; i < EventTouch::MAX_TOUCHES; i++) {

            if (! (temp & 0x00000001)) {

                g_indexBitsUsed |= (1 <<  i);

                return i;

            }

            

            temp >>= 1;

        }

        

        // all bits are used

        return -1;

    }

    

    static void removeUsedIndexBit(int index)

    {

        if (index < 0 || index >= EventTouch::MAX_TOUCHES)

        {

            return;

        }

        

        unsigned int temp = 1 << index;

        temp = ~temp;

        g_indexBitsUsed &= temp;

    }

    

}


GLViewProtocol::GLViewProtocol()

: _scaleX(1.0f)

, _scaleY(1.0f)

, _resolutionPolicy(ResolutionPolicy::UNKNOWN)

{

}


GLViewProtocol::~GLViewProtocol()

{


}


void GLViewProtocol::pollInputEvents()

{

}



void GLViewProtocol::updateDesignResolutionSize()

{

    if (_screenSize.width > 0 && _screenSize.height > 0

        && _designResolutionSize.width > 0 && _designResolutionSize.height > 0)

    {

        _scaleX = (float)_screenSize.width / _designResolutionSize.width;

        _scaleY = (float)_screenSize.height / _designResolutionSize.height;

        

        if (_resolutionPolicy == ResolutionPolicy::NO_BORDER)

        {

            _scaleX = _scaleY = MAX(_scaleX, _scaleY);

        }

        

        else if (_resolutionPolicy == ResolutionPolicy::SHOW_ALL)

        {

            _scaleX = _scaleY = MIN(_scaleX, _scaleY);

        }

        

        else if ( _resolutionPolicy == ResolutionPolicy::FIXED_HEIGHT) {

            _scaleX = _scaleY;

            _designResolutionSize.width = ceilf(_screenSize.width/_scaleX);

        }

        

        else if ( _resolutionPolicy == ResolutionPolicy::FIXED_WIDTH) {

            _scaleY = _scaleX;

            _designResolutionSize.height = ceilf(_screenSize.height/_scaleY);

        }

        

        // calculate the rect of viewport

        float viewPortW = _designResolutionSize.width * _scaleX;

        float viewPortH = _designResolutionSize.height * _scaleY;

        

        _viewPortRect.setRect((_screenSize.width - viewPortW) / 2, (_screenSize.height - viewPortH) / 2, viewPortW, viewPortH);

        

        // reset director's member variables to fit visible rect

        auto director = Director::getInstance();

        director->_winSizeInPoints = getDesignResolutionSize();

        director->createStatsLabel();

        director->setGLDefaultValues();

    }

}


void GLViewProtocol::setDesignResolutionSize(float width, float height, ResolutionPolicy resolutionPolicy)

{

    CCASSERT(resolutionPolicy != ResolutionPolicy::UNKNOWN, "should set resolutionPolicy");

    

    if (width == 0.0f || height == 0.0f)

    {

        return;

    }


    _designResolutionSize.setSize(width, height);

    _resolutionPolicy = resolutionPolicy;

    

    updateDesignResolutionSize();

 }


const Size& GLViewProtocol::getDesignResolutionSize() const 

{

    return _designResolutionSize;

}


const Size& GLViewProtocol::getFrameSize() const

{

    return _screenSize;

}


void GLViewProtocol::setFrameSize(float width, float height)

{

    _designResolutionSize = _screenSize = Size(width, height);

}


Rect GLViewProtocol::getVisibleRect() const

{

    Rect ret;

    ret.size = getVisibleSize();

    ret.origin = getVisibleOrigin();

    return ret;

}


Size GLViewProtocol::getVisibleSize() const

{

    if (_resolutionPolicy == ResolutionPolicy::NO_BORDER)

    {

        return Size(_screenSize.width/_scaleX, _screenSize.height/_scaleY);

    }

    else 

    {

        return _designResolutionSize;

    }

}


Vec2 GLViewProtocol::getVisibleOrigin() const

{

    if (_resolutionPolicy == ResolutionPolicy::NO_BORDER)

    {

        return Vec2((_designResolutionSize.width - _screenSize.width/_scaleX)/2

                           (_designResolutionSize.height - _screenSize.height/_scaleY)/2);

    }

    else 

    {

        return Vec2::ZERO;

    }

}


void GLViewProtocol::setViewPortInPoints(float x , float y , float w , float h)

{

    glViewport((GLint)(x * _scaleX + _viewPortRect.origin.x),

               (GLint)(y * _scaleY + _viewPortRect.origin.y),

               (GLsizei)(w * _scaleX),

               (GLsizei)(h * _scaleY));

}


void GLViewProtocol::setScissorInPoints(float x , float y , float w , float h)

{

    glScissor((GLint)(x * _scaleX + _viewPortRect.origin.x),

              (GLint)(y * _scaleY + _viewPortRect.origin.y),

              (GLsizei)(w * _scaleX),

              (GLsizei)(h * _scaleY));

}


bool GLViewProtocol::isScissorEnabled()

{

return (GL_FALSE == glIsEnabled(GL_SCISSOR_TEST)) ? false : true;

}


Rect GLViewProtocol::getScissorRect() const

{

GLfloat params[4];

glGetFloatv(GL_SCISSOR_BOX, params);

float x = (params[0] - _viewPortRect.origin.x) / _scaleX;

float y = (params[1] - _viewPortRect.origin.y) / _scaleY;

float w = params[2] / _scaleX;

float h = params[3] / _scaleY;

return Rect(x, y, w, h);

}


void GLViewProtocol::setViewName(const std::string& viewname )

{

    _viewName = viewname;

}


const std::string& GLViewProtocol::getViewName() const

{

    return _viewName;

}


void GLViewProtocol::handleTouchesBegin(int num, intptr_t ids[], float xs[], float ys[])

{

    intptr_t id = 0;

    float x = 0.0f;

    float y = 0.0f;

    int unusedIndex = 0;

    EventTouch touchEvent;

    

    for (int i = 0; i < num; ++i)

    {

        id = ids[i];

        x = xs[i];

        y = ys[i];


        auto iter = g_touchIdReorderMap.find(id);


        // it is a new touch

        if (iter == g_touchIdReorderMap.end())

        {

            unusedIndex = getUnUsedIndex();


            // The touches is more than MAX_TOUCHES ?

            if (unusedIndex == -1) {

                CCLOG("The touches is more than MAX_TOUCHES, unusedIndex = %d", unusedIndex);

                continue;

            }


            Touch* touch = g_touches[unusedIndex] = new Touch();

touch->setTouchInfo(unusedIndex, (x - _viewPortRect.origin.x) / _scaleX,

                                     (y - _viewPortRect.origin.y) / _scaleY);

            

            CCLOGINFO("x = %f y = %f", touch->getLocationInView().x, touch->getLocationInView().y);

            

            g_touchIdReorderMap.insert(std::make_pair(id, unusedIndex));

            touchEvent._touches.push_back(touch);

        }

    }


    if (touchEvent._touches.size() == 0)

    {

        CCLOG("touchesBegan: size = 0");

        return;

    }

    

    touchEvent._eventCode = EventTouch::EventCode::BEGAN;

    auto dispatcher = Director::getInstance()->getEventDispatcher();

    dispatcher->dispatchEvent(&touchEvent);

}


void GLViewProtocol::handleTouchesMove(int num, intptr_t ids[], float xs[], float ys[])

{

    intptr_t id = 0;

    float x = 0.0f;

    float y = 0.0f;

    EventTouch touchEvent;

    

    for (int i = 0; i < num; ++i)

    {

        id = ids[i];

        x = xs[i];

        y = ys[i];


        auto iter = g_touchIdReorderMap.find(id);

        if (iter == g_touchIdReorderMap.end())

        {

            CCLOG("if the index doesn't exist, it is an error");

            continue;

        }


        CCLOGINFO("Moving touches with id: %d, x=%f, y=%f", id, x, y);

        Touch* touch = g_touches[iter->second];

        if (touch)

        {

touch->setTouchInfo(iter->second, (x - _viewPortRect.origin.x) / _scaleX,

(y - _viewPortRect.origin.y) / _scaleY);

            

            touchEvent._touches.push_back(touch);

        }

        else

        {

            // It is error, should return.

            CCLOG("Moving touches with id: %ld error", (long int)id);

            return;

        }

    }


    if (touchEvent._touches.size() == 0)

    {

        CCLOG("touchesMoved: size = 0");

        return;

    }

    

    touchEvent._eventCode = EventTouch::EventCode::MOVED;

    auto dispatcher = Director::getInstance()->getEventDispatcher();

    dispatcher->dispatchEvent(&touchEvent);

}


void GLViewProtocol::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, int num, intptr_t ids[], float xs[], float ys[])

{

    intptr_t id = 0;

    float x = 0.0f;

    float y = 0.0f;

    EventTouch touchEvent;

    

    for (int i = 0; i < num; ++i)

    {

        id = ids[i];

        x = xs[i];

        y = ys[i];


        auto iter = g_touchIdReorderMap.find(id);

        if (iter == g_touchIdReorderMap.end())

        {

            CCLOG("if the index doesn't exist, it is an error");

            continue;

        }

        

        /* Add to the set to send to the director */

        Touch* touch = g_touches[iter->second];

        if (touch)

        {

            CCLOGINFO("Ending touches with id: %d, x=%f, y=%f", id, x, y);

touch->setTouchInfo(iter->second, (x - _viewPortRect.origin.x) / _scaleX,

(y - _viewPortRect.origin.y) / _scaleY);


            touchEvent._touches.push_back(touch);

            

            g_touches[iter->second] = nullptr;

            removeUsedIndexBit(iter->second);


            g_touchIdReorderMap.erase(id);

        } 

        else

        {

            CCLOG("Ending touches with id: %ld error", static_cast<long>(id));

            return;

        } 


    }


    if (touchEvent._touches.size() == 0)

    {

        CCLOG("touchesEnded or touchesCancel: size = 0");

        return;

    }

    

    touchEvent._eventCode = eventCode;

    auto dispatcher = Director::getInstance()->getEventDispatcher();

    dispatcher->dispatchEvent(&touchEvent);

    

    for (auto& touch : touchEvent._touches)

    {

        // release the touch object.

        touch->release();

    }

}


void GLViewProtocol::handleTouchesEnd(int num, intptr_t ids[], float xs[], float ys[])

{

    handleTouchesOfEndOrCancel(EventTouch::EventCode::ENDED, num, ids, xs, ys);

}


void GLViewProtocol::handleTouchesCancel(int num, intptr_t ids[], float xs[], float ys[])

{

    handleTouchesOfEndOrCancel(EventTouch::EventCode::CANCELLED, num, ids, xs, ys);

}


const Rect& GLViewProtocol::getViewPortRect() const

{

    return _viewPortRect;

}


float GLViewProtocol::getScaleX() const

{

    return _scaleX;

}


float GLViewProtocol::getScaleY() const

{

    return _scaleY;

}


NS_CC_END


2014-09-28 15:19:44 u012419410 阅读数 450

/****************************************************************************

Copyright (c) 2010-2012 cocos2d-x.org

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.

****************************************************************************/


#ifndef __CCGLVIEWPROTOCOL_H__

#define __CCGLVIEWPROTOCOL_H__


#include "base/ccTypes.h"

#include "base/CCEventTouch.h"


#include <vector>


enumclass ResolutionPolicy

{

/**

[1] EXACT_FIT 通过 stretch-to-fit(拉伸)来填满屏幕: 如果分辨率的宽度、高度和屏幕的分辨率不同,会拉长你的游戏视图来适应屏幕 

[2] NO_BORDER 全屏无黑色边框:  如果分辨率式样的宽度、高度和屏幕的分辨率不同,你游戏视图的两个区域会将被削减。

[3] SHOW_ALL 带有黑色边框的全屏:  如果分辨率式样的宽度、高度和屏幕的分辨率不同,两个黑色边框将显示. 

*/



    // The entire application is visible in the specified area without trying to preserve the original aspect ratio.

    // Distortion can occur, and the application may appear stretched or compressed.

// 整个应用程序在指定区域中可见,而试图保持原始宽高比。 

  // 可能会发生扭曲,应用程序可能会拉伸或压缩。  

    EXACT_FIT,

    // The entire application fills the specified area, without distortion but possibly with some cropping,

    // while maintaining the original aspect ratio of the application.

    // 整个应用程序填满指定区域,不扭曲,但可能进行一些裁切,同时保持应用程序的原始宽高比。

    NO_BORDER,

    // The entire application is visible in the specified area without distortion while maintaining the original

    // aspect ratio of the application. Borders can appear on two sides of the application.

    // 看到整个应用程序在指定区域不失真,同时保持应用程序的原始宽高比。应用程序的两边可能会显示边框。

    SHOW_ALL,

    // The application takes the height of the design resolution size and modifies the width of the internal

    // canvas so that it fits the aspect ratio of the device

    // no distortion will occur however you must make sure your application works on different

    // aspect ratios

// 该应用程序采用高度来内部画布的宽度根据设计分辨率大小变化的,使其适合设备的纵横比没有会变形,但是你必须确保你的应用程序适用于不同的纵横比  

    FIXED_HEIGHT,

    // The application takes the width of the design resolution size and modifies the height of the internal

    // canvas so that it fits the aspect ratio of the device

    // no distortion will occur however you must make sure your application works on different

    // aspect ratios

// 该应用程序采用宽度根据分辨率大小设计高度根据内部画布变化的,使其适合设备的纵横比没有会变形,但是你必须确保你的应用程序适用于不同的纵横比

    FIXED_WIDTH,


    UNKNOWN,

};


NS_CC_BEGIN


/**

 * @addtogroup platform

 * @{

 */


classCC_DLL GLViewProtocol

{

public:

   /**

     * @js ctor

     */

    GLViewProtocol();

   /**

     * @js NA

     * @lua NA

     */

   virtual ~GLViewProtocol();


    /** Force destroying EGL view, subclass must implement this method. */

    /**强制销毁EGL视图,子类必须实现此方法。*/

   virtualvoid end() =0;


    /** Get whether opengl render system is ready, subclass must implement this method. */

    /** 获取OpenGL的渲染系统是否已准备好,子类必须实现此方法. */ 

   virtualbool isOpenGLReady() =0;


    /** Exchanges the front and back buffers, subclass must implement this method. */

    /**交换前后缓冲区,子类必须实现此方法. */ 

   virtualvoid swapBuffers() =0;


    /** Open or close IME keyboard , subclass must implement this method. */

   /** 打开或关闭输入法键盘,子类必须实现此方法. */  

   virtualvoid setIMEKeyboardState(bool open) =0;


   /**

     * Polls input events. Subclass must implement methods if platform

     * does not provide event callbacks.

       Polls 输入事件。如果平台不提供事件回调 子类必须实现的方法 

     */

   virtualvoid pollInputEvents();


   /**

     * Get the frame size of EGL view.

     * In general, it returns the screen size since the EGL view is a fullscreen view.

* 获取EGL视图帧大小。 

* 在一般情况下,它返回的屏幕尺寸,因为EGL的 view 是全屏的 view  

     */

   virtualconstSize& getFrameSize()const;


   /**

     * Set the frame size of EGL view.

     * 设置 EGL 视图帧大小. 

     */

   virtualvoid setFrameSize(float width,float height);


   /**

     * Get the visible area size of opengl viewport.

     * 获取 openGL的视图窗口的可见区域大小. 

     */

   virtualSize getVisibleSize()const;


   /**

     * Get the visible origin point of opengl viewport.

     * 获取 openGL的视图窗口可见源点

     */

   virtualVec2 getVisibleOrigin()const;


   /**

     * Get the visible rectangle of opengl viewport.

     * 获取openGL 视图窗口的可见矩形

     */

   virtualRect getVisibleRect()const;


   /**

     * Set the design resolution size. 设置设计分辨率大小 

     * @param width Design resolution width.  分辨率宽度样式

     * @param height Design resolution height.分辨率高度样式

     * @param resolutionPolicy The resolution policy desired, you may choose: 你可以根据需要选择所需要的分辨率:

     *                         [1] EXACT_FIT Fill screen by stretch-to-fit: if the design resolution ratio of width to height is different from the screen resolution ratio, your game view will be stretched.

     *                         [2] NO_BORDER Full screen without black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two areas of your game view will be cut.

     *                         [3] SHOW_ALL  Full screen with black border: if the design resolution ratio of width to height is different from the screen resolution ratio, two black borders will be shown.


[1] EXACT_FIT 通过 stretch-to-fit(拉伸)来填满屏幕: 如果分辨率的宽度、高度和屏幕的分辨率不同,会拉长你的游戏视图来适应屏幕 

[2] NO_BORDER 全屏无黑色边框:  如果分辨率式样的宽度、高度和屏幕的分辨率不同,你游戏视图的两个区域会将被削减。

  [3] SHOW_ALL 带有黑色边框的全屏:  如果分辨率式样的宽度、高度和屏幕的分辨率不同,两个黑色边框将显示. 

     */

   virtualvoid setDesignResolutionSize(float width,float height,ResolutionPolicy resolutionPolicy);


    /** Get design resolution size.  

     *  Default resolution size is the same as 'getFrameSize'. 

获取分辨率式样大小.  

默认分辨率大小和 'getFrameSize' 是一样的. 

     */

   virtualconstSize&  getDesignResolutionSize()const;


   /**

     * Set opengl view port rectangle with points.

     * 使用 一些点 设置opengl 视图窗口的矩形

     */

   virtualvoid setViewPortInPoints(float x ,float y ,float w ,float h);


   /**

     * Set Scissor rectangle with points.

     * 使用 一些点 设置裁剪矩形

     */

   virtualvoid setScissorInPoints(float x ,float y ,float w ,float h);


   /**

     * Get whether GL_SCISSOR_TEST is enable

     * 设置是否启用 GL_SCISSOR_TEST

     */

   virtualbool isScissorEnabled();


   /**

     * Get the current scissor rectangle

     * 获得当前的裁剪矩形

     */

   virtualRect getScissorRect()const;


   virtualvoid setViewName(conststd::string& viewname);

   conststd::string& getViewName()const;


    /**

        Touch events are handled by default; if you want to customize your handlers, please override these functions:

 默认情况下 触摸事件的处理,如果你想自定义您的处理程序,请重写这些函数
 */

   virtualvoid handleTouchesBegin(int num,intptr_t ids[],float xs[],float ys[]);

   virtualvoid handleTouchesMove(int num,intptr_t ids[],float xs[],float ys[]);

   virtualvoid handleTouchesEnd(int num,intptr_t ids[],float xs[],float ys[]);

   virtualvoid handleTouchesCancel(int num,intptr_t ids[],float xs[],float ys[]);


   /**

     * Get the opengl view port rectangle.

     * 获得  OpenGL 视图窗口. 

     */

   constRect& getViewPortRect()const;


   /**

     * Get scale factor of the horizontal direction.

     * 获得水平方向缩放比

     */

   float getScaleX()const;


   /**

     * Get scale factor of the vertical direction.

     * 获得垂直方向缩放比

     */

   float getScaleY()const;


    /** returns the current Resolution policy */

   ResolutionPolicy getResolutionPolicy()const { return_resolutionPolicy; }


protected:

   void updateDesignResolutionSize();

    

   void handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode,int num, intptr_t ids[],float xs[],float ys[]);


    // real screen size 真实的屏幕尺寸  

   Size _screenSize;

    // resolution size, it is the size appropriate for the app resources.

    // 分辨率的大小,它适应应用程序资源大小  

   Size _designResolutionSize;

    // the view port size

    //视图窗口的大小 

   Rect _viewPortRect;

    // the view name

   std::string _viewName;


   float _scaleX;

   float _scaleY;

   ResolutionPolicy _resolutionPolicy;

};


// end of platform group

/// @}


NS_CC_END


#endif /* __CCGLVIEWPROTOCOL_H__ */



2016-07-20 15:45:04 sleafye 阅读数 208

ATD android导入平台下java文件:点击工程->右键选择Build Path->Link Source->弹出界面后点击Browse->选择路径通常是"frameworks/cocos2d-x/cocos/platform/android/java/src"->修改"Folder name"因为src会重名


---------------------------------------------------下面为python拷贝assets代码------------------------------------------------------------------------------------------------------

# !/usr/bin/env python
# -*- coding: utf-8 -*-
# author: 2016 sleaf.ye

import shutil
import os
import sys

sys.path.append(os.path.split(os.path.realpath(__file__))[0]+"/../")

from common import config

def run():
    projPath = r"E:/gitworkspace/code/client/FGame"
    outputPath = r"E:/gitworkspace/code/client/FGame/frameworks/runtime-src/proj.android/assets"

    resPath = projPath + "/res"
    outputResPath = outputPath + "/res"
    if os.path.exists(outputResPath):
        print "clean file " + outputResPath
        shutil.rmtree(outputResPath)
    else:
        os.makedirs(outputResPath)

    print("start copy " + resPath + " to " + outputResPath)
    for f in os.listdir(resPath):
        if f.startswith('.') or f.startswith('$'):
            continue
        cPath = resPath+"/"+f
        if os.path.isdir(cPath):
            shutil.copytree(cPath,outputResPath+"/"+f)
        elif os.path.isfile(cPath):
            shutil.copy(cPath,outputResPath)

    srcPath = projPath + "/src"
    outputSrcPath = outputPath + "/src"
    if os.path.exists(outputSrcPath):
        print "clean file " + outputSrcPath
        shutil.rmtree(outputSrcPath)
    else:
        os.makedirs(outputSrcPath)

    print("start copy " + srcPath + " to " + outputSrcPath)
    for f in os.listdir(srcPath):
        if f.startswith('.') or f.startswith('$'):
            continue
        cPath = srcPath+"/"+f
        if os.path.isdir(cPath):
            shutil.copytree(cPath,outputSrcPath+"/"+f)
        elif os.path.isfile(cPath):
            shutil.copy(cPath,outputSrcPath)

    shutil.copy(projPath + "/config.json", outputPath)
    print("copy success")
if __name__== "__main__":
    run()
    os.system("pause")


没有更多推荐了,返回首页