Game Development Reference
In-Depth Information
The image is displayed centered where the dynamic body is. The world:step function updates the
body and takes three parameters. The first is timeStep , which determines the steps. The other two
parameters are velocityIterations and positionIterations . The number of iterations for both
velocity and position define how many calculations are needed to determine the next velocity and
position of the physics body.
Plug-Ins
One advantage of Gideros Studio is that you can create your own plug-ins, thereby extending its
functionality by introducing features that it doesn't currently have.
Note The BhWax plug-in (discussed in Chapter 13) provides complete access to the iOS API and you can use it
to create UIWindows, UIViews, UIKit objects, practically everything that the Apple API offers.
The structure of a Gideros plug-in stub looks like this:
#include "gideros.h"
#include "lua.h"
#include "lauxlib.h"
static int myFunc(lua_State *L)
{
int first = lua_tointeger(L, -1);
int second = lua_tointeger(L, -2);
int result = first + second;
lua_pushinteger(L, result);
return 1;
}
static int luaMy_func(lua_State *L)
{
const luaL_Reg functionlist[] = {
{"myFunc", myFunc},
{NULL, NULL},
};
luaL_register(L, "myPlugin", functionlist);
}
static void g_initializePlugin(lua_State *L)
{
lua_getglobal(L, "package");
lua_getfield(L, -1, "preload");
lua_pushcfunction(L, luaMy_func);
lua_setfield(L, -2, "test");
 
Search WWH ::




Custom Search