I would like to put clouds in my game that slowly drift across the screen in the background. How would I do this?
Comments
Braydon_SFXMember, Sous Chef, Bowlboy SidekickPosts: 9,273
Hi,
Just create a actor with the height and width of your cloud image. Then just put a move behavior in there and set it kind of slow, you want it to move slowly rather then very quick.
I looked at the cannon physics template but was confused as to how to do it. And I would like an unlimited supply of clouds. If you just put the actors there and set them to move then they will eventually move off the screen
Braydon_SFXMember, Sous Chef, Bowlboy SidekickPosts: 9,273
Hey MegapixelIdeas, I would create an actor Cloud and put a behaviuor that change self.motion.x to xspeed to make it go right or -xspeed to make it go left. For example you want the cloud to go from right to left: put change attribute self.motion.x to -1*100. Then you have to add a rule that check: if self.position.x<= -1*(self.width/2) then change self.position.x to scene size x +(self.width/2) With this rule when the cloud reaches the left part of the screen plus its width, it returns to the right part of the screen plus its width. I put plus its width because x position refers the center of the cloud and instead you need the cloud to completely go out of the scene before reusing it. This way you recycle your cloud without destroy or spawning anything. And this improve performance a lot! You can put more than one cloud for each scene and add some transparency and random attributes so that it will look less repetitive. For example each time the cloud reach the edge of the screen, you can vary its y position. I invite you to try playing a while with these attributes and see the results.
Comments
Just create a actor with the height and width of your cloud image.
Then just put a move behavior in there and set it kind of slow, you want it to move slowly rather then very quick.
My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx
My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx
I would create an actor Cloud and put a behaviuor that change self.motion.x to xspeed to make it go right or -xspeed to make it go left. For example you want the cloud to go from right to left: put change attribute self.motion.x to -1*100. Then you have to add a rule that check:
if self.position.x<= -1*(self.width/2)
then change self.position.x to scene size x +(self.width/2)
With this rule when the cloud reaches the left part of the screen plus its width, it returns to the right part of the screen plus its width. I put plus its width because x position refers the center of the cloud and instead you need the cloud to completely go out of the scene before reusing it.
This way you recycle your cloud without destroy or spawning anything. And this improve performance a lot! You can put more than one cloud for each scene and add some transparency and random attributes so that it will look less repetitive.
For example each time the cloud reach the edge of the screen, you can vary its y position. I invite you to try playing a while with these attributes and see the results.
Hope it helps!
Typed all from my iPod!
Cerulean Swan Games