duplicating or copying an actor

liefkeesliefkees Member Posts: 11
edited April 2012 in Working with GS (Mac)
Hi,

I hope you guys can help me with this problem:

I am making a scene in which you have to pick up an item(actor) and drag it to a different spot. However, I don't want the original actor to disappear when it is being dragged to a different place, I want to copy the actor so the original actor stays in place. This way the user can grab as many items as he likes, as if there is an endless pile of them.

First I tried to do exactly that: I placed a huge number of actors on top of each other. This didn't work as they then all behaved as one actor.

I then tried the 'replicate' behavior, which didn't work either.

What seemed to work is the 'spawn' behavior. I gave my actor this rule:

When actor receives event touch is pressed
constrain attribute
spawn actor
layer order in back of actor (I tried different orders here)
direction 0 relative to actor (as I do not want the spawned actor to appear in a different location as the original actor)
position 0 relative to actor (same reason)


This seems to work as a new actor is created when you touch the item and drag it. However, the new actor doesn't appear in the exact spot as the former actor. It seems to just jump to a place, without any logic. Sometimes it appears a few millimeters higher, sometimes a bit to the right, but never in the exact same spot as where the old actor was.

As I am starting to get a bit desperate, I hope someone can help me out!

Thanks,

Maaike

Best Answer

Answers

  • youngster9youngster9 Member Posts: 326
    What you could try is to create another actor and place that one as the bottom actor and set this actor to cannot move by unchecking the movable boolean. Then create the same rule on this actor saying when the new actor is tapped spawn the actor you want and then this actor is constrained to the x and y of the touch. The new actor should be the same image as the actor to be spawned. This should work. I will create a demo if you didn't understand this.
  • liefkeesliefkees Member Posts: 11
    Thanks, you made my day! Works like a charm...

    Maaike
Sign In or Register to comment.