Giter Club home page Giter Club logo

aajiwani / easyndk-for-cocos2dx Goto Github PK

View Code? Open in Web Editor NEW
170.0 170.0 108.0 23.32 MB

NDK is always a problem. Writing such a code that can become a breeze in connecting with other platforms is always a problem when working with cocos2dx. This repo is a step made forward to make this pain a simple step.

License: MIT License

C++ 32.90% C 7.62% Shell 0.03% Makefile 50.58% HTML 1.68% CSS 0.01% Java 1.45% Objective-C 3.89% Objective-C++ 1.85% CMake 0.01%

easyndk-for-cocos2dx's Introduction

Banner

Hello, folks!

My name is Amir Ali Jiwani and I am a software craftsman. I'm from Pakistan, currently residing in Malaysia and working with SEEK. I can define myself as a problem solver and craftsman -- Knows to write softwares; And uses logic as expression. You can find me on Twitter, or on LinkedIn. I believe life should be reasonable to live along with a purpose.

🔨 🔧 Technologies & Tools

📈 GitHub Stats

Amir Ali's github stats

🎿 Highlights

  • 🔭 I’m currently working on this project
  • 🌱 I’m currently learning the way to communicate with tech/non-tech audience in a reasonable fashion, along with swimming 🏊
  • 💬 Ask me about problem solving, architecture, practices, help with computer languages

easyndk-for-cocos2dx's People

Contributors

aajiwani avatar neonaleon avatar thearsenik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

easyndk-for-cocos2dx's Issues

iOS bug-fix as follow

HelloWorld::~HelloWorld()
{
// Remove the associated selector group from the global space,
// Because we are destroying this instance
string str = "HelloWorldSelectors";
char char_str = (char)str.c_str();
NDKHelper::RemoveSelectorsInGroup(char_str);
}

Are you ok with my changes?

Hello,

Please, have a look at a commit in my fork of cocos2d-x:
vedi/cocos2d-x@28c0405

