WP8 Cocos2dx and XAML

I read in Topic http://www.cocos2d-x.org/boards/6/topics/17769.
I also have a problem as he but on Windows Phone 8.

I want to use Facebook sdk for cocos2dx windows phone 8.

Can anybody give me some help? Sample codes or links are extremely welcomed.

Thank you indeed in advance.

1 Like

i also have the same problem. please if u find any thing post it here.

thank you

i also want to know

Hello.
I have problem to show ads in wp8.
I develop my game using cocos2dx.
In wp8 must use XAML to add ads.
Can anybody help me?
Thanks.

I have the same problem , I also use XAML to add ads

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.

namespace PhoneDirect3DXamlAppComponent
{
	public delegate void CallNativeFunctionDelegate();
	public ref class NativeEventHelper sealed
	{	
	public:
		NativeEventHelper(void);
		void SetCallNativeFunctionDelegate(CallNativeFunctionDelegate^ delegate) {
			m_CallNativeFunctionDelegate = delegate;
		}
		bool NativeEventHelper::CallNativeFunction()
		{
			if m_CallNativeFunctionDelegate 
			{
				m_CallNativeFunctionDelegate >Invoke();
				return true;
			}
			return false;
		}
		
	}
	private:
		property static CallNativeFunctionDelegate^ m_CallNativeFunctionDelegate 
}

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)

public void CallNativeFunction()
        {              
            Dispatcher.BeginInvoke(() =>
            {
                //native code
            });
            return;
        }

here is a tutorial about third sdk in wp8, with the example of adcontrol of MS: https://github.com/cocos2d/cocos-docs/blob/master/manual/framework/native/sdk-integration/wp8-thirdSDK/en.md

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)

Thanks in advance.

One thing to @ardas post. I had trouble with using it, but finally solved my problem! Here’s how I solved it: