after using real values for the finalbits (0 and the IntPtr to the EngineObject) and additionaly adding a wait after loading the level, it seems to work just fine ! I changed the code to use the methods the wrapper uses internally, so less code and additonally it should be faster, because for getting the value, now only the IntPtr is read, not the whole struct !
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AcknexWrapper;
namespace eventExample
{
using AcknexWrapper.Native;
using System.Runtime.InteropServices;
public static class FinalBit
{
private static IntPtr GetPointerToFinalBit(BMAP bitmap)
{
return
(IntPtr)(
(int)bitmap.getIntPtr() +
(int)Marshal.OffsetOf(typeof(NativeBMAP), "finalbits"));
}
public static IntPtr GetValue(BMAP bmap)
{
return
Conversion.getIntPtrFromIntPtr(
FinalBit.GetPointerToFinalBit(bmap));
}
public static void SetValue(BMAP bmap, IntPtr value)
{
Conversion.setIntPtrFromIntPtr(
FinalBit.GetPointerToFinalBit(bmap),
value);
}
}
class Program
{
//the main method, called by the scheduler
private static IEnumerable<ScheduleMethod> myMainMethod()
{
// limit frame rate
EngVar.fps_max = 60;
// load an empty level
EngFun.level_load(null);
yield return 1;
BMAP bla =
BMAP.bmap_createblack(300, 300, 32);
// print current value
Console.WriteLine(FinalBit.GetValue(bla));
// change the finalbit to Zero and storing the current value
IntPtr currentFinalBitValue =
FinalBit.GetValue(bla);
FinalBit.SetValue(bla, IntPtr.Zero);
// print current value
Console.WriteLine(FinalBit.GetValue(bla));
// change the finalbit from Zero to the stored value
FinalBit.SetValue(bla, currentFinalBitValue);
// print current value
Console.WriteLine(FinalBit.GetValue(bla));
yield return ScheduleMethod.wait(1);
}
static void Main(string[] args)
{
//open the engine
EngFun.engine_open(null, null);
//start the scheduler
Scheduler.StartScheduler(myMainMethod);
}
}
}