Clone object in code

Get help using Construct 2

Post » Sun Oct 13, 2013 7:31 am


I would like to know if a feature allowing to clone a sprite directly in code was available.

Or if creating an object with a dynamic name has been introduced.

I already read from here :
It's not possible but this post is from last year.
Have things evolved ?

And I also know the trick with creating an sprite containing many different frame but I'm not a fan of this work around.

Any advices ?

ThanksDaedolon2013-10-13 07:52:34
Posts: 67
Reputation: 690

Post » Sun Oct 13, 2013 8:34 am

You can create sprites during runtime. What is the added benefit of cloning?

If you'd just like to name the sprite, give it an instance variable name and set it to the name you want so you can call it directly from your eventsheet.

I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
Posts: 6,160
Reputation: 19,775

Post » Sun Oct 13, 2013 9:16 am

I've not been clear enough.

I'm creating a platform game where the player can visit towns and enter shops to buy items.
When he enters a building, the interior of the shop appear and the items are displayed. Those items are already in the layout.

Now my aim is this :
When the player collided with an item, he can click a button to buy it. When bought, a copy of this item appear near the player.
The problem is there are many different items and I would like to avoid to create one line of code for each one of them to create a copy of the item purchased.

Is there a way to clone an object from the layout during an event ?Daedolon2013-10-13 09:17:16
Posts: 67
Reputation: 690

Return to How do I....?

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 8 guests