Stencyl 3.4.0 is now out. Get it now!

Can't draw without crashing game

nikopol

  • Posts: 19
Hi all,

I am writing this Actor Behavior called OpenIventory. Basically, when a key is pressed, it has to draw a rectangle on the screen and draw other stuff.
However, whenever I activate the behaviour and test the game, all my layers (except backgrounds) disappear, and the log viewer shows hundreds of :

Level:     ERROR
When:      2017-03-19 18:49:41:347
From:      stencyl.sw.app.filewatcher.ExternalAppLauncher

[Flash] Universal#uncaughtErrorHandler(59): Error #1034: Type Coercion failed: cannot convert com.stencyl.models.scene.layers::BackgroundLayer@13f772d71 to com.stencyl.models.scene.Layer.

Another thing : my actors are still moving on the tiles... the tiles just become invisible.

I left the code in attachments.
Thanks

« Last Edit: March 19, 2017, 11:44:21 am by nikopol »


VoidShard

  • Posts: 53
I see nothing wrong with the code you've posted. I've run into the issue you're describing, but I never solved it.
Maybe you can post your .stencyl file? If there's nothing wrong at all, you could submit it to bugs.

Maybe you could switch set drawing to scene layer with set drawing to screen layer?

nikopol

  • Posts: 19
I think I found the source of the problem :

When I test my game, it starts with a blank scene that I use to start some music. ( see scene events in attachments )

When I tried to test the 'openInventory' behaviour while not launching the game but only testing a specific scene, without passing by this blank scene, everything worked.

Do you have any idea what's happening ?

nikopol

  • Posts: 19
ALRIGHT !!!

I changed the :  "create hero at (x:90 y:300) at Middle in the next scene"

to :   "create hero at (x:90 y:300) at Front in the next scene"

and now the behaviour works. However, my actor is behind my layers... How does all this Front/Middle/Back work ?

« Last Edit: March 20, 2017, 02:40:41 am by nikopol »

rob1221

  • *
  • Posts: 8908
If your actor is showing under other things it could still be on the same layer.  It really depends on how you're displaying things and the order you're displaying them in.  A sample game would help to determine if there's a bug to be fixed or not.

nikopol

  • Posts: 19
Here is how I think everything is drawn :

Firstly a scene with only one empty layer is created. After one second, this scene changes to a second one and also creates an Actor on the latter. (using "create hero at (x:90 y:300) at Front in the next scene")

The second scene has two background layers positioned 'under' all the layers in the layer list , and 9 other layers.

So the actor appearing in the second scene Is behind all layers except the two background layer, and the first layer called 'Floor + InvisibleWal' ( see layers screenshot in attachment ).

Using "create actor in Front" makes the 'open inventory' behaviour (see attachment) work, but places my actor behind almost all the layers. And if I "create actor in middle", the 'open Inventory' behaviour makes all the layers, except backgrounds, disappear, but the actor Is in front of every layers

What's happening ?

rob1221

  • *
  • Posts: 8908
An error can cause other things to not work as expected so it's not a good comparison until that error is fixed.

VoidShard

  • Posts: 53
Maybe try using the block that lets you define which layer to put the thing on, instead of the front, back, or middle.