random spawns of a sprite into a another sprite

  • 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 ..

  • 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 =)

  • 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.

  • 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 :)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • oops

  • 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

  • You have to put the origin image point of the shadow sprite to the top left corner.

  • 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 :)

  • 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.

  • 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

  • could you do a capx of that?, running into some difficulty

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

    i didnt know if the global variables were numbers or ...

  • Sure, here you go:

    railslaves_game.capx (r98)

    <font size="1">Edit: Link removed to avoid confusion, reposted below</font>

  • ok sprite 1 (for example) spawns at a certain rate ....but when you touch sprite 2 you "level up" and that changes the rate at which sprite 1 one spawns (slower rate ).... how could i do this ...?

  • If you set your sprite to spawn every second, you can just multiply that with the level. For example Every (1 * Level) seconds. Here's a quick example to illustrate:

    DecreasingSpawntime.capx (r98)

  • thanks again, that is great, i did work out a rather cruder way of doing it ... but great to see it so simple in a few lines, awesome seems to all be about the *

    i have another big problem ... in a new game mechanic you have to collect things (office workers !?)...but after you go into the random events (speedruns) the things you have collected reappear :P even though i have set them to destroy upon collection heres a capx...

    dl.dropbox.com/u/84483952/try%20this%20one%20game%20demo.capx

    oh space is now the button to get out the run sections

    appriciate all the help , learning from all this

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)