Sprite that disappears and reappears randomly

0 favourites
From the Asset Store
A set of 10 pixel art animated magic effects with icons. 2 Fire, 2 Earth, 2 Wind, 2 Water, Portal, Explosion.
  • I want to make a sprite disappear and reappear multiple times in completely in-boarder areas across the screen, anyone can help with this? <img src="smileys/smiley11.gif" border="0" align="middle" />

  • Add hiddin sprites on the potential locations you want the image to appear. Lets call them spawners. The object to appear, objectX.

    Have an event run every X seconds as desired, and use it to destroy and spawn a new objectX.

    event: every 2 seconds - action: destroy objectX

    subevent to every 2 seconds:

    event: system, pick random spawners - action: object spawners spawn objectX at image point 0.

    Every 2 seconds the objectX gets deestroyed and spawned on a new random picked spawn point.

  • Is this any good to you ?

  • Hey I understood the second part very well but I couldn't quite understand the first part could you elaborate to me by any chance? Thanks

  • <img src="https://dl.dropboxusercontent.com/u/143636437/examples%20for%20web/Ashampoo_Snap_2014.02.14_08h27m49s_002.png" border="0" />

    for example

    I call a function with a set of x and y coordinates (0,10,45,67) (upper left x,upper left y, lower right x, lower right y) would be a rectangle with (0,10) as upper left and (45,67) as lower right.

    these are sent as "0?10?45?67"

    in the function ("fcCreateSpriteInArea") I find the x and y positions using "tokenat"

    (from the manual - "tokenat(src, index, separator)

    Return the Nth token from src, splitting the string by separator. For example, tokenat("apples|oranges|bananas", 1, "|") returns oranges.")

    so now all I need to do is create sprite at (random (x1,x1)),random(y1,y2)

    I also called the function with choose("0?0?540?100","540?0?640?380","0?100?100?380","0?380?640?480")

    so the choose just picks 1 of the 4 rectangle coordinates I want to create a sprite in

    I also used fade to make the sprites fade in pause and fade out (to destroy)

    Clear as mud ? <img src="smileys/smiley1.gif" border="0" align="middle" />

    any questions please use RamPackWobble as I will get a message to reply

    Good luck

  • RamPackWobble Hey man, thanks a lot of going through the trouble of explaining all of this to me, I`m new to this whole construct scene and ive really been enjoying learning and everything but im still having some trouble understanding everything, when you say lvRectangleXandY what is that exactly, is that in itself a function, i find it easier to teach myself, if you could send me the capx it would be great, Thanks!

  • The capx is the one in my first post in this thread.

    edit (caps to capx - stupid auto correct !)

  • oh, the this, aiight thanks a lot

  • lvRectangleX&Y is just a local variable to store the choose in.

    & I've only just realised that when you asked, "Hey I understood the second part very well but I couldn't quite understand the first part could you elaborate to me by any chance? Thanks." you were not talking to me then ? <img src="smileys/smiley9.gif" border="0" align="middle" />

  • RamPackWobble

    That's how I would do it

    randomAreaOfSpawn.capx

    This way you don't need to maintain a cumbersome list of strings of bounding boxes

  • Thank you for the capx - it is certainly more elegant than mine.

    My line of thought was trying to avoid having extra sprites on the screen - I was under the impression that if you could avoid using things like hidden spawner sprites, and do it in the code, then that would be a good thing ? Then again I am also sure that having half a dozen hidden sprites will make very little difference to the speed of the game...

  • Try Construct 3

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

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

    If you set their visibility to invisible, they won't impact rendering.

    However, if you really want to reduce the number of object, you can run a loop on start of layout and build an Array of bounding boxes value to randomly pick from.

    And destroy the sprites afterward.

  • Yann

    Thank you for that - I am pleased to have been wrong (again) because I rather liked using sprites as zones/spawners.

    Just to prove my stupidity ( in case you had any doubts ?) I was just making them with an alpha (or just giving them an opacity of zero) but leaving them visible (which I know does give the GPU a hit) rather than setting them to invisible!

    I swear I learn something new nearly every day about C2 (I just wish I remembered it all) - best �70 spent on a computer program ever!

  • yan Thanks a lot, both of you are the kind of people that are making construct thrive even more! RamPackWobble Nope! & well said! <img src="smileys/smiley20.gif" border="0" align="middle" />

  • RamPackWobble

    That's how I would do itThis way you don't need to maintain a cumbersome list of strings of bounding boxes

    Hello, Yann ! I'm not on the topic, just didn't know how else could find in a private message me not to write ( Just think if you don't know, nobody knows =) because you decided to write. Please tell me, is there any way to do something, so the browser does not block pop-out window, moving from the game by reference. how to solve this problem, not only touching your browser settings ! can this be solved, without changing your browser settings ?

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