How do I Delete all instances even on different layouts

Get help using Construct 2

Post » Fri Sep 11, 2015 12:57 am

If I press a button to create a new Object (sprite) on layout 1 then move on to layout 2, How would I have a button destroy the instance I created on Layout 1 so that when I go back it's no longer there.

Thanks for any advice

*edit* btw, I'm using persistent sprites that i want to choose if they are onscreen on layout 1 or 2 but not both at the same time. thanks
B
16
S
4
Posts: 50
Reputation: 1,035

Post » Fri Sep 11, 2015 11:09 pm

I don't think you can.

Maybe destroy the object on exiting laytout 1 and recreate it later as needed?
https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,418
Reputation: 4,830

Post » Sat Sep 12, 2015 12:45 am

Wen you leave a layout, everything is destroyed unless it is given the Global property.
B
56
S
15
G
13
Posts: 826
Reputation: 17,665

Post » Sat Sep 12, 2015 12:54 pm

Tekniko wrote:Wen you leave a layout, everything is destroyed unless it is given the Global property.


The character is persistent and stays on the layer you drag him out / away from the 'bottom bar' a variable says he's out and lets him stay in that layout when leaving and returning

gumshoe2029 wrote:I don't think you can.

Maybe destroy the object on exiting laytout 1 and recreate it later as needed?


Would these need code for every layout to save a position of a character if the variable for it says it's out (up from the menu bar)

I'll share this link so you can see what's going on so far:

http://www.jmkit.com/html5/testproject/index.html

Things to bare in mind:
- You can click and drag the character out to one place (say blue) - leave and he's still out, go back to blue and is in the position you put him...

you can then drag him back to the bottom where he'll pop down and stay there through all the layouts.

every button goes to a new layout

However, the problem comes when say you drag him out in the blue place - then go to the green place and click the outline to bring him back down, then immediately drag him out to the green place he'll be in both the green and blue place :o (that goes for any variation on place to place, you can get him out in all 3 layouts with that method)

The resetting him from a layout he's not on seems like the only issue i'm having.

Thanks for your replies so far!

check out how i'm doing it code wise here: https://www.dropbox.com/s/6w3hkgdfmlf7e ... .capx?dl=0
B
16
S
4
Posts: 50
Reputation: 1,035

Post » Sat Sep 12, 2015 3:31 pm

JMKit wrote:
gumshoe2029 wrote:I don't think you can.

Maybe destroy the object on exiting laytout 1 and recreate it later as needed?


Would these need code for every layout to save a position of a character if the variable for it says it's out (up from the menu bar)


Depending on how advanced your game is going to get this advice may or may not apply:

Honestly, if all that you are changing is background colors, you should just use different layers for backgrounds and keep it all on one layout. Then just toggle layer visibility to change the background color using the buttons. That way you won't have to track every sprites positions in a global object (like Array or Hash) and repopulate them every layout swap.

If you MUST have multiple layouts, I would try making your little rabbit sprite global first. If that doesn't work, then you get to use an array/hash object and track all of the positions on screen of every object that you want to exist on multiple layouts and repopulate the screen each time you change layouts.
https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,418
Reputation: 4,830

Post » Sat Sep 12, 2015 4:21 pm

Can you post a capx or video of the issue in question? This is obviously in need of a more in depth analysis.
B
56
S
15
G
13
Posts: 826
Reputation: 17,665

Post » Sat Sep 12, 2015 7:03 pm

gumshoe2029 wrote:If you MUST have multiple layouts, I would try making your little rabbit sprite global first. If that doesn't work, then you get to use an array/hash object and track all of the positions on screen of every object that you want to exist on multiple layouts and repopulate the screen each time you change layouts.

lol yes I MUST! this is just a small isolated element of the overall project, separated so I could focus on it specifically, but ultimately I'm re-creating a game I made in flash ( http://www.jmkit.com/playsets/ ) while also adding new features that Construct will allow, and If you see the video posted below, you'll see its so close to how I'd like it to be it's just one element that seems like a tiny variable / iid or something away from perfect..

Tekniko wrote:Can you post a capx or video of the issue in question? This is obviously in need of a more in depth analysis.

I did include the capx in al link in my previous reply, but it'll be clearer with a video (I show the code to the right and a debug view of the variables etc)
VIDEO: https://www.youtube.com/watch?v=9rTjW0ILICk
B
16
S
4
Posts: 50
Reputation: 1,035

Post » Sat Sep 12, 2015 8:43 pm

Watching the video helped. I am assuming you will be adding more stuff to those layouts. If that's true then I would I would suggest you follow this logic.

On end of layout set player.x and player.y to two variables called playerPositionX and playerPositionY.
On Start of new layout set player.x and player.y to their respective variables.
B
56
S
15
G
13
Posts: 826
Reputation: 17,665

Post » Sun Sep 13, 2015 1:31 am

Tekniko wrote:On end of layout set player.x and player.y to two variables called playerPositionX and playerPositionY. On Start of new layout set player.x and player.y to their respective variables.


Seems like that would always have him on screen though, when what i want is that he's only on (when dragged out) one layout at a time - visualise a dolls house with a box of toys, going from room to room with the box, you place a toy from the box into a room, move to the next room, the toy isn't in that room, or the box... That much I can achieve with what I have right now..

The difference between digital and real life though is that (and this sounds theoretically possible and is what i'm attempting) to find that toy again in the real world, you'd have to look back through all the rooms, to pick it up and put it back in the box, in digital I'd like to not have to go looking for it, but click the placeholder to have it pop back into the 'box' ready for use again without being duplicated in a weird way lol
B
16
S
4
Posts: 50
Reputation: 1,035

Post » Sun Sep 13, 2015 10:24 am

is this what you tried to achieve?
if so the answer was half way there ... i just moved some actions you did on the button press
you can also create a function and instead of duplicating all those actions just add 1 action to trigger 1 function then call the function when u want... and will do exactly what i did there

https://mega.nz/#!wQM0mKKR!Hr0O0-zPx8C3 ... p3FSH9uRjo

not sure if u want him to be present on the other sides also...
B
78
S
23
G
69
Posts: 1,353
Reputation: 43,985

Next

Return to How do I....?

Who is online

Users browsing this forum: Blendi1223, jatin1726, Kyatric and 24 guests