Hey guys! I set up a nice little cloud system for my game earlier today, and I was just wondering if I could get some constructive criticism, and if you think this method would be good for a final game, or if there are much better more efficient ways of doing so.
I will list all the code I have created for my scrolling clouds.
The Cloud.as file:
package entities {
import net.flashpunk.Entity;
import net.flashpunk.graphics.Image;
import net.flashpunk.FP;
public class theCloud extends Entity {
[Embed(source = '../assets/cloud.png')]
protected const CLOUD:Class;
public function theCloud(posX:int,posY:int) {
graphic=new Image(CLOUD);
setHitbox(80,120);
type="cloud";
x=posX*40;
y = posY * 40;
//graphic.scrollX = .5;
}
override public function update():void
{
x -= FP.elapsed * 20;
trace("x value of the cloud imave: " + x);
if (x <= -125)
{
x = 2560;
}
}
}}
In the World.as
for (var t:int = 0; t < 10; t++)
{
add(new theCloud(FP.rand(64), FP.rand(7)+1));
}
Like I said everything runs fine, I was just wondering if there was a better way of doing this. Thanks guys! I tried making it a backdrop, but that went horribly wrong and I had a nice LARGE never ending cloud scrolling… lol