How do I drop and check sprite when is in right place

Get help using Construct 2

Post » Tue May 30, 2017 7:24 am

Hi, on project i have SpritesA and SpritesB

SpritesB have own instance variable 'Var'
Halo of spritesB have this var =1

You shuld drop spritesA on sprites B with var=1

when you find all right places to drop game is finished

can someone help me with this case?

CAPX fo help
https://www.dropbox.com/s/mm07s8uc973sf ... .capx?dl=0
B
25
S
8
Posts: 219
Reputation: 2,181

Post » Tue May 30, 2017 8:08 am

B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Tue May 30, 2017 4:40 pm

99Instances2Go wrote:https://www.dropbox.com/s/oh0tb2l5nsufbgc/placeIt%26faceIt.capx?dl=0



great example
hard to understand because its very advanced coding

can you modify this cap to version without random choose (t0tal) at start?
i need set this manually
B
25
S
8
Posts: 219
Reputation: 2,181

Post » Mon Jul 03, 2017 9:52 pm

99Instances2Go wrote:https://www.dropbox.com/s/oh0tb2l5nsufbgc/placeIt%26faceIt.capx?dl=0


hello im back with other question
How can i reset position of sprites and his variables to start again via events?
B
25
S
8
Posts: 219
Reputation: 2,181

Post » Mon Jul 03, 2017 10:11 pm

Depends on the needs.

Restart layout
Restart the current layout. Note that unlike Go to layout, this action resets all event groups to their initial activation state. Global variables keep their current value - they are not reset. To reset them use the system action Reset global variables.

Recreate initial objects
Recreate the objects in a rectangular area of the layout as they appear in the Layout View. In other words, this restores a section of the initial level design. Note that this does not destroy any existing objects, so if used repeatedly will create multiple objects sitting on top of each other. Only objects of the given type are created, or alternatively a family can be passed and all objects belonging to that family are recreated.

Reset global variables
Reset all the global variables in the project to their initial value.

Reset persisted objects
Across the entire project, reset all objects using the Persist behavior to their initial state (as if the layout has not been visited yet). This is useful when restarting a new game from the beginning again.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Mon Jul 03, 2017 11:16 pm

i should not restart layout

what you mean recreate object?
i think on layout should be a button and when i click all object back on start position and should be ready to place all again

i dont use persist

thanks

99Instances2Go wrote:Depends on the needs.

Restart layout
Restart the current layout. Note that unlike Go to layout, this action resets all event groups to their initial activation state. Global variables keep their current value - they are not reset. To reset them use the system action Reset global variables.

Recreate initial objects
Recreate the objects in a rectangular area of the layout as they appear in the Layout View. In other words, this restores a section of the initial level design. Note that this does not destroy any existing objects, so if used repeatedly will create multiple objects sitting on top of each other. Only objects of the given type are created, or alternatively a family can be passed and all objects belonging to that family are recreated.

Reset global variables
Reset all the global variables in the project to their initial value.

Reset persisted objects
Across the entire project, reset all objects using the Persist behavior to their initial state (as if the layout has not been visited yet). This is useful when restarting a new game from the beginning again.
B
25
S
8
Posts: 219
Reputation: 2,181

Post » Tue Jul 04, 2017 1:58 am

You could do this:

global number placed=0

spriteA: on drop
spriteB: var = 1
spriteA: is overlapping SpriteB
SpriteB: pick closest to (spriteA.x, spriteA.y)
--- spriteA: set position to spriteB
--- spriteB: set var to 0
--- add 1 to placed
--- spriteA: disable dragndrop

placed = spriteA.count
--- wait 1 second
--- restart layout
B
94
S
33
G
117
Posts: 5,387
Reputation: 75,335

Post » Tue Jul 04, 2017 5:09 pm

But all should be reseted without restarting all level (because other sprites are in level too, position of player/ killed enemies)

R0J0hound wrote:You could do this:

placed = spriteA.count
--- wait 1 second
--- restart layout
B
25
S
8
Posts: 219
Reputation: 2,181

Post » Tue Jul 04, 2017 6:02 pm

Fiddle with 99's other ideas then.

The most manual way would be to add additional variables that have the original position and variable values in them. Then to reset you set set the positions and variables from that.
B
94
S
33
G
117
Posts: 5,387
Reputation: 75,335

Post » Tue Jul 04, 2017 10:21 pm

Well i dont understand the question. I have no idea what you exactly want.

I notice a question (from 30 may) that implies that nothing is placed on run time. I assume this is still true, that everything is set up in the layout. I have no idea if there are objects destroyed and/or created. How can i, you dont share a .capx ?

So lets walk trough a few scenarios.

1/ You want to go back to the basic set up, but want to keep global variables as score ...etc. Use 'Restart layout'.

2/ You want to go back to the basic set up, and reset the global variables. Use 'Restart layout' + 'Reset global variables'

3/ Things get created and placed in a random way on layout startup. And you want to go back to to exact the same set up. Assuming that later on objects are created that dont belong to the basic setup. Give each object a instance text variable 'backup' and a instance boolean 'base'. Set base to true for the objects that you randomly create in the setup. Set 'backup' to self.AsJSON during the creation of the setup.

When you want to go back to the randomly created setup .... loop trough all objects. If 'base' = false then destroy that object, else use 'Set from JSON' to 'backup'.

Option 1 should be enough though. Explain why it is not what you need ?
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests