News Mar 20: R.U.B.E v1.7 released. Instanciable objects!
Feb 21: Added RUBE sample loader for Cocos2d-X v3.4.
Feb 17: Funny Fists released in iOS App store and Google Play store. (YouTube video)
2014
May 25: R.U.B.E v1.6 released. Samplers!
May 12: "On-the-fly" resource updating for Cocos2d-x
Apr 22: New blog post: Inverted pendulum control
Apr 7: On-screen logging class for Cocos2d-x
Mar 22: Downhill Supreme 2 released for iOS and Android
Jan 2: YouTube video: Making soft-body wheels in RUBE
2013
Oct 6: Check out Supplyfront RTS, my 7dRTS entry continued.
Sep 26: R.U.B.E v1.5 released. Customizable item labels, snap-to-grid, export filtering, full-text help search.
Sep 18: Added RUBE sample loader for Cocos2d-X.
Sep 16: Updated RUBE sample loader for Cocos2d v2.
Aug 12: RUBE loader for Nape by Zeh Fernando
Aug 7: Added RUBE sample loader for SFML.
Jul 30: Try my MiniLD 7dRTS entry.
Jul 24: Added physics-driven particles tutorial.
Jul 20: New blog post: rendering solid ground (as in Downhill Supreme)
Jul 18: R.U.B.E v1.4 released. Command-line interface for batch jobs, hotkeys for scripts, better script management.
May 22: Downhill Supreme is out now! (iOS)
Apr 2: R.U.B.E v1.3 released. Collision bitplane editing, Cocos2d-iphone loader, usability improvements.
Mar 11: R.U.B.E v1.2 released. Now supports weld, friction, motor joints and automatic image reloading.
Mar 10: RUBE loader for libGDX by Tim Scott
Jan 28: New blog post: a functional combustion engine!
Jan 22: New blog post: wind tunnel
Jan 20: Added explosions tutorial.
Jan 16: Added buoyancy tutorial.
Jan 16: AndEngine sample project to load RUBE scene by Bart Hirst
Jan 14: R.U.B.E v1.1 released, now supports custom properties.
Jan 1: All basic tutorials are now available in Chinese at ohcoder.com Huge thankyou to @OhCoder!
2012
Dec 23: Discussion forums have been set up
Dec 4: R.U.B.E v1.0 is ready !
Dec 2: YouTube video: Box2D pendulum clock
Nov 26: New blog post: rocket platform thingy
Nov 25: Video of R.U.B.E scenes in Chipmunk.
Nov 23: A sample project to load R.U.B.E scenes into Chipmunk physics! Details here.
Nov 14: An XCode sample project to load R.U.B.E scenes on iOS is now available. Details here.
Nov 11: A Java version of b2dJson is now available, based on JBox2D.
Nov 6: A Javascript version of b2dJson based on box2dweb is now available. Demo here!
Nov 2: The full specification of the JSON format used by b2dJson can be found here: b2dJson file structure
Oct 28: YouTube video: 2-minute ragdoll in R.U.B.E Box2D editor
Sep 29: YouTube video: R.U.B.E Box2D editor usage example

Cocos2d-x resources - Extra file utils

Last edited: May 16 2014

Extra file utils (Android + iOS, C++)


While preparing the "On-the-fly resource updating" topic, I remembered that it depends on some extra file utility functions I added myself. I'll make these available here as a separate topic since they are not specific to OTF and I expect they will be added to the cocos2d-x someday, in which case you should use the official functions instead.

Here is the outline of what functionality is included, they should be self-explanatory:
1
2
3
4
  bool copyFile( string src, string dst );
  bool deleteFile( string file );
  bool createFolder( string folder );
  int listFolder( string folder, vector<string>& entries, bool directoriesOnly );

These functions expect full paths, so to work with files in the private folder of your app, you'll need to prefix them with getWritablePath. For example, to create a folder called 'saves' in the private folder, you would do:
1
  createFolder( FileUtils::sharedFileUtils()->getWritablePath() + "saves" );

Source code


iforce2dFileUtils.h
iforce2dFileUtils.cpp
iforce2dFileUtilsJNI.cpp
iforce2dFileUtilsIOS.mm

This code was confirmed to work with Cocos2d-x v3 RC1.


Instructions for use (iOS)


1. Add the files (except for the JNI one) to your project.


Instructions for use (Android)


1. Add the files (except for the IOS one) to your project.

2. In iforce2dFileUtilsJNI.cpp, change the CLASS_NAME define to the main activity class of your app.

3. Add the following functions to your main activity class:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
  public static boolean copyFile(File src, File dst) {
      try {
          FileInputStream in = new FileInputStream(src);
          FileOutputStream out = new FileOutputStream(dst);
          byte[] buf = new byte[1024];
          int len;
          while ((len = in.read(buf)) > 0) {
              out.write(buf, 0, len);
          }
          in.close();
          out.close();
      }
      catch( IOException e ) {
          Log.v("cocos2d-x", "Could not copy file: " + src + " to " + dst);
          e.printStackTrace();
          return false;
      }
      return true;
  }
  
  public static boolean copyFile( String from, String to ) {
      return copyFile( new File(from), new File(to) );
  }
  
  public static boolean createFolder( String foldername ) {
      boolean ok = true;
      try {
          File directory = new File( foldername );
          if ( ! directory.isDirectory() ) {
              ok = directory.mkdirs();
          }
      }
      catch ( SecurityException e ) {
          Log.v("cocos2d-x", "Could not create folder: " + foldername);
          e.printStackTrace();
          ok = false;
      }
      return ok;
  }
  
  public static boolean deleteFile2( String filename )
  {
      boolean ok = true;
      try {
          File f = new File( filename );
          f.delete();
      }
      catch ( Exception e ) {
          Log.v("cocos2d-x", "Could not delete file (maybe already deleted): " + filename);
          e.printStackTrace();
          ok = false;
      }
      return ok;
  }
You will need to import android.util.Log and java.io.* for this to compile.



Not seeing the any comments below? Try changing the 'https' in the page URL to just 'http'
Click here: http://www.iforce2d.net/cc2dxres/fileutils