deepnight / gameBase

Base structure for my games, using Heaps framework and Haxe language.
https://deepnight.net
MIT License
614 stars 152 forks source link

How to use Camera and Fx.hx #17

Closed harshetmaruff closed 3 years ago

harshetmaruff commented 3 years ago

Hi deepnight, How do i use camera and fx system in your GameBase, Since... I am a Beginner at Haxe .

deepnight commented 3 years ago

The Camera class is just a coordinate that moves around the Game.scroller container (which should contain all the in-game display objects).

Fx is a little bit more complicated, and can't be explained in short way :)

I just added to git a very short sample to demonstrate how to create some dots explosion in Fx.hx:


    /**
        A small sample to demonstrate how basic particles work. This example produces a small explosion of yellow dots that will fall and slowly fade to purple.

        USAGE: fx.dotsExplosionExample(50,50, 0xffcc00)
    **/
    public function dotsExplosionExample(x:Float, y:Float, color:UInt) {
        for(i in 0...80) {
            var p = allocTopAdd( getTile("fxDot"), x+rnd(0,3,true), y+rnd(0,3,true) );
            p.alpha = rnd(0.4,1);
            p.colorAnimS(color, 0x762087, rnd(0.6, 3)); // fade particle color from parameter color to some purple
            p.moveAwayFrom(x,y, rnd(1,3)); // move away from source
            p.frict = rnd(0.8, 0.9); // friction applied to velocities
            p.gy = rnd(0, 0.02); // gravity Y (added on each frame)
            p.lifeS = rnd(2,3); // life time in seconds
        }
    }