how to create project for wp8/winrt - cocos2d-x

in create_project.py
# Create cross-platform cocos2d-x project
# define global variables
PLATFORMS = {
"cpp" : ["ios", "android", "win32", "mac", "linux"],
}
I can not find out the parameter to create the cocos2dx project for wp8/winrt.
Your comment welcome

My create_project.py file looks exactly like this: http://www.cocos2d-x.org/attachments/2790/create_project.py (I use version 2.2.1). If you specify cpp in the parameters, it creates wind32 and winrt in platforms_list:
if ("cpp" == context["language"]):
context["src_project_name"] = "HelloCpp"
context["src_package_name"] = "org.cocos2dx.hellocpp"
context["src_project_path"] = os.getcwd() + "/../../template/multi-platform-cpp"
platforms_list = ["ios",
"android",
"win32",
"winrt",
"wp8",
"mac",
"blackberry",
"linux",
"marmalade"]
Then it uses those values here:
for platform in platforms_list:
processPlatformProjects(platform)
Project template is supposed to be created in your project path.

cocos2d-x 3.0 doesnt support winrt or windows phone. You would have to use 2.2.3 for it and cpp as the language.
For winrt you would use the proj.winrt folder and proj.wp8 or proj.wp8-XAML for making games for wp8.

Related

Adding Jetpack Compose to one build variant

I have a project which supports API 19 and higher. I want to implement jetpack compose to the project but i want to keep supporting below API 21. For this purpose, I created two flavors: "minApi21", "minApi19". I want minApi21 to support compose while minApi19 works with the old code.
Here is the build.gradle file:
android {
.
.
.
buildTypes {
debug {
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
.
.
.
flavorDimensions "api"
productFlavors{
minApi21 {
dimension "api"
minSdkVersion 21
versionCode 2000 + android.defaultConfig.versionCode
}
minApi19 {
dimension "api"
minSdkVersion 19
versionCode 1000 + android.defaultConfig.versionCode
versionNameSuffix ".19"
}
}
.
.
.
if (getGradle().getStartParameter().getTaskRequests()
.toString().contains("MinApi21")){
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerVersion = "1.5.31"
kotlinCompilerExtensionVersion = "1.1.0-alpha05"
}
}
}
Here is the dependencies:
dependencies{
.
.
.
minApi21Implementation 'androidx.activity:activity-compose:1.3.1'
// Integration with activities
minApi21Implementation "androidx.constraintlayout:constraintlayout-compose:1.0.0-beta02"
minApi21Implementation "androidx.compose.runtime:runtime:1.1.0-alpha05"
// Compose Material Design
minApi21Implementation 'androidx.compose.material:material:1.0.2'
// Animations
minApi21Implementation "androidx.navigation:navigation-compose:2.4.0-alpha09"
minApi21Implementation 'androidx.compose.animation:animation:1.0.2'
// Tooling support (Previews, etc.)
minApi21Implementation "com.github.skydoves:landscapist-fresco:1.3.6"
minApi21Implementation "androidx.compose.ui:ui-tooling:1.0.2"
// Integration with ViewModels
minApi21Implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.4.0-beta01'
minApi21Implementation "com.google.accompanist:accompanist-permissions:0.18.0"
minApi21Implementation "androidx.compose.ui:ui:1.0.2"
minApi21Implementation "androidx.compose.ui:ui-tooling-preview:1.0.2"
minApi21Implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
androidTestMinApi21Implementation 'androidx.compose.ui:ui-test-junit4:1.0.2'
androidTestMinApi21Implementation "androidx.test.espresso:espresso-core:$espressoVersion"
androidTestMinApi21Implementation "androidx.test.espresso:espresso-contrib:$espressoVersion"
androidTestMinApi21Implementation "androidx.compose.ui:ui-test-junit4:1.0.2"
}
With this build.gradle file, both minApi19 and minApi21 debug versions build perfectly fine, but when i create signed bundles i got the error message:
Task :app:compileMinApi19ReleaseKotlin FAILED
androidx.compose.compiler.plugins.kotlin.IncompatibleComposeRuntimeVersionException: The Compose Compiler requires the Compose Runtime to be on the class path, but none could be found. The compose compiler plugin you are using (version 1.1.0-alpha05) expects a minimum runtime version of 1.0.0.
at androidx.compose.compiler.plugins.kotlin.VersionChecker.noRuntimeOnClasspathError(VersionChecker.kt:112)
at androidx.compose.compiler.plugins.kotlin.VersionChecker.check(VersionChecker.kt:89)
at androidx.compose.compiler.plugins.kotlin.ComposeIrGenerationExtension.generate(ComposeIrGenerationExtension.kt:61)
at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr$lambda-1(JvmIrCodegenFactory.kt:126)
at org.jetbrains.kotlin.psi2ir.Psi2IrTranslator.generateModuleFragment(Psi2IrTranslator.kt:89)
at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr(JvmIrCodegenFactory.kt:146)
at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr$default(JvmIrCodegenFactory.kt:64)
at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.generateModule(JvmIrCodegenFactory.kt:59)
at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.compileCorrectFiles(KotlinCodegenFacade.java:35)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.generate(KotlinToJVMBytecodeCompiler.kt:321)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:113)
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:56)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:169)
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:92)
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44)
at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98)
at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:412)
at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:112)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally(IncrementalCompilerRunner.kt:358)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally$default(IncrementalCompilerRunner.kt:300)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl$rebuild(IncrementalCompilerRunner.kt:119)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:170)
at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:81)
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:607)
at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:96)
at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1658)
I tried to declare compileOptions and buildFeatures in flavor, got the same error.
How can i solve this issue and why it fails only in release version?
We're also playing around Jetpack Compose on an opensource project and had the same issue which solved by actually doing something like this only for the runtime part,
if (gradle.startParameter.taskNames.any { "minApi21" in it || "MinApi21" in it }) {
implementation("androidx.compose.runtime:runtime:$composeVersion")
}
(it is in Kotlin DSL not Groovy so you have to do the conversion yourself)
And here is the part I've done it, https://github.com/persian-calendar/DroidPersianCalendar/blob/2af5eb3/PersianCalendar/build.gradle.kts#L200
I know it is not ideal but was is good enough for us until compose itself gets useful enough so abandoning Android 4 worth the benefits of compose brings on the table and this makes it the switch actually worthy but this hacky solution makes the signed builds of separated flavor for compose actually work.

