spacer graphic
spacer graphic
Montage of games AGS Logo
spacer graphic

 

spacer graphic
Menu
spacer graphic Home
About
News
Features
Download AGS
spacer graphic Games 
Games main page
Award Winners
Picks of the month
Short games
Medium length games
Full length games
In Production
Hints & Tips
Community
Forums
AGSers World Map
Member websites
Chat
Resources
Tutorials
FAQ
Knowledge Base
Downloads
Links
AGS-related links
* AGS Manual
  * Scripting
    * Pointers in AGS

Pointers for people who know C or C++

Pointers in AGS are based on the C/C++ syntax, so they are declared with an asterisk. However, in AGS you can only create pointers to built-in AGS types, and not to any custom structs declared in your script.

Pointer members are accessed with the dot operator, and not the -> C-style operator. Because AGS doesn't support features such as pointers-to-pointers and so forth, there is no need for a separate operator.

In AGS, pointer memory management is done automatically based on reference counting (similar to the way COM works), so there is no new or delete keyword. When an object is no longer referenced by any pointer variables, it will be freed. For this reason, if you have any global pointer variables it's advisable to set them to null if you are done with them.

AGS pointers are strongly typed, and you cannot cast between types at will like you can in C and C++. AGS will only allow you to compare and assign pointers of the same type, or of the same base type. There is a special keyword null which all pointers can be set to and compared with, which indicates that they are unassigned.

Because there is no new keyword, you cannot create object instances; rather, they are returned by static member functions in AGS, such as File.Open and Hotspot.GetAtScreenXY. See the examples for the functions to get an idea of how to use them.


User comments and notes
There are currently no user comments on this page.
The user comment facility is currently disabled.