Save Custom Objects in Cocos2d-x - object

I'm not sure if this would be possible using sqlite or some other method of saving, but how would one save a custom object in a cocos2d-x game? Can you serialize it and store in the an sqlite database and then unserialize when you want to read the data? Is that efficient enough?
I'm looking for pointers on how to do this. I created a game using Sprite Kit and saving using the NSCoding protocol which was very nice. Not sure if there is something similar in Cocos2d-x, but doesn't look like it. Anyways, any help is appreciated!

Related

Producing PDF files in NodeJS - simpler than puppeteer/chromium but a bit less basic than low level libraries

I'd like to be able to produce PDF files in NodeJS.
Currently, we use puppeteer. We need to produce highly designed documents and so puppeteer/chromium gives me the ability to create a complex layout in HTML with the added benefit of also having the HTML version of the file.
It's great for relatively small documents where design is key.
The problem is when I try to produce long report documents. These documents do not require elaborate design. These are pretty much just a header with some information, and then a simple table with lots of records that stretch far as the eye can see, so they tend to be large. Like, really really large.
When I try using puppeteer for that, well pretty much just crashes and burns because loading such huge layouts into the underlying browser is just too much.
Currently I do "stitching". I create the document by having puppeteer create the doc in parts, and then I connect all those "doclets" into one using PDFKit.
But then I have problems like when one "doclet" ends and a new one begins, there are blank lines. (partially empty pages for no good reason from the perspective of a customer viewing it)
What I'm looking for is a library that has basic layout functionality but that doesn't use a browser (or perhaps uses something lightweight).
Problem is that libraries like PDFkit and pdf-lib seem to be too low level.
I'm going to literally have to "draw" the documents by telling it where exactly the text should be.
If I want tables, I'm going to straight up have to draw rectangles and stuff.
Having to create all of this manually would be a nightmare.
All I want is the ability to create simple layouts (tables, titles, text wrapping, background color) without having to use a library that just launches chromium.
Please, let me know if you know of any such option.
Thanks in advance!
What I tried:
PDFkit/pdf-lib - too low level. Unless I'm getting something wrong, there doesn't seem to be a way to create word wrapped layouts with basic tables.
jsPDF doesn't seem to be able to use the HTML functionality on the server(I think to get it to work I'd have to let it use a browser...? if so, doesn't really help).
Puppeteer/other libraries that pilot a browser - well, it uses a browser so a no-go for large docs.
Praying to Odin - No luck so far.

how to export object from maya into opengl application

Im learning openGL, basically ive created an object in Maya, im wondering how i go about exporting it, and loading it into my application ive created (it is simply a plain square room with different coloured walls at the moment.
OpenGL doesn't have the concept of models. You'll have to write your own model loader, or use one that's already out there. If you opt for writing your own, you should probably export as .obj, that's a fairly simple text based format.

How to save data in a cards based database stack?

I understand that in livecode you may do a database type application a) as a collection of cards as in HyperCard or b) with an SQL db engine like SQLite. In Hypercard (a) there was no need to save data entered into data fields. In livecode I need to use 'File/save' to save data in the development mode. How do I save data in a stand alone application which is cards based. Is this possible at all?
Yes, you can use the "save" command to save the state of your stack in code. To do this in a built standalone however, you need to do a little bit of wrangling by launching the stack with a launcher as detailed in this lesson:
http://lessons.runrev.com/s/lessons/m/4071/l/17375-how-do-i-save-custom-properties-in-a-standalone-application
The executable is never saved. The usual way LC standalones manage this is to create a "splash" stack, which may have a use or not, be visible or not, and contain useful data. Or not. But it is the executable.
And then as many other stacks, substacks and other resources are attached to that stack file as might be required, and all these can be saved. The reason the executable is called a "splash" is because it might appear as an intro window at startup, only to be dismissed in order to get the real work done.
Craig Newman

Can Python or Pygame create separate files in order to save game progress?

I am making a game in which I want it possible to save. Is there some way to program python or pygame so that it creates a notepad (or something similar) file documenting a players progress? I am fairly new to python, so please explain it easily.
Thanks.
You could use Pickle to serialize variables to a file.

Direct3D: Recording to AVI files

In follow up to my previous question, I am able to save the backbuffer of a Direct3DDevice to a surface.
I already found the D3DXSaveSurfaceToFile in the DirectX SDK and it works fine! However, I want to record the obtained surfaces to an AVI file.
I also found the AVIFile reference but they are obviously not straight up compatible with DirectX surfaces.
What would be the best way of approaching this problem? I've seen a number of GDI+/MVC based solutions of grabbing HDCs but those are out of the question. I'm also not sure what kind of data AVIFile expects and how to extract it from the D3DSurface.
Please advise! :)
edit:
Post-processing is also an option. I can capture the surface data in a number of formats, specified here, into memory with D3DXSaveSurfaceToFileInMemory. Afterwards, I could compress this data and then store to disk.
How should I be compressing my data? How should I be storing it? Do I store a timestamp along with it? After recording, how should I turn the generated data into an AVI file?
The source code at this link will show you how to do it:
http://gpalem.web.officelive.com/SimulationRecording.html
Edit: Well you don't have to do things exactly like that linked code. You have a D3DSurface so you can just lock it grab the bits and pass them into CAviFile::AppendFrameUsual ... If you want to change its format then use D3DXLoadSurfaceFromSurface. I didn't say the link was a perfect solution but it DOES show you how to write the frames into an AVi file.
Edit2: As I didn't answer your edit I should do. Firstly don't bother with compression until you have got uncompressed working. Compression is a significantly more complicated thing to get right and you won't be able to get proper compression by simply using the various D3DXSurface copying functions. They don't support the kinds of compression you are after. D3DX is for 3D rendering and NOT for video compression.
For video compression you are best off using DirectShow as you can, simply, add any compressors you wish. This will however mean you'll need to write a "source filter" that you can build your graph off. DirectShow is not an easy thing to use but its very powerful. As far as writing the "source filter" goes you can check out the "Push Source" example in the windows SDK. You will need to adapt it to take the data you are retrieving however.
As an aside, going further on my original edit you could use that code as is by intercepting more D3D9 calls. If you hook the SetRenderTarget calls then you can insert whatever render target you like in there and use the, previously, linked code directly ...

Resources