Layers, functions and Z-order

For questions about using Classic.

Post » Mon Aug 13, 2012 3:32 pm

Hi, i have a problem with my game. I'll try to explain as my best, i'm french.

I have in my game a main layout "stage", where i include an event sheet "character". In this event sheet, i include an another one called "spells".

In the layout "stage" i have 4 layers : "couche 1", "couche 2", "couche 3" and "HUD". With this, i'll be able to manage Z order easier.


Now, in the event sheet "spells" :

I use functions to cast spells. I have for now 2 functions.

1- The first one after some effects, put a variable to 1, and outside the function, when this variable is egal to 1, an object is created at layer "couche 2"

2- The second one, create an other object in the function at layer "couche2".

The 1- works, but the 2- doesn't work. The debug says "layer "couche 2" doesn't exist".

What can I do to correct this please ? Tell me if you want more details.

Thanks a lot !
B
10
S
1
G
1
Posts: 31
Reputation: 1,006

Post » Mon Aug 13, 2012 4:51 pm

Can you upload your CAP file so we can test it?
B
6
Posts: 27
Reputation: 404

Post » Tue Aug 14, 2012 2:51 pm

Hi and thanks.

Here is the link : -Deleted-

Here, the global variable "classe" is "mage". Try with this, and press the button 1 (with your keyboard) then click.

Try also by changing the global variable "classe" to "combattant". Try with this and press button 1 (with mouse on the game).
Martifou2012-09-05 19:31:59
B
10
S
1
G
1
Posts: 31
Reputation: 1,006

Post » Wed Aug 15, 2012 3:48 am

Nothing happens when I press 1 on the keyboard. It seems that pressing 1 should cause spell 1 to be cast, but for that to happen, the private variable 'cible' has to be either "oui" or "non." I ran your game in debug mode, and I saw that 'cible' was blank. Was there supposed to be an event that would set 'cible' to "oui" or "non"?

Looks like you've already done a lot of work on your game. It's getting hard to debug, so I suggest that you debug everything first before you add more events.

I do have a couple of suggestions at this point.

First, you should make your background image a Tiled Background instead of a Sprite. Tiled Backgrounds use up less memory and do not require the features of a Sprite.

Second, if you need a variable like 'cible' that stores only "oui" or "non," consider making it numeric and store the numbers 1 for "oui" and 0 for "non." Your game will use up less computing resources that way.Elyzius2012-08-15 03:50:32
B
6
Posts: 27
Reputation: 404

Post » Thu Aug 16, 2012 9:47 am

Hi, and thanks for the answer.

Did you press 1 in your NumPad ? Because this is not that. This is the 1 at the top of the keybaord (near F1, F2, etc...). And when I press 1, this is working.

Look at the "sorts" event sheet at the beginning, Start of Layout > i read an INI file and store values in private variables.

I replaced the "oui"/"non" by 1 and 0.

But, for the Tiled Background, i put a sprite, solid, then i erased path at the collision mask of this sprite, so the character can walk in. But with a Tiled Background, it works also. However, I can't put an event like "On collision with TiledBackground".

Thanks a lot for your help.
B
10
S
1
G
1
Posts: 31
Reputation: 1,006

Post » Thu Aug 16, 2012 3:25 pm

Hi, after long and long research, i found a solution : The "Layout" object is a problem ! It causes problem everywhere. So i used Inherited Layer and it's fine !

Thanks for your help ! If you have others ideas about optimization, please tell me ! :)
B
10
S
1
G
1
Posts: 31
Reputation: 1,006


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 7 guests