Open-sourcing my framework : any interest?

During the last year and a half, I have been working full time on cocos2d-x apps. I am currently at 6 apps pushed to production, which means I am starting to have a quite large shared codebase on top of cocos2d-x, which covers both things done by cocos2d-x, but in a different way that fit my use case, and things that the cocos2d-x team doesn’t plan on supporting.

I have been wondering if the community would be interested in part of that code, which is currently closed-source but that I can open-source.

Here are the main features that are covered:

Native wrappers part (support iOS and Android, other
platforms aren’t planned anytime soon):

  • Analytics : support a dual delivery to Google Analytics and Flurry (based on Di Wu’s AnalyticX project), with very limited features
  • Audio Player / Recorder : similar to SimpleAudioEngine, except it supports recording
  • Audio Picker : pick a sound from the user library
  • Video Player : again, limited features. Supports VLC on Android, which means you can change playback rate
  • Video Picker : pick a video from the user library, or directly record it
  • Local Notification : standard local notifications (note : on Android, it doesn’t handle the use case when an app is shut down)
  • Mail / URL : send a mail (via the user’s mail app) or open an URL (via browser)
  • Image Picker : pick an image either from library or from camera (using Intent on Android, not in the app)
  • In App : support for iTunes and Google Play Billing
  • Text To Speech : currently only available on Android
  • Miscellaneous : everything that didn’t fit the previous one: get/set luminosity, volume, use vibrations, get local language, app name, is a phone

Core part (a good part of those features may be redundant with cocos2d-x current features, most were designed on cocos2d-iphone beta versions)

  • CCB : one-line loading with autoresizing and several custom properties loading
  • Graphics : a layer above cocos2d-x objects to allow searching objects by name, adding custom informations, and some other niceties
  • Scenes : automatic change of scenes with a Notification, taking care of all creation/destruction
  • Gestures Handling : several gestures recognizers, including: tap, selection (long press), swipe, scrolling, inertia generator following scrolling
  • Utility : miscellaneous features, including string utilities, random generators, a lot of shorteners for frequently used methods, plist format persisting and a localization utility

Currently, everything works more or less, but there is a lot of dead code, and a need to refactor and document everything (there is absolutely no documentation).  I need to migrate to V3 as well since V2 is deprecated (currently on V2.2, with lots of modifications on cocos2d-x).

I think the project will be in a state I am comfortable open-sourcing in 3 to 6 months. I also plan to have a sample project showcasing the features along with the framework (currently, the sample project is the minimal required code to have the app compile and launch to a black screen).

Here are the questions :

  • Do you think all or part of this would be useful to you ?
  • Would you use it even if there is no support, and only iOS and Android ?
  • If you plan to use it, would you contribute ?
7 Likes

Hi Fradow,

It is nice idea. But strange questions :smile:
If you want to open your sources - just do it. Why to ask questions like above about the thing that I don’t see right now?
How I can say - is it useful or not or will I contribute to it? Right now I can say “will see” only :smile: it depends what you will share in 6 months…

Hi Lion_Ts,

I don’t really see the point of open-sourcing something nobody wants, since it’s going to take effort to get to a clean state and maintain it.

The thing is: cocos2d-x is a game engine, and most of those features are not used by typical games. That’s why I really wonder if anyone is really going to be interested at all.

Interested :wink:

we’re all interesting in open source :smile:
so, proceed.
I’m interested in all the parts; IOS+Android is good for me; probably will contribute.

I’m interested in your utility functions and gestures the most (to simplify/abstract out repetitive code) but this overall looks very promising. :thumbsup:

How easy it is to integrate will definitely influence how many contributions there will be (as opposed to Soomla, which I love, but is too difficult to do a PR). If it’s clean and has enough momentum, I’d probably help with documentation.

For now, I’m interested in some parts of your work, but who knows in the future, I might need the others? Looking forward to it.

I’m very interested .

open source it ! it will be great for every one

Thanks for the answers :slight_smile:

