a new version was uploaded (for Acknex 7.85.4 AND Acknex 8.20) the update of the wrapper includes:
- updated to 8.20 - the wrapper can be used without the scheduler - using the Conditional compilation symbols (VS2010) value "NO_SCHEDULER" ("A7_WRAPPER" can be used beside "NO_SCHEDULER" !)
when using the wrapper without the scheduler, references to used delegates have to be stored ! Additionally WrappedDouble, WrappedInt and WrappedString objects are introduced, they have to be used in order to interact with certain methods like pan_setneedle etc... These objects are needed, because WITHOUT a scheduler, the creation/deletion and updating of such variables isn't done automatically ! Additionally no more IEnumerables have to be used, if the scheduler isn't used !
here's an example, providing an overview on how to use the wrapper wihtout a scheduler and how the WrappedDouble is used :
Click to reveal..
Code:
using AcknexWrapper;
namespace NoSchedulerTest
{
public class Program
{
static void Main(string[] args)
{
// opening the engine
EngFun.engine_open(null, null);
// limit frame rate
EngVar.fps_max = 60;
// load an empty level
EngFun.level_load(null);
// create a player entity
Player player =
new Player(new Vector(100, 0, 0));
// create and keep the reference to the delegate as long as it is needed !
WrapperDelegateVoid onSpaceMethodDelegate =
OnSpaceMethod;
// assign the delegate to the EngVar variable
EngVar.on_space =
onSpaceMethodDelegate;
// create a panel
PANEL sliderPanel =
PANEL.pan_create(null, 1);
sliderPanel.SHOW = true;
sliderPanel.size_x = 300;
sliderPanel.size_y = 100;
// allow mouse interaction
EngVar.mouse_mode = 4;
// create bitmaps, to be used in the slider
BMAP sliderBackground =
BMAP.bmap_createblack(200, 40, 24);
BMAP sliderKnob =
BMAP.bmap_createblack(20, 60, 24);
sliderBackground.bmap_fill(new Color(255, 255, 255), 100);
// the value to be read and modified by the user AND the engine
WrappedDouble wrappedDouble =
new WrappedDouble(50);
// create the slider
sliderPanel.pan_setslider(
0,
50,
50,
sliderBackground,
sliderKnob,
0,
255,
wrappedDouble);
bool keyEnterHasBeenReleased = true;
while (EngFun.engine_frame() != 0)
{
// interaction in the rendering loop
if (EngVar.key_enter == true)
{
if (keyEnterHasBeenReleased == true)
{
EngVar.sky_color.blue += 25;
EngVar.sky_color.blue %= 255;
keyEnterHasBeenReleased = false;
}
}
else
{
keyEnterHasBeenReleased = true;
}
EngVar.sky_color.red = wrappedDouble.Value;
}
EngFun.engine_close();
}
// interaction using EngVar key events
private static void OnSpaceMethod()
{
EngVar.sky_color.green += 25;
EngVar.sky_color.green %= 255;
}
}
public class Player
{
private readonly ENTITY PlayerEntity;
/// <summary>
/// the delegate has to be referenced to, as long as it is used !
/// </summary>
private readonly WrapperDelegateVoid PlayerRoutineDelegate;
public Player(Vector position)
{
// create the entity
this.PlayerEntity =
ENTITY.ent_create("_CUBE.MDL", new Vector(100, 0, 0), null);
// enable triggering of the event function, every frame !
this.PlayerEntity.ENABLE_FRAME = true;
// create and store the delegate
this.PlayerRoutineDelegate =
this.PlayerRoutine;
// assign the event method/delegate
this.PlayerEntity.event_ =
this.PlayerRoutineDelegate;
}
// interaction using on_frame
private void PlayerRoutine()
{
double speedOfPositionChange =
2.5 * EngVar.time_step;
if (EngVar.key_a == true)
{
this.PlayerEntity.y += speedOfPositionChange;
}
if (EngVar.key_d == true)
{
this.PlayerEntity.y -= speedOfPositionChange;
}
if (EngVar.key_w == true)
{
this.PlayerEntity.z += speedOfPositionChange;
}
if (EngVar.key_s == true)
{
this.PlayerEntity.z -= speedOfPositionChange;
}
}
}
}