I've integrated your library to cocos2d-x. But it's not original library. I did some changes here:

  • changed first letter of all the methods from upper to lower case (it better fits name conventions of cocos2d-x),
  • renamed NDKCallbackNode (because it's confusing with nodes of cocos2d-x),
  • fixed typo recIEve->recEIve in all the method,
  • maybe something else, but actually I do not remember.

If you happy with these changes I can try to do a pull request to the original cocos2d-x repository, or you can do that by yourself.

Looking forward to your feedback.

Best regards,
Fedor Shubin

Cocos2d-x 3.0 some class deprecated, such as CCObject to Object

Cocos2d-x 3.0 some class deprecated, such as CCObject to Object:

EasyNDK/NDKHelper/NDKHelper.cpp:16:95: 'CCNode' is deprecated

NDKHelper/NDKHelper.cpp:45:1: 'CCObject' is deprecated

'CCDictionary' is deprecated

maybe you can change sdk to fix Cocos2d-x 3.0

iOS test project: Multiple console output messages.

This doesn't affect the EasyNDK, but is really annoying.

When I run the test project y got multiple console outputs like this:


Nov 19 18:46:30 iPad-de-Gonzalo SampleNDK[1128] : CGBitmapContextCreate: unsupported parameter combination: 8 integer bits/component; 32 bits/pixel; 3-component color space; kCGImageAlphaPremultipliedLast; 186 bytes/row.


Tested with:
Mac OS X 10.9 Mavericks / Xcode 5.0.1
iPad Mini wifi / iOS 7.0.2

I fix this issue upgrading the cocos2d-x library to current 2.2

License

What kind of license will you use on EasyNDK?

EasyNDK support for WP8 using XAML

Hi,

I liked your library and it was so easy integrating it in my game.
I have successfully integrated the same and implemented couple of 3rd party SDKs both in iOS and Android using EasyNDK which was so fast and easy.

Wanted to ask if you are looking in to add the support for WP8 for calling C# methods in the same fashion with help of XAML.

Thank you for sharing such a good work with us.

Regards
Sudhaker

How to pass parameters to native method?

I'm trying to pass an integer to the native method but I'm not sure how to do that with SendMessageWithParams. I keep getting weird values on the native side when I convert the NSObject to NSInteger.

EasyNDK C++11 Issues

Hello,

I am using Xcode 6.1 and cocos2dx v2.2
I Changed C++ dialect to C++11 for some of my needs but i got 4 EasyNDK errors
screen shot 2014-10-28 at 13 48 43

PS: Its working perfect for C++ Dialect "Compiler Default"
Can you hint me what is going wrong here
Thanks

memory leak

   in void NDKHelper::HandleMessage(json_t *methodName, json_t* methodParams)

  CCObject *dataToPass = NDKHelper::GetCCObjectFromJson(methodParams);
  //dataToPass retain count 1

  if (dataToPass != NULL)
          dataToPass->retain();
  //dataToPass retain count 2

        CCFiniteTimeAction* action = CCSequence::create(CCCallFuncND::create(target, sel, (void*)dataToPass), NULL);

        target->runAction(action);//without retain and release


  if (dataToPass != NULL)
          dataToPass->autorelease();
        //dataToPass retain count 2 autorelease_count 1

And When i get data in me method

   void  method(CCNode *sender, void *data){
   }

data have retain count 2 autorelease_count 1
Need remove one retain

Android callback empty dictionary

Hi, i found a bug. When creating CCDictionary from JSON object we use autorelease object. And when parameters pass to Native equriment we get empty dictionary. So i added retatin when create CCDIctionary and release in every to_be_call function.

CCObject* NDKHelper::GetCCObjectFromJson(json_t *obj)
{
if (obj == NULL)
return NULL;

if (json_is_object(obj))
{
    CCDictionary *dictionary = CCDictionary::create();
    dictionary->retain();

.....

Log displayed issue:
{"calling_method_name":"getCoins","calling_method_params":{"coins":"0","gems":"0"}}
Ndk proceed key coins
Ndk proceed key gems
Ndk get dictionary with 2 keys
getCoins call
params count 0 //so we have empty dictionary
NULL string
NULL string

Crash on some devices

Hello,

First of all, thank you for your work :) It helped me a lot.

I am receiving crash reports on the Developer Console. Here is the one I received today:
#00 pc 0004c2a0 /system/lib/libdvm.so
#1 pc 00197360 /data/app-lib/com.dashtag.tapzou-1/libgame.so (JNIEnv::GetStaticMethodID(jclass, char const, char const*)+56)
#2 pc 001976ac /data/app-lib/com.dashtag.tapzou-1/libgame.so
#3 pc 00197a38 /data/app-lib/com.dashtag.tapzou-1/libgame.so (cocos2d::JniHelper::getStaticMethodInfo(cocos2d::JniMethodInfo_&, char const_, char const_, char const*)+44)
#4 pc 000d33dc /data/app-lib/com.dashtag.tapzou-1/libgame.so (SendMessageWithParams+200)
#5 pc 000c79ac /data/app-lib/com.dashtag.tapzou-1/libgame.so (GameMain::shareButtonClicked()+324)
#6 pc 00166a6c /data/app-lib/com.dashtag.tapzou-1/libgame.so (cocos2d::CCMenuItem::activate()+200)
#7 pc 00162e54 /data/app-lib/com.dashtag.tapzou-1/libgame.so (cocos2d::CCMenu::ccTouchEnded(cocos2d::CCTouch_, cocos2d::CCEvent_)+284)
#8 pc 001eb430 /data/app-lib/com.dashtag.tapzou-1/libgame.so (cocos2d::CCTouchDispatcher::touches(cocos2d::CCSet_, cocos2d::CCEvent_, unsigned int)+816)
#9 pc 001ebaec /data/app-lib/com.dashtag.tapzou-1/libgame.so (cocos2d::CCTouchDispatcher::touchesEnded(cocos2d::CCSet_, cocos2d::CCEvent_)+56)
#10 pc 0019051c /data/app-lib/com.dashtag.tapzou-1/libgame.so (cocos2d::CCEGLViewProtocol::handleTouchesEnd(int, int_, float_, float*)+124)
#11 pc 00197e0c /data/app-lib/com.dashtag.tapzou-1/libgame.so (Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeTouchesEnd+88)
#12 pc 0001e90c /system/lib/libdvm.so (dvmPlatformInvoke+112)
#13 pc 0004eddb /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const_, JValue_, Method const_, Thread_)+398)
#14 pc 00027d20 /system/lib/libdvm.so
#15 pc 0002c2fc /system/lib/libdvm.so (dvmInterpret(Thread_, Method const_, JValue*)+184)
#16 pc 00060f21 /system/lib/libdvm.so (dvmCallMethodV(Thread_, Method const_, Object_, bool, JValue_, std::va_list)+292)
#17 pc 00060f4b /system/lib/libdvm.so (dvmCallMethod(Thread
, Method const
, Object_, JValue_, ...)+20)
#18 pc 00055ccf /system/lib/libdvm.so
#19 pc 0000cba0 /system/lib/libc.so (__thread_entry+72)
#20 pc 0000cd1c /system/lib/libc.so (pthread_create+208)

I don't know what is the problem and I hope someone can help me.

Thanks a lot :)

how to integrate easyndk to cocos2d-x Android.mk?

how to integrate easyndk to cocos2d-x 3.0 Android.mk?

  1. Android.mk add
    ../../Classes/Game/Foundation_diy/EasyNDK/jansson/dump.c
    ../../Classes/Game/Foundation_diy/EasyNDK/jansson/error.c
    ../../Classes/Game/Foundation_diy/EasyNDK/jansson/hashtable.c
    ../../Classes/Game/Foundation_diy/EasyNDK/jansson/load.c
    ../../Classes/Game/Foundation_diy/EasyNDK/jansson/memory.c
    ../../Classes/Game/Foundation_diy/EasyNDK/jansson/pack_unpack.c
    ../../Classes/Game/Foundation_diy/EasyNDK/jansson/strbuffer.c
    ../../Classes/Game/Foundation_diy/EasyNDK/jansson/strconv.c
    ../../Classes/Game/Foundation_diy/EasyNDK/jansson/utf.c
    ../../Classes/Game/Foundation_diy/EasyNDK/jansson/value.c \
  2. compile error
    Compile++ thumb : cocos2dcpp_shared <= NDKHelper.cpp
    In file included from jni/../../Classes/Game/Foundation_diy/EasyNDK/NDKHelper/NDKHelper.cpp:9:0:
    jni/../../Classes/Game/Foundation_diy/EasyNDK/NDKHelper/NDKHelper.h:16:21: fatal error: jansson.h: No such file or directory
  3. add like instruction:
    LOCAL_SRC_FILES := hellocpp/main.cpp
    ../../Classes/AppDelegate.cpp
    ../../Classes/HelloWorldScene.cpp
    ../../Classes/jansson/dump.c
    ../../Classes/jansson/error.c
    ../../Classes/jansson/hashtable.c
    ../../Classes/jansson/load.c
    ../../Classes/jansson/memory.c
    ../../Classes/jansson/pack_unpack.c
    ../../Classes/jansson/strbuffer.c
    ../../Classes/jansson/strconv.c
    ../../Classes/jansson/utf.c
    ../../Classes/jansson/value.c
    ../../Classes/NDKHelper/NDKCallbackNode.cpp
    ../../Classes/NDKHelper/NDKHelper.cpp

LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes
$(LOCAL_PATH)/../../Classes/NDKHelper
$(LOCAL_PATH)/../../Classes/jansson
4. compile error
jni/../../Classes/Game/Foundation_diy/EasyNDK/NDKHelper/NDKHelper.cpp: At global scope:
jni/../../Classes/Game/Foundation_diy/EasyNDK/NDKHelper/NDKHelper.cpp:255:73: warning: 'CCObject' is deprecated (declared at /Users/xx/Documents/cocos2d-x-3.0alpha0-pre/projects/xxx/proj.android/../../../cocos2dx/cocoa/CCObject.h:64) [-Wdeprecated-declarations]
void SendMessageWithParams(string methodName, CCObject* methodParams)
^
cc1plus: some warnings being treated as errors
make: * [obj/local/armeabi/objs/cocos2dcpp_shared//**/Classes/Game/Foundation_diy/EasyNDK/NDKHelper/NDKHelper.o] Error 1
make: Leaving directory `/Users/xx/Documents/cocos2d-x-3.0alpha0-pre/projects/xxx/proj.android'

Conversion of String Literal to Char * is Depreciated.

Hello,
Hoping you are well.
I am not sure whether its an issue or not, but when removing selectors from group Xcode 4.5 throughs a warning of
Conversion of String Literal to Char * is Depreciated.

Rest Works like Magic
Thank You

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.