コード例 #1
0
ファイル: lparticle.c プロジェクト: rainfiel/ejoy2d
static int
lreset(lua_State *L) {
	luaL_checktype(L,1,LUA_TUSERDATA);
	struct particle_system *ps = (struct particle_system *)lua_touserdata(L, 1);
	particle_system_reset(ps);

	if (!lua_isnoneornil(L, 2))	{
		if (!_init_from_table(ps->config, L))
			luaL_error(L, "reset particle error");
	}

	return 1;
}
コード例 #2
0
ファイル: particle.c プロジェクト: zhoukk/pixel
static struct particle_system *_new(struct lua_State *L) {
	int maxParticles = dict_int(L, "maxParticles");
	int totalsize = sizeof(struct particle_system) + maxParticles * (sizeof(struct particle) + sizeof(struct matrix)) + sizeof(struct particle_config);
	struct particle_system * ps = (struct particle_system *)lua_newuserdata(L, totalsize);
	lua_insert(L, -2);
	memset(ps, 0, totalsize);
	init_with_particles(ps, maxParticles);
	if (!_init_from_table(ps->config, L)) {
		lua_pop(L, 2);
		return NULL;
	}
	lua_pop(L, 1);
	return ps;
}