[SOLVED] How to select clones of an object on a specific layer?

I want to change the opacity of a cloned sprite but only the clone of the sprite on the specific Z-Axis. How would I do so? Also, how would I delete it when it gets to a specific opacity? Also, I want the cloned objects to stop moving once they are created.

What are you after here - objects on a layer (as per title), or at a point on the z-axis?

To stop clones will depend on how you are moving them. Provide a screenshot of the events that move the original object and we may be able to help.

Oops - fell asleep. Here is a screenshot of the code:


Basically, if the player touches another object, which borders around the screen, it activates game over. Essentially you can’t touch the walls. You are always moving at a slowly-increasing angle and speed. When you press space, you turn around.

I want to continuously make a copy of the player sprite on z-axis 1 instead of 2(where the original sprite is). When a player starts as a clone, It changes opacity by 10 every 0.5 seconds, and when it reaches 100 opacity, the clone gets deleted. However, I’m not sure how to delete all instances of an object on a specific Z-axis, and I’m not sure how to only delete clones with a specific opacity level.

I can’t see the events where you create the clone or change the opacity over time. So either it’s in some events that aren’t in the screen shot, or you still have to add them.

Either way, to remove the Player objects of a particluar opacity use an opacity tween behaviour (no need to worry about what the z-order is with this solution):

  • Add the tween behaviour to your Player object
  • Then add an opacity tween, and set “Destroy this object on tween finishes” to true

To stop your clones from moving, add the condition “Player z-order = 2” to every event that moves your player.

wow, thanks for responding! So just to be clear, to stop my clones from moving, I would change from the first bit of code to the second?

Yes. And for each event that moves or changes the angle of the player object.

Okay thanks so much!

Okay, I’m so sorry I’m bombarding you with so many questions, but I can’t figure this out. So I created a custom collision setup for the edge of the screen, however it doesn’t work as intended. Whenever the player is about 70 pixels away from the screen edge, it still triggers game over… And it’s even worse when I add a clone, for some reason that causes it to trigger game over after about 10 pixels of movement. Also, the clone isn’t the resized version of the player sprite so it’s about 20 times bigger.

would it be helpful if I were to upload the game onto itch.io or something?’
if so, Tap Bounce by HypnoticOcelot is the link.

Firstly, I’d seriously consider creating a new object called PlayerClone (with the same image as your player), and use that when you create the fading player clone. It’ll save a lot of headaches and pain that you’ll otherwise encounter as you continue with your game development. All you’d have to do is create a PlayerClone object with the fading tween. No need for for remembering the z-orders checks.

If you try this path first, then we’ll see how things are going. I suspect the cloning is probably a big part of the problem.

Alright, I’ll try that! Thanks

Honestly, without you I would probably never gotten this close to completing my game. I just have one more problem. I set the playerclone to tween to 255 opacity but it isn’t changing opacity at all… It’s just cloning the player sprite and staying there.(Also, I still have that collision problem, do you know anything that might be the cause?)

Make it tween to a lower opacity number, as default opacity is usually 255. I think 100 will be similar to what you had with your increments of 10 every 0.5 seconds.

And make sure you have the “Destroy object when tween finishes” set to true.

As for the collision, post a screen shot of your collision events. We’ll see if anything untoward can be spotted.

sorry for the late response, here is my collision setup:
Snip20210409_18


Since all the walls are 10 pixels wide, I have different quadrilaterals for each wall.
Here is the code:

That’s a strange way of doing the collision. I suggest you use the wall objects for collision instead.

Also, check the collision shape for your Player and wall objects, and make sure they fit snugly round the image.

Don’t worry about that. I suspect we’re in different time zones. Delays between messages are inevitable.

Oh! I think I forgot to setup the collision for the player object! I’ll set it up and let you know how it goes.

The hitbox for the player was the problem, thanks! However, I’m still not sure why the tween isn’t working.


This is my code for the cloning of PlayerClone, as well as the movement of Player. Everything works great except for the tweening…
This is my code for the tweening:

And this is what happens:

Look in your screenshots.
The answer is right there in red.

Tweens need the tween behaviour attached.