0 registered members (),
1,459
guests, and 9
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: C# wrapper 2.3.1 - RELEASE
[Re: jenGs]
#379984
08/10/11 19:41
08/10/11 19:41
|
Joined: Dec 2002
Posts: 616 Austria
Stromausfall
OP
User
|
OP
User
Joined: Dec 2002
Posts: 616
Austria
|
there are two types of events : one that uses 'EventHandlers' like EngVar.on_mouse_left, an example for this is shown in one of my previous posts ! the other type only allows one method to be called, for example the Panel.event_ property :
// the method to be called when the panel is clicked
static void PanelEvent(IntPtr p)
{
// get the clicked panel
PANEL thisPanel =
PANEL.createFromPointer(p);
// change the color of the clicked panel
thisPanel.bmap.bmap_fill(new Color(200, 0, 0), 50);
}
// the main method called by the scheduler
private static IEnumerable<ScheduleMethod> MyMainMethod()
{
// create a red panel and make it visible...
PANEL p =
PANEL.pan_create(null, 24);
p.SHOW = true;
p.size_x = 100;
p.size_y = 100;
p.pos_x = 300;
p.pos_y = 300;
p.bmap =
BMAP.bmap_createblack(100, 100, 32);
p.bmap.bmap_fill(new Color(0, 0, 255), 50);
// assign the method to be called when the panel is clicked..
p.event_ =
PanelEvent;
// use the mouse !!
EngVar.mouse_mode = 4;
}
// the entry point of the program
static void Main(string[] args)
{
// load an empty level
EngFun.engine_open(null, null);
EngFun.level_load(null);
// start the scheduler
Scheduler.StartScheduler(MyMainMethod);
}
|
|
|
Re: C# wrapper 2.3.1 - RELEASE
[Re: Stromausfall]
#380288
08/15/11 13:18
08/15/11 13:18
|
Joined: Jul 2010
Posts: 283 Germany
jenGs
Member
|
Member
Joined: Jul 2010
Posts: 283
Germany
|
Hi, I have another question Do I have to write an own inkey function or is it somewhere. I noticed that you are using csharp native strings. So I guess it is difficult to wrap the inkey function? Patrick
|
|
|
Re: C# wrapper 2.3.1 - RELEASE
[Re: jenGs]
#380323
08/15/11 16:36
08/15/11 16:36
|
Joined: Dec 2002
Posts: 616 Austria
Stromausfall
OP
User
|
OP
User
Joined: Dec 2002
Posts: 616
Austria
|
The problem with inkey is that it isn't part of the acknex.dll (from http://www.conitec.net/beta/ainkey.htm) as it uses wait (and thus the lite-c scheduler) ! simulating inkey shouldn't be that hard, I guess the description of inkey in the GameStudio manual offers a reasonable solution : You could use wait and check a variable that contains the value of the last pressed char, for example the engine variable key_lastpressed !
|
|
|
Re: C# wrapper 2.3.1 - RELEASE
[Re: pararealist]
#380516
08/18/11 15:19
08/18/11 15:19
|
Joined: Dec 2002
Posts: 616 Austria
Stromausfall
OP
User
|
OP
User
Joined: Dec 2002
Posts: 616
Austria
|
button_state works for me ! look at the following example, it uses button_state to switch the state of the toggle button ! it uses a toggle button and switches it on/off depending on its current state, using button_state (when space is pressed) ! The state is also changed if you press the button, but remember to move the mouse away from the button to see it's state (because of mouseOver and mouseOverOff)
// here's some sample code
private static PANEL p;
private static IEnumerable<ScheduleMethod> switchStateOfButtonUsingButtonState()
{
// first get old state... -1 means DON'T change state of the button
double oldState =
p.button_state(1, -1);
// then switch the state, according to the return value
if (oldState == 0)
{
// switch to on
p.button_state(1, 1);
}
else
{
// switch to off
p.button_state(1, 0);
}
yield break;
}
public static IEnumerable<ScheduleMethod> myMainMethod()
{
// use mouse !!
EngVar.mouse_mode = 4;
p =
PANEL.pan_create(null, 1);
p.SHOW = true;
p.pos_x = 100;
p.pos_y = 100;
p.size_x = 500;
p.size_y = 500;
BMAP on =
BMAP.bmap_createblack(200, 200, 32);
on.bmap_fill(new Color(0, 255, 0), 50);
BMAP off =
BMAP.bmap_createblack(200, 200, 32);
off.bmap_fill(new Color(0, 0, 255), 50);
BMAP over =
BMAP.bmap_createblack(200, 200, 32);
over.bmap_fill(new Color(200, 200, 20), 50);
p.pan_setbutton(
0,
2,
50,
50,
on,
off,
over,
over,
null,
null,
null);
EngVar.on_space +=
switchStateOfButtonUsingButtonState;
yield break;
}
static void Main(string[] args)
{
EngFun.engine_open(null, null);
EngFun.level_load(null);
Scheduler.StartScheduler(myMainMethod);
}
|
|
|
Re: C# wrapper 2.3.1 - RELEASE
[Re: pararealist]
#380615
08/19/11 18:13
08/19/11 18:13
|
Joined: Dec 2008
Posts: 1,218 Germany
Rackscha
Serious User
|
Serious User
Joined: Dec 2008
Posts: 1,218
Germany
|
tried to use it the firts time(copied helloworld example).
It crashes instantly in engine_open when calling NativeEngFun.engine_open
BatImageFormatException
Greets Rackscha
MY Website with news of my projects: (for example my current Muliplayer Bomberman, GenesisPrecompiler for LiteC and TileMaster, an easy to use Tile editor) Sparetime-Development
|
|
|
Re: C# wrapper 2.3.1 - RELEASE
[Re: Rackscha]
#380617
08/19/11 18:45
08/19/11 18:45
|
Joined: Dec 2008
Posts: 1,218 Germany
Rackscha
Serious User
|
Serious User
Joined: Dec 2008
Posts: 1,218
Germany
|
Damn it, express compiled an x64 assembly. Had to change platform target manually in projectfile >.<
MY Website with news of my projects: (for example my current Muliplayer Bomberman, GenesisPrecompiler for LiteC and TileMaster, an easy to use Tile editor) Sparetime-Development
|
|
|
Re: C# wrapper 2.3.3 - RELEASE
[Re: Stromausfall]
#381039
08/23/11 15:07
08/23/11 15:07
|
Joined: Dec 2008
Posts: 1,218 Germany
Rackscha
Serious User
|
Serious User
Joined: Dec 2008
Posts: 1,218
Germany
|
eh...your wrapper is using SHOW for entities. But isnt the correct flag VISIBLE ?
MY Website with news of my projects: (for example my current Muliplayer Bomberman, GenesisPrecompiler for LiteC and TileMaster, an easy to use Tile editor) Sparetime-Development
|
|
|
|