Package tripleplay.particle

Examples of tripleplay.particle.Initializer


     * Returns an initializer that configures a particle with a constant transform.
     */
    public static Initializer constant (float scale, float rot, final float tx, final float ty) {
        float sina = FloatMath.sin(rot), cosa = FloatMath.cos(rot);
        final float m00 = cosa * scale, m01 = sina * scale, m10 = -sina * scale, m11 = cosa * scale;
        return new Initializer() {
            @Override public void init (int index, float[] data, int start) {
                data[start + ParticleBuffer.M00] = m00;
                data[start + ParticleBuffer.M01] = m01;
                data[start + ParticleBuffer.M10] = m10;
                data[start + ParticleBuffer.M11] = m11;
View Full Code Here


    /**
     * Returns an initializer that scales its previously assigned transform.
     */
    public static Initializer scale (final float scale)
    {
        return new Initializer() {
            @Override public void init (int index, float[] data, int start) {
                data[start + ParticleBuffer.M00] *= scale;
                data[start + ParticleBuffer.M01] *= scale;
                data[start + ParticleBuffer.M10] *= scale;
                data[start + ParticleBuffer.M11] *= scale;
View Full Code Here

     * random amount within the specified range.
     */
    public static Initializer randomScale (final Randoms rando, final float minScale,
                                           final float maxScale)
    {
        return new Initializer() {
            @Override public void init (int index, float[] data, int start) {
                float scale = rando.getInRange(minScale, maxScale);

                data[start + ParticleBuffer.M00] *= scale;
                data[start + ParticleBuffer.M01] *= scale;
View Full Code Here

     * Returns an initializer that configures a particle with the same transform (scale, rotation,
     * position) as the supplied layer. This will the the fully computed transform, not the layer's
     * local transform.
     */
    public static Initializer layer (final Layer layer) {
        return new Initializer() {
            @Override public void willInit (int count) {
                // concatenate the transform of all layers above our target layer
                xform.setTransform(1, 0, 0, 1, 0, 0);
                Layer xlayer = layer;
                while (xlayer != null) {
View Full Code Here

     * Returns an initializer that configures a particle's position in a random region. The scale
     * and rotation are not initialized, so this should be used with {@link #identity}.
     */
    public static Initializer randomPos (final Randoms rando, final float x, final float y,
                                         final float width, final float height) {
        return new Initializer() {
            @Override public void init (int index, float[] data, int start) {
                data[start + ParticleBuffer.TX] = x + rando.getFloat(width);
                data[start + ParticleBuffer.TY] = y + rando.getFloat(height);
            }
        };
View Full Code Here

    /**
     * Returns an initializer that adjusts the particle's position randomly from its current
     * location by up to noise units in both x & y.
     */
    public static Initializer randomOffset (final Randoms rando, final float noise) {
        return new Initializer() {
            @Override public void init (int index, float[] data, int start) {
                data[start + ParticleBuffer.TX] += rando.getInRange(-noise, noise);
                data[start + ParticleBuffer.TY] += rando.getInRange(-noise, noise);
            }
        };
View Full Code Here

{
    /**
     * Returns an initializer that provides a constant lifespan.
     */
    public static Initializer constant (final float lifespan) {
        return new Initializer() {
            @Override public void init (int index, float[] data, int start) {
                data[start+ParticleBuffer.LIFESPAN] = lifespan;
            }
        };
    }
View Full Code Here

    /**
     * Returns an initializer that provides a random lifespan between {@code min} and {@code max}.
     */
    public static Initializer random (final Randoms rando, final float min, final float max) {
        return new Initializer() {
            @Override public void init (int index, float[] data, int start) {
                data[start+ParticleBuffer.LIFESPAN] = rando.getInRange(min, max);
            }
        };
    }
View Full Code Here

    /**
     * Returns an initializer that increments the previously assigned velocity by the specified
     * amounts.
     */
    public static Initializer increment (final float dx, final float dy) {
        return new Initializer() {
            @Override public void init (int index, float[] data, int start) {
                float scale = graphics().ctx().scale.factor;
                data[start + ParticleBuffer.VEL_X] += dx * scale;
                data[start + ParticleBuffer.VEL_Y] += dy * scale;
            }
View Full Code Here

    /**
     * Returns an initializer that initializes the particle's color to the supplied constant value.
     */
    public static Initializer constant (final float r, final float g, final float b, final float a) {
        return new Initializer() {
            @Override public void init (int index, float[] data, int start) {
                data[start+ParticleBuffer.ALPHA_RED= playn.core.Color.encode(a, r);
                data[start+ParticleBuffer.GREEN_BLUE] = playn.core.Color.encode(g, b);
            }
        };
View Full Code Here

TOP

Related Classes of tripleplay.particle.Initializer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.