Fire on bottom of the screen following the player


(Zouhair Elamrani Abou Elassad) #1

Hi,

I was working on some fire emitters, the idea is to generate fire on the bottom of the screen and at the same time it should follow the player while he’s moving (follow the Camera), this is where i am so far :

Weather Class :

           var p:ParticleType = emit.newType("f", [0]);

	p.setMotion(94, 20, 10, 0, 50, 1.0);
	p.setColor(0xF9FF59, 0xFF270A);
	p.setAlpha(0.9, 0.3);

       public function SetWeather(weather_type:String, frequency:int, layer:int = 4, weather_falls_down:Boolean = true):void {
	active = true;
	interval_between_particles = frequency;
	emit_count_down = 10;
	emit_string = weather_type;
	this.layer = layer;
	this.weather_falls_down = weather_falls_down; // If true, weather particles will float up instead
}

override public function update():void {
	emit_count_down += 1;
	if (emit_count_down > interval_between_particles) {
		emit_count_down = 0;
		emit.emit(emit_string, xx + FP.rand(6) , 200);
		xx++;
	}
}

I’m only testing with an incremented variable, i create the entity from my world using :

private function initFire):void 
	{		
		var w:Weather = new Weather();
		w.SetWeather("f", 0.3);
		add(w);
	}

This is what i get :

I was hoping for something more like :

If there is anything i can change, i’m all ears :).


(Mike Evmm) #2

I don’t think it’ll be easy to achieve that second effect without pre rendered textures, especially not with emmiters (if you insist on generated-on-the-fly stuff you might get away with bitmapdata manipulation). I might be wrong though. in case you go with pre rendered textures, a spritemap with a scroll factor of 0 might be the way to go.


(Mike Evmm) #3

Adding several emmiters might also help


(Zouhair Elamrani Abou Elassad) #4

I see what you mean, i thought maybe if i played a bit with the angle and duration i might get what i was looking for, but i’ll try to add several emitters and see what that will give, thanks buddy :).


(Zouhair Elamrani Abou Elassad) #5

Hi, what’s a scroll factor for the texture ? :).


(Mike Evmm) #6

A scroll factor for a graphic is how much (in percentage) a graphic moves with a camera.
By default, scrollX and scrollY, the vertical and horizontal components of the scroll factor, are set to 1. This means that if the camera moves, for instance, 10 pixels to the right, a default graphic (/image/spritemap/entity) will move 10 pxs to the left, which is what you’ll usually expect (if you move to your right, things which were in front of you are then to your left).
However, if you set scrollX to, imagine, 0.5, then if the camera moved horizontally 10 pixels to the right, then that graphic (again, /image/spritemap/entity) would move 0.5*10=5 pixels to the left. This is the sort of thing that happens when things are far away.
By setting both the scrollX and the scrollY to 0 you can make sure your fire will stay in place, no matter the movement of the camera (because it’ll always move 0*whatever=0 pixels).


(Zouhair Elamrani Abou Elassad) #7

Thanks for the explanation, i see what you mean, and yes using a spritesheet seems a lot more logical now :), thanks again buddy ^^.