Building for the new AppleTV / tvOS

Only touch events, not click events.

We have forked the repo from @hawkwood and added a samples folder which will be updated with more samples https://github.com/SonarSystems/cocos2dx-helloWorld-tvOS/tree/master/Samples

Feel free to add to it

To get click events, you will have to add/modify gameController support to include the new profile for the Siri Remote. I started working on this but had to set it down due to another project.

What else is missing from the AppleTV version, so we can aim to fix this and provide samples.

The tests?

What about the tests???

I think that if they are running everything anyone could ever ask for is there. There are tests on how to invoke external text input. Gyro reading is also a part of the integration, and there are tests for it.
If the remote is integrated so much that you can navigate between the testcases that is a great first step.

It is indeed.

Thanks @SonarSystems for adding in that first touch example. Have you noticed the values this gives on the actual device. I always receive x960 y540 first, going up and to the right increases x and y, going down and to the left decreases the values. There is no way to get the physical start point of the touch on the remote, so e.g. assigning different virtual buttons to the corners is not possible right now.

How do you go about mapping input to the new remote?

Do you think that cocos2d-js will also work with AppleTV?
What would be the steps? Create new JS project and merge it with what you have provided above?

Exactly what type of input are you talking about?

Revisiting what I wrote I was a little unclear, sorry.

What I meant was: How do you map your current controls to the new input e.g. directly touching a sprite on an iOS device vs. focus mode with the remote. There are certainly games that have an advantage, e.g. the ones that only use the left and right area of the screen to steer a car or similar, but there are more complex games that need to be completely rethought for the new type of input. This wasn’t a technical question, rather a game design question.

Don’t know ATM but will keep you updated.

I have put aside a project that would heavily rely on refactoring/rethinking controls in favor of a really nice little project that uses only basic steering.

In addition to the touch which works nicely for steering so far, steering by tilting the remote would be nice as well. Has anyone started working on this? Or maybe some hints at where to start.

I dont know if we can simulate tilt without a physical device but I’m hoping the usual accelerometer code will work but waiting for an actual device.

Apparently we are not quite there yet: https://forums.developer.apple.com/thread/18684

I will tackle this later on in development and see if things change until then.

I also ported cocos2d-x to AppleTV (took some code from other repositories on GitHub). Tested it on simulator and it worked well. I will later integrate input detection from AppleTV remote.
Repository URL: https://github.com/elvman/cocos2d-x/tree/tvos

1 Like

Please do let us know when you have input detection.

Any reason for doing another fork in addition to @hawkwood’s? Would be great if this could be merged centrally. Who is responsible for cocos2d-x tvOS branch? Maybe we should ask them to start accepting pull requests or have @elvman and @hawkwood added as admins for the branch?

I’d be happy to add anyone else as admin.

A further note on actual submission of tvOS apps that will add temporary complications, there is a requirement that all pre-compiled libraries be built against tvOS, not iOS, and that they (and the final app) have Bitcode enabled. I know there is a bunch of prebuilt lib files included with Cocos, so all of those will need to get recompiled to link to tvOS (if they currently link to iOS) and have Bitcode enabled.

Thanks for clarifying the pitfalls along the way, @hawkwood. Is there a guide somewhere as how to set up things so a project compiles by the rules?

edit: I have checked and it seems as if for now we can disable Bitcode in itc.