[Solved] Exlosion via image api dosn't work in one scene

TF101

  • *
  • Posts: 82
Hi,
I downloaded the example file from this post and copied it.

https://community.stencyl.com/index.php/topic,50691.msg280393.html#msg280393

I just adjusted it a bit so that it is now an actor behavior. In a newly created game it works fine. The actors explode as they should. The behavior use the image api.
However, when I add this actor behavior to my current game, it doesn't work!
When I paste it in my play scene it doesn't work. If I create another Scene it works. Damn!
Actors are the same,
collision groups are the same,
physics settings are the same.
Project is cleaned.
But the actor just doesn't explode. He just disappears. So he gets "killed".

It works:
- In a new created game
- In a new created scene of my current game

It doesn't work:
- in the play scene of my current game

I do not understand that. Why does everything work in a newly created game/scene and my current play scene doesn't?!
Does anyone have an idea what else could it be? Where is the difference in the scenes?

Thomas

« Last Edit: September 02, 2022, 09:13:02 am by TF101 »

Justin

  • *
  • Posts: 4689
The test game works fine for me. Does it not work for you?

I'm not sure why it works in one scene but not the other. Perhaps collisions are causing the actors to die in a different behavior in your main play scene?

One thing I noticed is that it seems you're not using the explosion behavior as intended. It shouldn't be attached to the actor that explodes. It should probably only be attached to a single (not exploding) actor in the scene, or it should be a scene behavior. I say this for a couple of reasons.

1. It has cleanup code for deleting images after they've grown small enough. To ensure that this code is run, this behavior shouldn't be attached to an actor that's going to die.

2. It has an event for [ENEMIES] and [BLOCKS] colliding, rather than [self] and [BLOCKS] colliding. Since each copy of this behavior that's currently running has the same event, you only really need one of them.
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

TF101

  • *
  • Posts: 82
I found out that it is due to the height of the scene.

If the scene is larger than the player's view, the actor will only be killed and will not explode.
At least you can't see the explosion...
I created an example image showing this.
I also created an example game where you can see that it doesn't work.
The scene is 120 tiles high and the camera was placed down.
I have no idea how to build this so that it works in oversized scenes.

Maybe someone has an idea what I can do?

Greetings
Thomas

« Last Edit: September 02, 2022, 06:12:37 am by TF101 »

Justin

  • *
  • Posts: 4689
The problem is that the exploded parts of the actor are being attached to the screen, which uses on-screen coordinates. Using on-screen coordinates for this, though, will make it so the images don't move on the screen even if the camera moves. What you probably want to do instead, is attach the images to a layer.

In the collision event, just make the following change:

"attach image to screen" -> "attach image to to layer"

If you want to continue with on-screen coordinates instead, you would make these changes in the "attach image to screen" and "slide image by" blocks:
"x of 1st actor" -> "x (on screen) of 1st actor"
"y of 1st actor" -> "y (on screen) of 1st actor"
"x-center of 1st actor" -> "x (on screen) of 1st actor + half-width of 1st actor"
"y-center of 1st actor" -> "y (on screen) of 1st actor + half-height of 1st actor"
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

TF101

  • *
  • Posts: 82
Hi Justin,
thanks again for you help!
Both of your solutions work!!

I'll add the behavior to it. Maybe someone needs it too

Greetings
Thomas