Android Open Source - candymem Firework Item






From Project

Back to project page candymem.

License

The source code is released under:

GNU General Public License

If you think the Android project candymem listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package se.tube42.kidsmem.item;
// w ww .j  a  v  a 2 s  . c  o m
import com.badlogic.gdx.graphics.*;
import com.badlogic.gdx.graphics.g2d.*;

import se.tube42.lib.tweeny.*;
import se.tube42.lib.item.*;
import se.tube42.lib.util.*;
import se.tube42.lib.ks.*;

import se.tube42.kidsmem.data.*;
import se.tube42.kidsmem.service.*;

public class FireworkItem
extends ParticleItem
{
    private MessageListener listener;
    private int msg, data0;

    public FireworkItem()
    {
    }


    public void emit(MessageListener listener, int msg, int data0)
    {
        if(getState() != 0) {
            stop();
        }

        this.listener = listener;
        this.msg = msg;
        this.data0 = data0;

        emit1();
    }

    private void emit1()
    {
        final float ya = -20;
        final float xa = ServiceProvider.getRandom(0, UI.sw);
        final float xb = Math.max(0, Math.min(UI.sw,
                  xa + ServiceProvider.getRandom(0, UI.sw / 3)));
        final float yb = UI.sh * 0.3f + ServiceProvider.getRandom(0, UI.sh * 0.7f);
        final float t = ServiceProvider.getRandom(0.6f, 1.0f);

        setState(0);
        setPosition(xa, ya);
        set(BaseItem.ITEM_X, xb).configure(t, null);
        set(BaseItem.ITEM_Y, yb).configure(t, null);
        emit(Assets.pep_trail);

    }

    private void emit2()
    {
        setState(1);
        emit(Assets.pep_firework);
    }


    public void onParticleEnded()
    {
        super.onParticleEnded();

        switch(getState()) {
        case 0:
            emit2();
            break;
        default:
            setState(0);
            if(listener != null)
                listener.onMessage(msg, data0, this, this);
        }
    }
}




Java Source Code List

com.badlogic.gdx.backends.lwjgl.LwjglApplication.java
se.tube42.kidsmem.KidsMemoryApp.java
se.tube42.kidsmem.SystemHandler.java
se.tube42.kidsmem.android.MainActivity.java
se.tube42.kidsmem.data.Assets.java
se.tube42.kidsmem.data.Constants.java
se.tube42.kidsmem.data.Settings.java
se.tube42.kidsmem.data.UI.java
se.tube42.kidsmem.data.World.java
se.tube42.kidsmem.desktop.DesktopMain.java
se.tube42.kidsmem.item.Button.java
se.tube42.kidsmem.item.FireworkItem.java
se.tube42.kidsmem.item.GameStat.java
se.tube42.kidsmem.item.TileSprite.java
se.tube42.kidsmem.item.TopBar.java
se.tube42.kidsmem.logic.AssetHelper.java
se.tube42.kidsmem.logic.GameHelper.java
se.tube42.kidsmem.logic.SettingsHelper.java
se.tube42.kidsmem.logic.SizeHelper.java
se.tube42.kidsmem.scene.BackgroundScene.java
se.tube42.kidsmem.scene.GameScene.java
se.tube42.kidsmem.scene.MenuScene.java
se.tube42.kidsmem.service.ServiceProvider.java
se.tube42.lib.item.BaseItem.java
se.tube42.lib.item.BaseText.java
se.tube42.lib.item.ParticleItem.java
se.tube42.lib.item.PatchItem.java
se.tube42.lib.item.SpriteItem.java
se.tube42.lib.scene.LayerList.java
se.tube42.lib.scene.Layer.java
se.tube42.lib.scene.SceneManager.java
se.tube42.lib.scene.Scene.java
se.tube42.lib.service.AssetService.java
se.tube42.lib.service.JobService.java
se.tube42.lib.service.RandomService.java
se.tube42.lib.service.StorageService.java
se.tube42.lib.util.BaseApp.java
se.tube42.lib.util.UIC.java