Since there is so much interest, I’ll open-source as soon as it is ready. Before doing that, I’ll need to rename the project, migrate to another github account, write a proper readme and add a licence (I’m leaning toward BSD 2 clauses). That will be a very rough version with close to no documentation, outdated cocos2d-x version and a great need to refactor. The native wrappers should be usable though.

I’ll keep you updated, it should be ready in 2/3 weeks (unfortunately, I have more pressing things to do before).

@Fradow - I think this is beneficial to everyone and you are generous for doing it.

I, personally, would be interested in gesture recognition. I’m currently experimenting with ways to accomplish this.

@slackmoehrle What kind of gesture recognition are you interested in ?
The gestures I recognize are very basic (although there is quite a bit of complexity to support multi-touch in an acceptable way) : they are actually all available on iOS (Objective-C), although the way I implement them allow a few specific things you can’t do with iOS recognizers (at least that was the case 2/3 years ago, when I wrote their Objective-C implementation exactly for that reason).

They could be described in a few lines, by suscribing to touchStarted/Moved/Ended/Cancelled:

  • see if the distance and time is inferior to a threshold for a tap
  • see if horizontal/vertical distance is superior to a distance threshold and inferior to a time threshold for a swipe
  • etc…

The only “sensible” part is adjusting the thresholds according to device dpi/resolution (I only use resolution because it’s good enough according my tests).

If you need more advanced gesture recognition, like for example lines and circle, I have some Objective-C code that actually do that. It’s an entire different project though, and need to be translated in C++. If you want that, contact me privately, I’ll share you the code privately (I will not open-source that anytime soon).

I’m primarily working with scrolling around my layer better and pinch to zoom.

I do not have pinch gesture yet, but I do have scrolling.
There are 2 pitfalls to scrolling:

  • first one is multitouch: if you have 2 (or more) touches, do you want the scroll to be twice as fast or the same speed ? I choosed the second (because if you want to pinch at the same time, it feels weird to have the scroll go twice as fast)
  • second one is refresh rate: if you spit scrolling events at each touchMoved event, you are going to have a bad time. I adress this issue by throttling the scrolling events I sent with an artificial limit

For pinch, I have Objective-C code I didn’t bother to port in C++ because my current apps don’t need it. It should be easy and short enough to port it. I think I could do that on my free time.

Do you have a pressing need for it ? I can privately share some snippets if that’s something you are currently working on.

What if we wrap the native gesture recognizers (whose touch-handling code is likely better than anything we’d write), with an abstraction? Granted, I haven’t looked at the touch methods and how they compare on iOS and Android, but we’d get all of that for free.

@Jgod you could do that, but there will likely be several problems you’d have to work around:

  • you’d have to implement it on every single platform cocos2d-x support (or that you want to support), instead of a single c++ implementation
  • you will have to use the least powerful common denominator, so that it works everywhere (if a platform have something fancy the others don’t, too bad you can’t use it)
  • there may be discrepancies between OS, which is in general not a good thing
  • there are already some limitations on what you can do: there was at least two use cases that prompted me to roll my own on iOS at the time of first writing those implementations in Objective-C, and I didn’t explore Android possibilities
  • you have to map everything back to cocos2d-x coordinates and do the wrappers. While not very hard, those are time consuming, and you have to maintain everything separately.

You may have some things for free (probably faster than you can do, well tested and calibrated etc…), but for all those reasons I prefer to get my hands dirty and re-implement it in C++. I don’t remember anyone telling me it didn’t feel right lately (but some things have indeed take me a lot of time to get right, and there still are small differences with native detectors, mostly irrelevant things).

The great thing for game is that you can easily tweak them for a special gameplay. For example, make the tap recognizer more restrictive for very short taps, or change the swipe directions to diagonals.

That’s a good analysis, and now I agree. Eagerly waiting to see your implementation.

Hello everyone,

The first version of FenneX (that’s the name I chose) is available, and include everything mentionned in the first post. https://github.com/FenneX/FenneX

Let me know if you find anything useful at all and what you think would be the most important things to do.

I’m currently upgrading to cocos2d-x V3.2, I’ll obviously update FenneX ASAP.

Thanks.

4 Likes

This is very generous of you @fradow.

Thanks for all your work, will take a look at it later.

1 Like