random spawns of a sprite into a another sprite

Get help using Construct 2

Post » Fri Jul 06, 2012 1:13 am

random spawns of a sprite strictly within another sprite area... ive got some success, but the objects keep spilling into the surrounding layout ..i need them in that particular area

its for a random encounter system that only happens when your in the shadows ..
B
16
S
4
G
4
Posts: 179
Reputation: 4,688

Post » Fri Jul 06, 2012 12:26 pm

you could try spawning them at "scroll.x+(random(-600, 600), scroll.y+(random(-600, 600))"

the numbers completely depend on you window size setting =)
B
42
S
11
G
5
Posts: 446
Reputation: 6,417

Post » Fri Jul 06, 2012 1:18 pm

Here's one way to do it:
SpawnWithinSprite.capx (r98)

I set the image point of the sprite to top-left, then made the random expression spawn between the sprite's position and the position + the width/height of the sprite.Nimtrix2012-07-06 20:21:12
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Fri Jul 06, 2012 1:50 pm

thanks guys, been waiting with baited breathe :) i been up all night trying to figure this out, and learn the right expressions :)

ill give all this a try :)
B
16
S
4
G
4
Posts: 179
Reputation: 4,688

Post » Fri Jul 06, 2012 2:19 pm

oopsrailslave2012-07-06 14:35:14
B
16
S
4
G
4
Posts: 179
Reputation: 4,688

Post » Fri Jul 06, 2012 2:34 pm

https://dl.dropbox.com/u/84483952/phantasy%20star%20style%20part%20%281%29.capx

hmmm dunno if its the scrolling but despite using your commands they still seem to be spawning in the same area...not spread out and over the shadowy sprite
B
16
S
4
G
4
Posts: 179
Reputation: 4,688

Post » Fri Jul 06, 2012 2:58 pm

You have to put the origin image point of the shadow sprite to the top left corner.
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Fri Jul 06, 2012 3:32 pm

thats awesome thanks alot, thats been such a stumbling block to me ...
could you just help me with on more thing...
touching those random blocks (which will be invisible) sends you to a speedrun action section but, on completing that, what would commands would i use to get my guy to start of in exactly the same place he left ?

it would be great if you could show me that ... that would pretty much be the mechanics of my game :)
B
16
S
4
G
4
Posts: 179
Reputation: 4,688

Post » Fri Jul 06, 2012 3:44 pm

Make two global variables, let's call them SaveX and SaveY. When your character hits the block, set variable SaveX to PlayerObject.X and SaveY to PlayerObject.Y. Then you just put an On start of layout event where you place your character at SaveX, SaveY.

This way you save the players position in the variables, then place him at the saved location when returning to the layout.

Edit: I forgot to mention, if you use "on start of layout", you should set the variable's initial values to where you want the player to start.Nimtrix2012-07-06 15:58:24
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Fri Jul 06, 2012 4:28 pm

thanks alot, your a genius, i shall beaver away at this till i get it (and hopefully get the hang on it as well )right
B
16
S
4
G
4
Posts: 179
Reputation: 4,688

Next

Return to How do I....?

Who is online

Users browsing this forum: Baidu [Spider], R0J0hound and 24 guests