I have an error when using the mode7 module.

Started by FanOfHumor, Sun 03/04/2022 00:38:17

Previous topic - Next topic

FanOfHumor

When I heard about this module I started a new game to just try it out and I can't figure out why I get this error((Failed to save room room1.crm; details below
room1.asc(5): Error (line 5): must have an instance of the struct to access a non-static member)).I have the module imported and no matter what of those commands I type I always get the same error.What am I missing?
Code: ags

function room_AfterFadeIn()
{
	Mode7.SetGroundSprite(3);
}

eri0o

Hey, feel free to ask in the module topic itself! I have notifications set for my modules so messaging in these topics send me an email!

I need to create better room examples, I am sorry for that, I didn't had the time to do that yet.

The problem is that the structs from this module has non static methods, meaning you must instantiate the struct to use it!

So you need to do the below in either room or global context (outside of a function):

Code: ags
Mode7 myM7;


And then later you can use this instance

Code: ags
void room_Load()
{
  myM7.SetGroundSprite(3);
}

FanOfHumor

#2
Ok sorry for not posting there.I did what you said and now I have another error.((mode7.asc(198): Error (line 198): wrong number of parameters in call to 'DrawingSurface::DrawImage')).And then it shows a line of the module.((          t_x, t_z, t_w, 1);Now what am I doing wrong?

Code: ags

Mode7 test;
function room_AfterFadeIn()
{
	test.SetGroundSprite(3);
}


eri0o

erh the code is not much production ready yet, it probably needs some safeguards. I am not sure yet why you are getting this error... I am not sure why that is happening. Do you have more code somewhere?

The code you have should not call anything yet.
https://github.com/ericoporto/mode7/blob/main/mode7_demo/Mode7.asc#L282-L288

FanOfHumor

No there's no other code.This is the first thing I did.

SMF spam blocked by CleanTalk