Creating a class(SOLVED)

Started by Snake Blisken, Wed 30/11/2005 07:28:16

Previous topic - Next topic

Snake Blisken

The manual mentions that object oriented type stuff is possible, and looking at the Zoom module created by SSH, I can see where he created what appears to be an instance of the class Zoom. He called it zzz.

Where is the class Zoom defined? Anyone care to post a small class definition I can peek at to get the idea of how they are structured in AGS? Any other tips, help, anything you have to say on the subject is greatly appreciated.

Note that I am pretty familiar with classes and instances in C++.
Thanks,
Snake Blisken


Snake Blisken

Thanks,
Snake Blisken

DoorKnobHandle

I will hijack this, because I have a small question that fits the thread description perfectly and since the original question is answered, I don't see nothing wrong with it...

Scotch recently mentioned, that there is now the possibility to add functions to a struct (thus acting pretty much like a c++ class). How does that work? I searched but couldn't find anything and scotch didn't answer to my PM...

Thanks!

monkey0506

You import the function:

Code: ags
struct ExampleStruct {
  import int DoSomething(int param);
  import static void DoNothing();
  protected int value;
  };

int ExampleStruct::DoSomething(int param) {
  this.value += param;
  return this.value;
  }

static void ExampleStruct::DoNothing() {
  /* this function does nothing, but note due to it's static nature it does not contain a 'this' pointer or access to member variables */
  }

// in game_start
ExampleStruct ExampleItem;
ExampleItem.DoSomething(5);
ExampleStruct.DoNothing();

DoorKnobHandle

Ah, thanks a bunch, monkey_05_06!

SMF spam blocked by CleanTalk