Alternative for object pools in cocos2d-x v3.3 - cocos2d-x

i am migrating my game from AndEngine, there I always used object pools for efficient use of objects like bullets etc in my game. What alternate do i have in cocos2d-x for this scenario?

Unfortunately Cocos2d-x doesn't have built-in object pool. Cocos2d-JS(Cocos2d-HTML5) does have it in extensions.
http://cocos2d-x.org/docs/manual/framework/html5/v3/cc-pool/en
https://github.com/cocos2d/cocos2d-html5/blob/develop/extensions/ccpool/CCPool.js
But you can implement your own object pool like the example of some Cocos2d-x book.
https://github.com/setiawand/SkyDefenseExample/blob/master/Classes/HelloWorldScene.h
https://github.com/setiawand/SkyDefenseExample/blob/master/Classes/HelloWorldScene.cpp
Object Pools in Cocos2D-X v3.0 Final - Deprecated CCArray for migration 2.x to 3.x
void createPools(void);

Related

AS3 PNG Encoder without BitmapData

Simply stated, I'm looking for a PNG encoder that will directly convert a RGB/RGBA ByteArray into a PNG file also stored in a ByteArray without making use of the BitmapData class at all. I'm currently working on a ~v4.0 Scaleform Gfx project - which doesn't support any of the Get/SetPixel methods.
If you're using Scaleform 4.0, then likely your best solution is to bind the ByteArray in question to a GFx::Value in C++, via an ExternalInterface call. With the GFx::Value, you can use ReadByteArray, WriteByteArray, etc.
Scaleform 4.0 by default has a PNG reader/writer built in, Scaleform::Render::PNG::FileReader/FileWriter. These basically just wrap libpng functionality. You can use Scaleform::MemoryFile to wrap the incoming/outgoing bytes, so they can use this interface.
Alternatively, if you'd like to use the BitmapData API, you could upgrade to the final version of Scaleform, which is available from Autodesk support for free, assuming you have a valid license.

Xml serialization/deserialization in WinRT (Store application)

I need to make a Windows Store application that exchanges xml serialized data over a TCP connection with a server. Since I need to use Direct3D rendering in the application I went for the c++/cx store application template however I ran into issues with xml serialization/deserialization.
My usual approach in C# would be to use the XmlSerializer and classes with DataContractAttribute annotations. However as soon as I try to import System.Xml.Serialization assembly I get the C1114 error - WinRT does not support #using of a managed assembly. However there are lots of examples that mention using this approach in a Windows Phone app from C#.
So the question is - is only c++/cx limited in support for .NET in Windows Store applications and C# can use all the standard components on phone as well or is switching to C# in this case also not a solution and I need to use the WinRT classes for xml serialization/deserialization?
Your confusion is understandable, what with the variety of frameworks Microsoft has put out there.
C++/Cx is a native binding to the Windows Runtime (WinRT). It does not use any managed code or the .NET framework in any way, which is why you're getting the C1114 error.
C# provides a managed binding to WinRT. It does leverage the .NET framework, so in a C# Windows Store application, you can make use of some of the base-class library. This subset is referred to as the .NET Profile. This article talks about this more: http://blogs.msdn.com/b/dotnet/archive/2012/04/17/net-for-metro-style-apps.aspx
In your specific case, you are using a C++/Cx application because you want access to Direct3D. This makes sense, although it means that you will not have access to System.Xml.Serialization. Instead, as you surmised, you will need to use APIs that are available to C++/Cx to read XML, specifically Windows.Data.Xml.Dom: https://msdn.microsoft.com/en-us/library/windows/apps/windows.data.xml.dom.aspx

What is Cocos2d-JS?

Cocos2d-JS is Cocos2d-x engine's JavaScript version that includes
Cocos2d-html5 and Cocos2d-x JavaScript Bindings. It equips your game
with cross-browser and cross-platform abilities, accompanied by full
Cocos2d-x features and simplified JavaScript friendly APIs.
I understand that you write JS and it works every where, but how it is done? I want to understand this diagram: http://www.cocos2d-x.org/wiki/Getting_Started_Cocos2d-js As I understand cocos2d-html5 is the same thing as cocos2d-x but it is in JS and based on WebGL. If this is true then what is Cocos2d-JSB? Does it compile JS script to native code? Or is it a JS extended interpreter, that understands more than native interpreter and can interpret cocos2d specific commands?
As I understand cocos2d-html5 is the same thing as cocos2d-x but it is
in JS and based on WebGL. If this is true then what is Cocos2d-JSB?
I believe the JSB appended to cocos2d-x JSB simply means: cocos2d-x JavaScript Bindings
The module that does the translation / mediation between two programming languages is commonly called a "binding". The JSB is just a small aspect of cocos2d-x that allows users to run apps written in cocos2d-js Javascript via the cocos2d-x C++ rendering engine.
Note that cocos2d-html5 is not exactly the same as cocos2d-x. It provides similar functionality than cocos2d-x but runs only in a web browser. Obviously cocos2d-html5 has no functionality for touch or accelerometer input, and other restrictions when it comes to saving and loading files, for instance.
Does it compile JS script to native code? Or is it a JS extended interpreter, that understands more than native interpreter and can interpret cocos2d specific commands?
The JSB simply maps between the Javascript API and the C++ cocos2d-x versions of classes, methods, identifiers and what not.
I don't know whether it compiles Javascript to native code.
The gist of this:
cocos2d-js provides a programming interface (API) in Javascript that produces the same results whether you run it in the browser via cocos2d-html5 or on other (mobile) platforms via cocos2d-x.
Cocos2d-x uses SpiderMonkey, the Firefox JS virtual machine (VM), to
execute JS code.
The JS VM is extended to support all the cocos2d, Chipmunk and CocosBuilder Reader APIs. So, when you create a CCSprite in JS, you
are actually creating an C++ CCSprite. When you create an action in
JS, you are actually creating an C++ action, when you create a
particle system in JS, you are actually creating an C++ particle
system… and so on. This approach is about 10x ~ 20x faster than HTML5
games even when they use accelerators like directCanvas Basically all
the cocos2d, Chipmunk or CocosBuilder Reader APIs are going to perform
almost at native speed. But you should pay attention to the following
scenarios: The performance could be slow down while the garbage
collector is run. Workaround: Do not create many JS objects. Reuse as
many as possible Having a complex main loop could slow down the
performance. Workaround: Profile your JS code, and if you can’t
further optimize it, write the expensive parts in C++ and create JS
bindings for those functions.
This is from wiki. So the JS interpreter is extended to understand cocos2d api command such as create Action or create Sprite.

Can I code in both LUA and Java in Cocos2d-x?

Right now I'm using Corona SDK so I have experience with LUA but I need to implement some features in Java but I would still like to use LUA as the "main" language. Is this possible in Cocos2d-x?
Another question is if native objects will always be on top as in Corona SDK? Maybe this is not a Corona specific problem, but maybe a thing with the devices?
there is a javascript binding and Lua binding but no java check alternative game engine for java like Slick2D

Roles of JavaFx 2.0, Swing, and Java 2D in Java 7 Ecosystem

I am a bit confused as to the new standards. To the best of my understanding Swing -- the former standard interface library -- is based on it's predecesor, AWT, and the Java 2D graphics libraries.
Now that JavaFx 2.0 has replaced Swing my question is where does Java 2D fit in? Is it possible to use Java 2D methods to generate graphics on JavaFX interface elements?
Thank you
From the Oracle client tech lead's 10000 foot view of JavaFX.
At various times people have written articles or blog posts or forum posts asking the question, what is JavaFX? ... Is it a replacement for Swing? (The answer would be an emphatic Yes).
Mostly, use of Java2D is unnecessary with JavaFX as JavaFX has strong immediate and retained mode 2D apis.
If really needed, you can use Java2D methods to render to a buffer backing a JavaFX WritableImage or an awt image which you can later convert to a JavaFX image.
To an extent, you can still use Swing together with JavaFX if you want or need to. For example people have embedded a JavaFX webview in the Swing based NetBeans platform.