best way to bring various actors across side scrolling screen?

app-etiteapp-etite Member Posts: 139
edited November -1 in Working with GS (Mac)
Hi guys,

My game is an automatic run and press to jump game side scroller.

Whats the best way to bring objects in from the right to left, Im looking for a way that is good on memory saving because the only way I know is to have all my objects just outside the screen and have them move on individually from a timer.

any suggestions?

Thanks

Appetite games

Comments

  • app-etiteapp-etite Member Posts: 139
    anyone?
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
  • app-etiteapp-etite Member Posts: 139
    How would i go about using the interpolate for all my actors?

    Im a beginner so please elaborate.

    Thanks
  • b2iscoolb2iscool Member Posts: 135
    just use move in the direction you would like if you dont wanna get complicated then if you run into memory issues you could use interpolate
  • app-etiteapp-etite Member Posts: 139
    at the moment I do have the objects moving in the direction needed but there are about 20 actors on top of each other waiting to move onto the screen which is messy tho look at and hard to deal with when im editing things.... how is the interpolate used in this situation?

    Thanks for the replies
  • app-etiteapp-etite Member Posts: 139
    really need help with this

    I have approximately 10 actors (objects) that my character has to jump over. I want them scrolling on screen from right to left.. so although i have 10 actors i will need them to repeat again and again.

    The only way i know how to have the actors moving across screen, is to have all my actors dropped in just off screen and use the move attribute at this or that speed. But obviously having all those actors there at one time is terrible for memory usage which is now up to 26mb when viewing the gameplay.

    any help please??

    -appetite games
  • olster1olster1 Member Posts: 396
    In fact, it's better to have all the actors on screen and once and to recycle them rather than destroying and spawning. What I explain below is assuming each of the obstacles are different sizes.

    Create a game intiger attribute called obstacle
    Create a boolean attribute in each obstacle called move

    Create an actor or anything to use as your randomiser. Add a timer in it and say
    every X seconds change attribute game.obstacle random (1, however many obstacles there are)

    Assign a number to each obstacle and create rule when game.obstacle = the number you assigned
    change attribute self.move to true

    Create a second rule when self.move=true
    move actor at 180 speed 90 (something like that) If you want to interpolate instead of move then say interpolate position x to -50 select linear and have a duration of 1. If you want it slower make the duration bigger.

    Create a third rule When Attribute self.position.X < - self.Size.Width /2
    Change attribute self.position.X to self.Position.X + self.Size.Width + game.Display Size.Width AND change self.move to false.

    Place each actor just out of view of the camera on the right.

    This is at least what I use, not sure if it's the most efficient but seems like the best solution.

    If your obstacles are the same size this may save more memory:

    Create a game intiger attribute called obstacle
    Create a boolean attribute in each obstacle called move
    Create another game intiger attribute called image

    Create an actor or anything to use as your randomiser. Add a timer in it and say
    every X seconds change attribute game.obstacle random (1, however many obstacles there are on screen at any one time)

    Create a single prototype actor and chuck all of these rules in there.

    What is the maximum number of obstacles on screen at any one time, lets say its 3. So drag 3 copies of this prototype onto your scene on right hand side. Assign a number to each obstacle 1,2 and 3 and create rule when game.obstacle = the number you assigned
    change attribute self.move to true AND change attribute game.image to random (1, however many images of obstacles you have)

    Assign each image with a number and create a second rule thats says when game.image = the assigned number
    change image to the image you assigned.

    Create a third rule when self.move=true
    move actor at 180 speed 90 (something like that) If you want to interpolate instead of move then say interpolate position x to -50 select linear and have a duration of 1. If you want it slower make the duration bigger.

    Create a fourth rule When Attribute self.position.X < - self.Size.Width /2
    Change attribute self.position.X to self.Position.X + self.Size.Width + game.Display Size.Width AND change self.move to false.

    So with this method you only have one prototype and only 3 actors on scene but all 10 obstacles.

    Hope that helps :)
Sign In or Register to comment.