problem with spawn/recycling character back to position

digitalzerodigitalzero Member, BASIC Posts: 639
edited May 2012 in Working with GS (Mac)
okay so I'm starting to kinda get the hang of the whole recycling an actor behavior thing-a-ma-jig so let me tell you all what I'm having trouble with... there are six characters that you can choose from in my game... and there are power ups that would "destroy" the character... which works out perfectly fine.. but the problem is that my character is not coming back on the screen :(... i know, bummer right... but here are the rules that i have placed... hopefully someone can tell me what I'm doing wrong

if actor overlaps or collides with actor of type "power ups"

Change Attribute self.position.x to 600 (which would be off the screen for my game)

then i have a timer set **after 5 seconds (which is when the power up will be done) change attribute self.position.x to 240 change attribute self.position.y to 320

now you might ask... well, of course its not going to show up because it would be off the screen... but my characters all have gravity attached to them and i want the character to spawn right in the middle of the screen basically looking like the character is flying down from above... can anyone help me with this?

Answers

  • JustMe74JustMe74 Member, PRO Posts: 542
    Make the scene a little taller than the camera and put all of the actors on top, off camera... then Interpolate them to where you want them as needed.
  • digitalzerodigitalzero Member, BASIC Posts: 639
    But the main player starts the scene though.. So I wouldn't be calling on the actor I would just be hiding it and then having it come back when the special move is over... My problem is the main actor .. Not so much the special move spawning
  • MotherHooseMotherHoose Member Posts: 2,456
    gameAttribute … boolean type … powerUpActive

    on playerActor:
    Rule: when
    Attribute: game.powerUpActive is false
    -changeAttribute: self.Position.X To: whatever is correct onScene X
    -changeAttribute: self.Position.Y To: whatever is correct onScene Y
    Otherwise:
    -changeAttribute: self.Position.X To: whatever is correct offScene X
    -changeAttribute: self.Position.Y To: whatever is correct offScene Y

    on powerUp: … you want lots of the rules here so player has less to process

    add selfAttribute: myTimer … real type

    Rule: when
    Event: overlaps or collides with actor type: player
    -changeAttribute: game.powerUpActive To: true

    Rule: when
    Event: powerUpActive is true
    -changeAttribute: myTimer To: self.Time
    -whatever you have happening

    Rule: when
    Attribute: self.Time ≥ myTimer+5
    --changeAttribute: game.powerUpActive To: false
    --destroy or recycle this actor … if recycling change myTimer to a large# ex: 1000

    image MH
  • digitalzerodigitalzero Member, BASIC Posts: 639
    okay I'm trying to understand that but it makes no sense whatsoever LOL... i actually figured out how to do the recycle thing because of the download you provided for me so i just copied some rules there and BAM everything worked but... yea this... I'm not understanding one bit LOL
  • MotherHooseMotherHoose Member Posts: 2,456
    so glad you are LOL … got me grinning!

    I think perhaps the self.myTimer purpose/functionality may be confusing you

    what the actual value of that attribute is … the computer knows … we do not have to know!
    we just have to remember:
    … that the actor's self.Time keeps ticking as long as actor is active (in the scene)
    … that we tell the computer to compare the self.Time to the value it has placed in myTimer
    ... and that self.Time will ≥ self.myTimer+5 … after 5 seconds

    I try to use the default attributes to control things in my projects … as they are already in Computer memory … and changes in their values require less resources than new behaviors or attributes.

    keep laughing @digitalzero … games are fun and making games is fun …
    and we all do some funny dumb things!

    image MH
  • digitalzerodigitalzero Member, BASIC Posts: 639
    well i have done more than SOME dumb things when it comes to game salad lol... hahaha... but okay so if you're saying that the actor always records the time then if I'm making a runner game... which i am... and i want the points to go up 1 every 0.2 seconds then this rule should work right

    when attribute self.time =self.mytime+0.2
    change attribute game.score to game.score+1

    NOTTT! yeah i thought i was being smart but making that but apparently I'm not lol... so is there anyways that i can do this without using the timer?... because of course i would love to use the timer because its the easiest thing to do and i know it works lol but my games are going to become more and more complicated as i go along with working with game salad which has been true lol but my next game i would like to make would be a platform game and of course i wouldn't like for the game to run at 30fps... yeah... that would suck. but right now I'm at 57 fps which is not too bad... but i would like for all of the games to work at 60fps :) but yeah can you give me some insight on how to make that score tureen into score+1 every 0.2 seconds without using a time... sorry i kinda rambled in this post lol
  • MotherHooseMotherHoose Member Posts: 2,456
    okay … you are getting it! … @digitalzero
    remember: self.Time is always self.Time … never more or less
    … nothing you code will affect it
    when scene is loaded … every actor's instance has self.Time = 0 and immediately starts ticking
    when you spawn an actor in scene … the spawned actor's self.Time = 0
    (and that gives you possibility on spawnedActors
    for Ex: Rule: when self.Time ≥ 1 … add some behaviors)
    (when referencing self.Time remember that it ticks in real time in milliseconds units
    … use ≥ not = … time only equals a specified # for 1 millisecond)

    Timers can be quirky with the Every option
    also, often on Actors with lots of rules/behaviors

    sometimes best to add a controlActor to scene
    and have that controlActor for Timers

    demo: http://www.mediafire.com/?wji5b2jhgpzxd33

    image MH
  • digitalzerodigitalzero Member, BASIC Posts: 639
    mannn!!!! this is so insightful and I'm totally going to put this thread in my bookmarks :) you are really awesome with explaining everything... i mean I'm not getting it FULLY yet! but i have a feeling that if i start really studying what you say and read it about 29 more times then i will start to understand it lol... hahahahha... i wish that you had a class that i can take in order to learn all of what you know because this stuff is great! my problem with game salad more or less is that i have problems with performance! i have these grand ideas in my head but I'm wondering if they will work because i want performance to be top notch when people are downloading the games :) so if you have a site where you have a series of video tutorials where i can take notes or a youtube page or something i will totally devote my time in watching the videos and take notes for hours on end... just like a real online class :) because I'm just simply an artist turned video game designer and since i am an artist then i have A LOT of visuals that i have in my games lol

    thanks so much for everything @motherhoose!
  • MotherHooseMotherHoose Member Posts: 2,456
    edited May 2012
    sent you a PM … in your Profile > Messages … @digitalzero

    I don't do videos … I watch all videos … especially @Tshirtbooth's and GS ones.

    we all started with GS as newbies …
    we learned by watching videos … reading the forum … and exploring the demos/templates
    … and playing around with every wonderful feature of GS!

    more importantly … we all continue to learn! and enjoy ourselves!

    @};- MH
Sign In or Register to comment.