WP8 compass app issue

I am learning the WP8 development. I am trying to incorporate compass in my application. I have found nice tutorial online but I have one issue with this piece of code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Devices.Sensors;
namespace PhoneApp4
{
public partial class CompassScreen : PhoneApplicationPage
{
Compass compass = new Compass();
RotateTransform transform = new RotateTransform();
double TrueHeading;
double ReciprocalHeading;
double HeadingAccuracy;
bool Alphabetic = false; //alpha output setting, default is false
bool Calibrating = false;
// Constructor
public CompassScreen()
{
try
{
InitializeComponent();
compass.CurrentValueChanged += new EventHandler<SensorReadingEventArgs<CompassReading>>(compass_CurrentValueChanged);
compass.Calibrate += new EventHandler<CalibrationEventArgs>(compass_Calibrate);
When I do it as a an app that only displays the compass the app works fine, if I want to
incorporate in an app that have few windows it does not work the part ".CurentValueChanged" and ".Calibrate" is underlined in red, the last 2 lines.
compass.CurrentValueChanged
compass.Calibrate
Can you suggest what I am doing wrong?
Thanks
R.
According to the documentation, those events do not exist on the class elaborated for Windows 8 devices. The only event you may listen for (which is equivalent to CurrentValueChanged) is ReadingChanged.

Updating Libgdx through gradle

According to the Libgdx wiki, I should have a "gdxVersion = ..." line in my grade build file (I'm assuming of my core project). However, I do not. Is there some other way to update my libgdx?
build.gradle:
apply plugin: "java"
sourceCompatibility = 1.6
sourceSets.main.java.srcDirs = [ "src/" ]
eclipse.project {
name = appName + "-core"
}
Taken from the wiki:
Open up the build.gradle file in the root of your project, and locate the following line:
gdxVersion = "1.0.0"
That means you should not edit the build.gradle file in your core project, but in the root folder of your projects.
After that you should proceed according to your IDE as it's described in the wiki article.
Find out build.gradle in root of your project
allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
version = '1.0'
ext {
appName = "XYZ"
gdxVersion = '1.8.0'
roboVMVersion = '1.12.0'
box2DLightsVersion = '1.4'
ashleyVersion = '1.7.0'
aiVersion = '1.7.0'
visRuntime = '0.3.1'
visUI = '1.0.0'
overlap2D = '0.1.0'
}
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}
update your gdxVersion with newer version.
Usually updating gradle in the middle of a project or during an update messes up a lot of things. Just make sure your Libgdx version can handle newet Gradle versions. Most of the time you will receive a build error and will spend hours to fix that.
In my opinion, If you are not an expert just leave it be.

Debugging WP8 Native Code using a file

I'm developing a WP8 app that has some native code (runtime component).
Inside the runtime component I need to check to content of a c style array.
Because this array is not small, I thought the best I could do is write the array in a file
using fopen/fwrite/fclose;
Checking the returned value from fopen and fwrite, I can see that it succeeded.
But I cannot find the file (using Windows Phone Power Tools).
So where has the file been written?
Is there another way to dump the content of the array to a file (on the computer) from visual studio ?
I'm unfamiliar with the fopen/fwrite/fclose APIs in WP8. Which probably means it's not a whitelisted API you can use to submit your app with. It's best if you just use "Windows::Storage::ApplicationData::Current->LocalFolder" when working with IsoStore in C++. See Win8 code sample # http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh700361.aspx?cs-save-lang=1&cs-lang=cpp#code-snippet-1
Thanks Justin,
here's how I ended up doing it:
auto folder = Windows::Storage::ApplicationData::Current->LocalFolder;
Concurrency::task<Windows::Storage::StorageFile^> createFileOp(
folder->CreateFileAsync(L"Data.bin", Windows::Storage::CreationCollisionOption::ReplaceExisting));
createFileOp.then(
[nData, pData](Windows::Storage::StorageFile^ file)
{
return file->OpenAsync(Windows::Storage::FileAccessMode::ReadWrite);
})
.then([nData, pData](Windows::Storage::Streams::IRandomAccessStream^ stream)
{
auto buffer = ref new Platform::Array<BYTE>(pData, nData);
auto outputStream = stream->GetOutputStreamAt(0);
auto dataWriter = ref new Windows::Storage::Streams::DataWriter(outputStream);
dataWriter->WriteBytes(buffer);
return dataWriter->StoreAsync();
})
.wait();
Now compare that to what I "meant" :
FILE *fp = fopen("Data.bin", "wb");
if (fp)
{
int ret = fwrite(pData, 1, nData, fp);
fclose(fp);
}

Is there a way generate a shortcut file with adobe air?

Good afternoon,
I would like create a application that can can create folders and short cuts to folders in the file system. The user will click a button and it will put a folder on there desktop that has short cuts to files like //server/folder1/folder2 Can you create a desktop shortcut with code in adobe air? How would you do that? How do you create a folder? I keep thinking this should be easy but i keep missing it.
Thank you for your help sorry for the trouble,
Justin
If your deployment profile is Extended Desktop, you may be able to use NativeProcess and some simple scripts that you could package with your app. This approach would entail handling the functionality on a per OS basis, which would take some work and extensive testing. However, I wanted to at least share a scenario that I verified does work. Below is a test case that I threw together:
Test Case: Windows 7
Even though the Adobe documentation says that it prevents execution of .bat files, apparently it doesn't prevent one from executing the Windows Scripting Host: wscript.exe. This means you can execute any JScript or VBScript files. And this is what you would use to write a command to create a shortcut in Windows (since Windows doesn't have a commandline command to create shortcuts otherwise).
Here's a simple script to create a shortcut command, which I found on giannistsakiris.com, (converted to JScript):
// File: mkshortcut.js
var WshShell = new ActiveXObject("WScript.Shell");
var oShellLink = WshShell.CreateShortcut(WScript.Arguments.Named("shortcut") + ".lnk");
oShellLink.TargetPath = WScript.Arguments.Named("target");
oShellLink.WindowStyle = 1;
oShellLink.Save();
If you package this in your application in a folder named utils, you could write a function to create a shortcut like so:
public function createShortcut(target:File, shortcut:File):void {
if (NativeProcess.isSupported) { // Note: this is only true under extendedDesktop profile
var shortcutInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
// Location of the Windows Scripting Host executable
shortcutInfo.executable = new File("C:/Windows/System32/wscript.exe");
// Argument 1: script to execute
shortcutInfo.arguments.push( File.applicationDirectory.resolvePath("utils/mkshortcut.js").nativePath);
// Argument 2: target
shortcutInfo.arguments.push("/target:" + target.nativePath);
// Argument 3: shortcut
shortcutInfo.arguments.push("/shortcut:" + shortcut.nativePath);
var mkShortcutProcess = new NativeProcess();
mkShortcutProcess.start(shortcutInfo);
}
}
If one wanted to create a shortcut to the Application Storage Directory on the Desktop, the following would suffice:
var targetLocation:File = File.applicationStorageDirectory;
var shortcutLocation:File = File.desktopDirectory.resolvePath("Shortcut to My AIR App Storage");
createShortcut(targetLocation, shortcutLocation);
Obviously there's a lot of work to be done to handle different OS environments, but this is at least a step.
As far as I know, File class does not allow the creation of symbolic links. But you can create directories with createDirectory(): http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/File.html#createDirectory%28%29
Check if this can be useful: http://www.mikechambers.com/blog/2008/01/17/commandproxy-net-air-integration-proof-of-concept/
Air doesnt let you create shortcuts natively. Here's a workaround that works with Windows [may work on Mac but I don't have a machine to test].
Using Air, create a file that contains the following plain text
[InternetShortcut]
URL=C:\path-to-folder-or-file
Replace path-to-folder-or-file with your folder/file name
Save the file as test.url
Windows recognizes this file as a shortcut.
It is possible to coerce Adobe Air into creating symbolic links, other useful things, on a Mac. Here's how I did it:
You will need AIRAliases.js - Revision: 2.5
In the application.xml add:
<!-- Enables NativeProcess -->
<supportedProfiles>extendedDesktop desktop</supportedProfiles>
In the Air app JavaScript:
// A familiar console logger
var console = {
'log' : function(msg){air.Introspector.Console.log(msg)}
};
if (air.NativeProcess.isSupported) {
var cmdFile = air.File.documentsDirectory.resolvePath("/bin/ln");
if (cmdFile.exists) {
var nativeProcessStartupInfo = new air.NativeProcessStartupInfo();
var processArgs = new air.Vector["<String>"]();
nativeProcessStartupInfo.executable = cmdFile;
processArgs.push("-s");
processArgs.push("< source file path >");
processArgs.push("< link file path >");
nativeProcessStartupInfo.arguments = processArgs;
nativeProcess = new air.NativeProcess();
nativeProcess.addEventListener(air.NativeProcessExitEvent.EXIT, onProcessExit);
nativeProcess.addEventListener(air.ProgressEvent.STANDARD_OUTPUT_DATA, onProcessOutput);
nativeProcess.addEventListener(air.ProgressEvent.STANDARD_ERROR_DATA, onProcessError);
nativeProcess.start(nativeProcessStartupInfo);
} else {
console.log("Can't find cmdFile");
}
} else {
console.log("Not Supported");
}
function onProcessExit(event) {
var result = event.exitCode;
console.log("Exit Code: "+result);
};
function onProcessOutput() {
console.log("Output: "+nativeProcess.standardOutput.readUTFBytes(nativeProcess.standardOutput.bytesAvailable));
};
function onProcessError() {
console.log("Error: "+nativeProcess.standardError.readUTFBytes(nativeProcess.standardError.bytesAvailable));
};
Altering the syntax of the command and parameters passed to NativeProcess you should be able to get real shortcuts on Windows too.