Howto

Open two instances of Unity at once

onedayitwillmake No Comments

Sometimes you have a project that you’re using as reference, maybe you added some functionality in a previous project or you downloaded a sample project and you are trying to recreate that thing in your new project. It would be great if you could have them both open side by side so you can compare them right?

Unfortunately if you try to open Unity by clicking the icon, it will just bring your current instance into focus, so what can be done?

Here’s a simple trick that allows you to have two instances of Unity open at once, open the second instance from the command line and point it to a project.

$ /Applications/Unity/Unity.app/Contents/MacOS/Unity -projectPath ~/projects/coolgame

Note: You cannot open the same project twice, so if you have to do that create a temporary copy of the project.

Using Greensock JS / TweenMax in a Dart application

onedayitwillmake No Comments

Once you use Greensock / TweenMax / TweenLite, you don’t really want to use anything else.
It’s fast, it’s feature rich, and it works on more browsers than dart itself.
This is a quick post on how to use the animation library, it’s surprisingly easy.

  • First import the dart:js library
    import 'dart:js';

  • Next, add dart.interop.js to your HTML after your own apps script tags.
    Mine looks like this:

    <script type="application/dart" src="dart/mandala.dart"></script>
    <script src="packages/browser/dart.js"></script>
    <script src="packages/browser/interop.js"></script>

Now to call JS from dart you must follow the js-interop syntax, which I agree is a bit annoying – but one approach is to create a wrapper class / function for it.

  • With that out of the way, here is an example of a Tweenmax call to modify the Y / Alpha values of a div:
      // You can also just pass the element's ID instead to greensock
      // but assuming we already retrieved it or may not have an id we would use this method
      HTMLElement divToAnimate = querySelectorAll("#myDiv");
 
      // Context refers to the JSContext, and retrieves global window objects
      context['TweenMax'].callMethod("to", [divToAnimate 
            0.15,
            new JsObject.jsify({
                  "delay" : 0.5,
                  "y": "40"
                  "autoAlpha": 0
            })]);
 
      // A simpler one for reference
      context['TweenMax'].callMethod("to",["#myDiv", 0.15, new JsObject.jsify({x:100})]);

We can think of Context as referring to the Window object in the javascript context. So we retrieve it, and then call a method on it. Passing the method name to and then an array of parameters. For the last parameters, we create a new javascript object using the JsObject.jsify method which takes a map of primitive types with strings as keys.

In the next post / or an update to this one, I will show you how to create a simple wrapper class to make using Greensock more like calling it from JS

Eclipse template project with cocos2dx

onedayitwillmake No Comments

I have created an eclipse project template, which contains an SDK project, with a NDK C++ bindings ( done via ‘javah’ build step ), combined with Cocos2dx helloworld project.
I have used it as the base for 2 projects, and figured I would share.

https://github.com/onedayitwillmake/EclipseAndroid_NDK_SDK/tree/cocos2dx

 

C++11 in Eclipse CDT Part 1 – Getting and Installing GCC4.7

onedayitwillmake one comments

This is the second part of a three part series on using C++0x11 on OSX via Eclipse. If you need a little bit more nudging, you might want to look at Part0 of this series, where I make the case that the Langauge is moving in this direction and as such does not make sense for us to use older outdated tools.

In this post I’ll discuss the process of getting and installing the GCC4.7 compiler. First we need to arm our computer with the right tools.

We’ll be configuring and installing the following tools:

  • Macports: A tool for configuring / building / installing ¬†tools, binaries, etc from terminal on OSX similar to ports or apt-get
  • Xcode 4.2+ : Required for above
  • Xcode 4.2+ Command Line Support: Required to build macports
  • Eclipse CDT: Our editor