Working with clones

Hey everyone! Working is going swell on my first game but I ran into a bit of a problem. I have created a way to spawn an actor directly on top of another. My game uses actors by having the player click on them and then they switch animations based on clicks. The problem I’ve run into is the fact that when I create clone son top of the actors, the click that initiated the clone also clicks the actor that spawns in. I’m using “if clicked on self” to intitiate the cloning but it seems that is also applying to the newly created actor that replaces the already clicked one. I can send multiple pictures if needed. Any and all help would be greatly appreciated :)

Luyren

  • *
  • Posts: 1468
Created a boolean called Initialized.  On your click event, put "If <Initialized>" on top of everything. In an when created event, "do after 0.1 seconds, set Initialized to true." This should work.
Working.

Created a boolean called Initialized.  On your click event, put "If <Initialized>" on top of everything. In an when created event, "do after 0.1 seconds, set Initialized to true." This should work.

I tried this, and it fixed ge problem. But now instead of intitliazing after the first click, the actors are taking a click to “initialize” and then another to switch animations. It’s imperative that the actors switch upon one click. Any further help?

Luyren

  • *
  • Posts: 1468
Post a screen shot of your code, that shouldn't be happening. You might have put the Initialized boolean in the wrong place.
Working.

Post a screen shot of your code, that shouldn't be happening. You might have put the Initialized boolean in the wrong place.

Sure thing, they're below.

These are my screen caps. I have multiple "skulls" that all behave the same way..."if mouse clicks this color then clicks self make clone of another color at your location". I'm guessing the problem comes where the mouse senses that the clone is also clicked, and when I click on another skull (for the first time without any other color clicked before) it results in that skull creating an unwanted skull.


Luyren

  • *
  • Posts: 1468
Just from the screenshots, I think the problem might be with the attribute colorcode, because as far as I can tell, Initialized seems correct. You can check that by putting Initialized and the colorcode check in two different If blocks, on inside the other, and putting a print block after each If statement, to see where it stops after your first click:
If <Initialized>
-Print 1
-If <colodercode=N>
--Print 2

You could also reduce the time it takes to Initialize, from 0.1 to 0.01 or 0.02, but that would only make a difference if you are double-clicking and if Initialized is at fault.
Working.

NickamonPoppytail

  • *
  • Posts: 1019
When creating the clone, try creating it at x of self - 200 or something like that. This way the clone won’t appear directly on top of the original, but 200 pixels to its left. You can experiment with adding and subtracting the x and y positions of the actor to get it in the right position. That way, this shouldn’t cause this error.
046 121 116 105 116 110 101 100 105 032 121 109 032 116 117 111 098 097 032 110 111 105 116 115 101 117 113 032 111 110 032 101 118 097 104 032 100 108 117 111 104 115 032 117 111 089 032 046 084 074 032 101 114 097 032 115 108 097 105 116 105 110 105 032 121 077 032 046 117 111 121 032 107 099 097 116 116 097 032 108 108 105 116 115 032 108 108 105 119 032 073 032 100 110 065 032 046 116 114 105 104 115 032 115 105 104 116 032 103 110 105 114 097 101 119 032 108 108 105 116 115 032 109 097 032 073 032 046 110 111 115 032 115 105 104 032 109 097 032 073 032 046 101 109 032 119 111 110 107 032 121 097 109 032 117 111 089

Just from the screenshots, I think the problem might be with the attribute colorcode, because as far as I can tell, Initialized seems correct. You can check that by putting Initialized and the colorcode check in two different If blocks, on inside the other, and putting a print block after each If statement, to see where it stops after your first click:
If <Initialized>
-Print 1
-If <colodercode=N>
--Print 2

You could also reduce the time it takes to Initialize, from 0.1 to 0.01 or 0.02, but that would only make a difference if you are double-clicking and if Initialized is at fault.

I’ll try this when I get home. Thanks, I’ll let you know what happens!

When creating the clone, try creating it at x of self - 200 or something like that. This way the clone won’t appear directly on top of the original, but 200 pixels to its left. You can experiment with adding and subtracting the x and y positions of the actor to get it in the right position. That way, this shouldn’t cause this error.

This would work perfectly, only I need a skull which is clicked to seem like it is changing colors, thus the clone has to appear in the same exact location.