Programming

You are here

Build Order Matters (And Other Tales)

Just a few notes from the battlefield that is my game for Fantoche:

Build Order Matters

Whenever you get the error message «The type or namespace name <type/namespace> could not be found (are you missing a using directive or an assembly reference?)» in Unity when trying to access a component on another GameObject, do not bother to rewrite your complete code.

English

Getting Things In and Out of Arrays in ActionScript or JavaScript

Since I have a hard time keeping push(), pop(), shift() and unshift() apart, here’s a little cheat sheet I whipped up:

Array Manipulating Cheat Sheet

Undefined

Dynamically Referencing Variables and Methods in ActionScript

Sometimes, the state of an object decides which method has to be executed. Instead of an unwieldy switch construction like this …

switch (task) {

case "sleep":
sleep();
break;

case "walk":
walk();
break;

}

… you can use the someObject[someExpression] notation. This works for any object, and you can use it to access both variables and methods. All those lines from above become this:

thistask;

English

Using Unity 3D 2.6 with MonoDevelop

Since I want to dive into C# and code most of my game in that language, I was searching for a tool to make my life a bit easier – I just love stuff that writes for me …

Since C# is, once again, a rather Microsoft-centric thingy, there aren’t that many editors out there – except for MonoDevelop, which works like a charm on many systems.

English

Extending Functions

Sometimes, you have a function already programmed, and then you need a more refined function, that takes even more parameters. Refactoring? A pain in the ass. Thank god I finally learned how to circumvent that pain:

Make a new, more refined function:

function moreComplexFunction(parameter1, parameter2, parameter3) { //execute stuff }

Then replace the original code in the simple function, replacing the superfluous parameters with standard values:

English