How do I Create object in random place but not a solid oboje

Get help using Construct 2

Post » Wed Dec 17, 2014 1:08 pm

Message: maordany is not yet permitted to post plain text URLS (300 rep required). 1 URLS removed. Why?
How do I Create object in random place but not a solid obojets??

In the past I asked a similar question.


But now this solution is not good for me because I have a large number of solid objects in different names.

Is it possible to create a new layer and set that you can not create a new object on layer1 if there is an object at the same location on the second layer??? or something like that.
B
13
S
2
Posts: 95
Reputation: 861

Post » Wed Dec 17, 2014 3:56 pm

maordany easy try this demo
You do not have the required permissions to view the files attached to this post.
B
256
S
39
G
15
Posts: 1,982
Reputation: 41,032

Post » Thu Dec 18, 2014 10:16 am

Lordshiva1948 wrote:maordany easy try this demo


I'm afraid I did not understand what you did or I did not explain myself right.

1. I have a map with a lot of solid objects.
2. I need to create enemies in a random place on the map (But not on a solid object).

i use this code on Set Position :

X = random(ViewportLeft(0)+Box.Width/2, ViewportRight(0)-Box.Width/2)
Y = random(ViewportTop(0)+Box.Height/2, ViewportBottom(0)-Box.Height/2)

the "Box" is the solid object and it works well but my problem now is, i have many solid objects with different names and I can not use the previous code because he knows how to work only with object called "Box". and I have to work with an objects called Box01, Box02, Box03 and more.....
B
13
S
2
Posts: 95
Reputation: 861

Post » Thu Dec 18, 2014 4:16 pm

..add Box1, Box02, Box03 and more..... in Family"Solid"...
.add boolean instanceVar for enemy"overlap"

Enemy Set Position :
X = random(ViewportLeft(0)..
Y = random(ViewportTop(0...
set "overlap" to True..

Enemy is overlapping "Solid"
Is " overlap"............................. set position to ..Solid-Solid/2

Enemy is NOT overplapping "Solid" ..set "overlap" to False..


maybe.. just maybe... this can work well for you :?
(evidently...can not test this..)
B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072


Return to How do I....?

Who is online

Users browsing this forum: gameba and 25 guests