I had done it thus: STEP 1. Create any class for linking native c# and cocos2dx methods
#pragma once
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
namespace PhoneDirect3DXamlAppComponent
{
public ref class NativeEventHelper sealed
{
public:
NativeEventHelper(void);
}
}
STEP 2. You need to send funcion from native c# code to cocos2d-x code. This funtion is delegate. It sending by SetDelegate method, which called from native code (step 4).
namespace PhoneDirect3DXamlAppComponent
{
public delegate void CallNativeFunctionDelegate();
public ref class NativeEventHelper sealed
{
public:
NativeEventHelper(void);
void SetHideEditBoxDelegate(CallNativeFunctionDelegate^ delegate) {
m_CallNativeFunctionDelegate = delegate;
}
}
private:
property static CallNativeFunctionDelegate^ m_CallNativeFunctionDelegate
}
STEP 3. Add function which will call native function; When u call this function in cocos, corresponding function in C# will be called.
STEP 4. In c# file create instance of NativeEventHelper class, and set function
NativeEventHelper helper = new NativeEventHelper();
helper.SetCallNativeFunctionDelegate(CallNativeFunction); //this function implemented in cocos2d code
STEP 5. Add Implementation of your native method (in c# file)
Need your help regarding integrating windows advertising network in windows phone 8.
I followed your tutorial but i get this error.
Please help to fix it.
Error 7 The type or namespace name ‘AdControlHelper’ does not exist in the namespace ‘PhoneDirect3DXamlAppComponent’ (are you missing an assembly reference?) C:\Users\Muniraj\Desktop\cocos2d-x-2.2.3\samples\Cpp\HelloCpp\proj.wp8-xaml\HelloCpp\HelloCpp\MainPage.xaml.cs 21 37 HelloCpp (HelloCpp-XAML\HelloCpp)
Error 1 error C1010: unexpected end of file while looking for precompiled header. Did you forget to add ‘#include “pch.h”’ to your source? C:\Users\Muniraj\Desktop\cocos2d-x-2.2.3\samples\Cpp\HelloCpp\Classes\AdControlEvent.cpp 22 1 HelloCppComponent
Error 2 error C1010: unexpected end of file while looking for precompiled header. Did you forget to add ‘#include “pch.h”’ to your source? C:\Users\Muniraj\Desktop\cocos2d-x-2.2.3\samples\Cpp\HelloCpp\Classes\AdControlDelegate.cpp 21 1 HelloCppComponent
Error 3 The type or namespace name ‘AdControlHelper’ does not exist in the namespace ‘PhoneDirect3DXamlAppComponent’ (are you missing an assembly reference?) C:\Users\Muniraj\Desktop\cocos2d-x-2.2.3\samples\Cpp\HelloCpp\proj.wp8-xaml\HelloCpp\HelloCpp\AdControlCallback.cs 2 37 HelloCpp (HelloCpp-XAML\HelloCpp)
Error 4 The type or namespace name ‘ICallback’ could not be found (are you missing a using directive or an assembly reference?) C:\Users\Muniraj\Desktop\cocos2d-x-2.2.3\samples\Cpp\HelloCpp\proj.wp8-xaml\HelloCpp\HelloCpp\AdControlCallback.cs 15 38 HelloCpp (HelloCpp-XAML\HelloCpp)
Error 5 The type or namespace name ‘CompletedEventArgs’ could not be found (are you missing a using directive or an assembly reference?) C:\Users\Muniraj\Desktop\cocos2d-x-2.2.3\samples\Cpp\HelloCpp\proj.wp8-xaml\HelloCpp\HelloCpp\AdControlCallback.cs 17 35 HelloCpp (HelloCpp-XAML\HelloCpp)
Error 6 The type or namespace name ‘CompletedEventArgs’ could not be found (are you missing a using directive or an assembly reference?) C:\Users\Muniraj\Desktop\cocos2d-x-2.2.3\samples\Cpp\HelloCpp\proj.wp8-xaml\HelloCpp\HelloCpp\AdControlCallback.cs 18 35 HelloCpp (HelloCpp-XAML\HelloCpp)