java类com.badlogic.gdx.graphics.g2d.ParticleEffect的实例源码

GameState.java 文件源码 项目:KyperBox 阅读 28 收藏 0 点赞 0 评论 0
private void loadParticleEffects(TiledMap data, String atlasname) {
    MapObjects objects = data.getLayers().get("preload").getObjects();
    String ppcheck = "Particle";
    for (MapObject o : objects) {
        String name = o.getName();
        MapProperties properties = o.getProperties();
        String type = properties.get("type", String.class);
        if (type != null && type.equals(ppcheck)) {
            String file = properties.get("particle_file", String.class);
            if (file != null) {
                game.loadParticleEffect(file, atlasname);
                game.getAssetManager().finishLoading();
                if (!particle_effects.containsKey(name)) {
                    ParticleEffect pe = game.getParticleEffect(file);
                    pe.setEmittersCleanUpBlendFunction(false);
                    pvalues.add(KyperBoxGame.PARTICLE_FOLDER + KyperBoxGame.FILE_SEPARATOR + file);
                    particle_effects.put(name, new ParticleEffectPool(pe, 12, 48));
                }
            }
        }
    }
}
BattleUI.java 文件源码 项目:Inspiration 阅读 23 收藏 0 点赞 0 评论 0
@Override
public void act(float delta){
    battleTimer = (battleTimer + delta)%60;
    if( damageValLabel.isVisible() && damageValLabel.getY() < this.getHeight()){
        damageValLabel.setY(damageValLabel.getY()+5);
    }

    if( battleShakeCam != null && battleShakeCam.isCameraShaking() ){
        Vector2 shakeCoords = battleShakeCam.getNewShakePosition();
        _image.setPosition(shakeCoords.x, shakeCoords.y);
    }

    for( int i = 0; i < _effects.size; i++){
        ParticleEffect effect = _effects.get(i);
        if( effect == null ) continue;
        if( effect.isComplete() ){
            _effects.removeIndex(i);
            effect.dispose();
        }else{
            effect.update(delta);
        }
    }

    super.act(delta);
}
ParticleEffectFactory.java 文件源码 项目:Inspiration 阅读 21 收藏 0 点赞 0 评论 0
public static ParticleEffect getParticleEffect(ParticleEffectType particleEffectType, float positionX, float positionY){
    ParticleEffect effect = new ParticleEffect();
    effect.load(Gdx.files.internal(particleEffectType.getValue()), Gdx.files.internal(SFX_ROOT_DIR));
    effect.setPosition(positionX, positionY);
    switch(particleEffectType){
        case CANDLE_FIRE:
            effect.scaleEffect(1.6f);
            break;
        case LANTERN_FIRE:
            effect.scaleEffect(.6f);
            break;
        case LAVA_SMOKE:
            effect.scaleEffect(1.6f);
            break;
        case WAND_ATTACK:
            effect.scaleEffect(4.0f);
            break;
        default:
            break;
    }
    effect.start();
    return effect;
}
Shoot.java 文件源码 项目:spacegame 阅读 32 收藏 0 点赞 0 评论 0
public Shoot(String nameTexture, int x, int y, GameObject shooter, ParticleEffect shootEffect, ParticleEffect destroyEffect, String shootFX) {
    super(nameTexture,x,y);
    this.shooter = shooter;
    shocked = false;

    originalShootPosition = new Vector2(x,y);

    //Creamos los efectos de partículas si no vienen nulos
    if (shootEffect != null) {
        this.shootEffect = shootEffect;
        shootEffect.start();
    }
    if (destroyEffect != null) {
        this.destroyEffect = destroyEffect;
        destroyEffect.start();
    }

    this.shootFX = shootFX;
}
Enemy.java 文件源码 项目:spacegame 阅读 26 收藏 0 点赞 0 评论 0
public Enemy(String textureName, int x, int y, int vitality, ParticleEffect destroyEffect) {
    super(textureName, x, y);
    initialPosition = new Vector2(x,y);
    this.vitality = vitality;
    deletable = false;
    this.destroyEffect = destroyEffect;
    timeToFlick = 0;
    timeForInvisible = RANGE_INVISIBLE_TIMER;

    targettedByShip = false;

    if(this.destroyEffect != null){
        this.destroyEffect.getEmitters().first().setPosition(this.getX() + this.getWidth()/2, this.getY() + this.getHeight()/2);
        this.destroyEffect.start();
    }
}
Car.java 文件源码 项目:Crazy-Car-Race 阅读 29 收藏 0 点赞 0 评论 0
public Car(String name, String lane, Texture texture, Vector2 pos, Vector2 direction) {

        super(texture, pos, direction);

        this.eType = 1;

        if(name.equals("CAR1")){
            carWidth = TextureManager.CAR1.getWidth();
            carHeight = TextureManager.CAR1.getHeight();
        }else if(name.equals("CAR2")){
            carWidth = TextureManager.CAR2.getWidth();
            carHeight = TextureManager.CAR2.getHeight();
        }


        smokeEffect = new ParticleEffect();
        smokeEffect.load(Gdx.files.internal("effects/car_smoke_1.p"), Gdx.files.internal("effect_img"));
        smokeEffect.setPosition(this.pos.x + carWidth / 2, this.pos.y + carHeight / 10 );
        smokeEffect.start();
    }
ActuatorEntity.java 文件源码 项目:Entitas-Java 阅读 69 收藏 0 点赞 0 评论 0
public ActuatorEntity addParticleEffectActuator(ParticleEffect effect,
        boolean autoStart, float locaPosX, float locaPosY) {
    ParticleEffectActuator component = (ParticleEffectActuator) recoverComponent(ActuatorComponentsLookup.ParticleEffectActuator);
    if (component == null) {
        component = new ParticleEffectActuator(effect, autoStart, locaPosX,
                locaPosY);
    } else {
        component.particleEffect = effect;
        component.actuator = (indexOwner) -> {
            GameEntity owner = Indexed.getInteractiveEntity(indexOwner);
            RigidBody rc = owner.getRigidBody();
            Transform transform = rc.body.getTransform();
            effect.setPosition(transform.getPosition().x + locaPosX,
                    transform.getPosition().y + locaPosY);
            effect.update(Gdx.graphics.getDeltaTime());
            if (autoStart && effect.isComplete())
                effect.start();
        };
    }
    addComponent(ActuatorComponentsLookup.ParticleEffectActuator, component);
    return this;
}
ActuatorEntity.java 文件源码 项目:Entitas-Java 阅读 25 收藏 0 点赞 0 评论 0
public ActuatorEntity replaceParticleEffectActuator(ParticleEffect effect,
        boolean autoStart, float locaPosX, float locaPosY) {
    ParticleEffectActuator component = (ParticleEffectActuator) recoverComponent(ActuatorComponentsLookup.ParticleEffectActuator);
    if (component == null) {
        component = new ParticleEffectActuator(effect, autoStart, locaPosX,
                locaPosY);
    } else {
        component.particleEffect = effect;
        component.actuator = (indexOwner) -> {
            GameEntity owner = Indexed.getInteractiveEntity(indexOwner);
            RigidBody rc = owner.getRigidBody();
            Transform transform = rc.body.getTransform();
            effect.setPosition(transform.getPosition().x + locaPosX,
                    transform.getPosition().y + locaPosY);
            effect.update(Gdx.graphics.getDeltaTime());
            if (autoStart && effect.isComplete())
                effect.start();
        };
    }
    replaceComponent(ActuatorComponentsLookup.ParticleEffectActuator,
            component);
    return this;
}
ParticleSystem.java 文件源码 项目:ZombieCopter 阅读 20 收藏 0 点赞 0 评论 0
public void addEffect(String name, Vector2 position, float angle){
    logger.debug("Creating effect: " + name);
    ParticleEffect effect = App.assets.getEffect(name);
    if (effect == null) {
        logger.error("Couldn't create particle effect: " + name);
        return;
    }
    ParticleEffect e = new ParticleEffect(effect);
    for (ParticleEmitter emitter : e.getEmitters()){
        float a1 = emitter.getAngle().getHighMin(),
              a2 = emitter.getAngle().getHighMax();

        emitter.getRotation().setHighMin(a1 + angle);
        emitter.getRotation().setHighMax(a2 + angle);
    }
    e.setPosition(position.x * App.engine.PIXELS_PER_METER, position.y * App.engine.PIXELS_PER_METER);
    e.start();
    effects.add(e);

}
ParticleEffectProvider.java 文件源码 项目:gdx-lml 阅读 26 收藏 0 点赞 0 评论 0
@Override
public ParticleEffect getOrLoad(final String id) {
    final String[] data = Strings.split(id, '$');
    if (data.length == 0) {
        throwUnknownPathException();
    }
    final String path = determinePath(data[0]);
    getIdsToPaths().put(id, path);
    final AssetManager assetManager = getAssetManager();
    if (assetManager.isLoaded(path)) {
        return assetManager.get(path, getType());
    }
    if (data.length > 1) {
        final String atlasName = TextureAtlasProvider.getTextureAtlasPath(data[1]);
        final ParticleEffectParameter parameters = new ParticleEffectParameter();
        parameters.atlasFile = atlasName;
        assetManager.load(path, ParticleEffect.class, parameters);
    } else {
        assetManager.load(path, ParticleEffect.class);
    }
    return null;
}
ParticleEffectPools.java 文件源码 项目:sioncore 阅读 27 收藏 0 点赞 0 评论 0
public ParticleEffectPools() {
    logger = new Logger(TAG, Env.debugLevel);

    logger.info("initialising");

    pools = new ObjectMap<String, ParticleEffectPool>();

    try {
        JsonReader reader = new JsonReader();
        JsonValue root = reader.parse(Gdx.files.internal(PARTICLES_FILE));
        JsonIterator particlesIt = root.iterator();

        while (particlesIt.hasNext()) {
            JsonValue particleValue = particlesIt.next();
            String effectName = particleValue.asString();
            logger.info("loading " + effectName);
            ParticleEffect effect = new ParticleEffect();
            effect.load(Gdx.files.internal(effectName), Gdx.files.internal(PARTICLES_FOLDER));

            pools.put(effectName, new ParticleEffectPool(effect,
                                                         Env.particlePoolInitialCapacity,
                                                         Env.particlePoolMaxCapacity));
        }
    }
    catch (Exception e) {
        logger.error("failed to list directory " + PARTICLES_FILE);
    }
}
AssetManager.java 文件源码 项目:libgdxcn 阅读 27 收藏 0 点赞 0 评论 0
/** Creates a new AssetManager with all default loaders. */
public AssetManager (FileHandleResolver resolver) {
    setLoader(BitmapFont.class, new BitmapFontLoader(resolver));
    setLoader(Music.class, new MusicLoader(resolver));
    setLoader(Pixmap.class, new PixmapLoader(resolver));
    setLoader(Sound.class, new SoundLoader(resolver));
    setLoader(TextureAtlas.class, new TextureAtlasLoader(resolver));
    setLoader(Texture.class, new TextureLoader(resolver));
    setLoader(Skin.class, new SkinLoader(resolver));
    setLoader(ParticleEffect.class, new ParticleEffectLoader(resolver));
    setLoader(PolygonRegion.class, new PolygonRegionLoader(resolver));
    setLoader(I18NBundle.class, new I18NBundleLoader(resolver));
    setLoader(Model.class, ".g3dj", new G3dModelLoader(new JsonReader(), resolver));
    setLoader(Model.class, ".g3db", new G3dModelLoader(new UBJsonReader(), resolver));
    setLoader(Model.class, ".obj", new ObjLoader(resolver));
    executor = new AsyncExecutor(1);
}
FireWorksLayer.java 文件源码 项目:droidtowers 阅读 25 收藏 0 点赞 0 评论 0
public FireWorksLayer(GameGrid gameGrid) {
    super();

    gameGrid.events().register(this);
    TutorialEngine.instance().eventBus().register(this);
    AchievementEngine.instance().eventBus().register(this);

    ParticleEffect particleEffect = new ParticleEffect();
    particleEffect.load(Gdx.files.internal("particles/firework.p"), Gdx.files.internal("particles"));

    Set<float[]> colors = Sets.newHashSet();
    colors.add(makeParticleColorArray(Color.WHITE, Color.RED, Color.ORANGE));
    colors.add(makeParticleColorArray(Color.WHITE, Color.BLUE, Color.GREEN));
    colors.add(makeParticleColorArray(Color.WHITE, Color.YELLOW, Color.PINK));
    colors.add(makeParticleColorArray(Color.WHITE, Color.PINK, Color.MAGENTA));
    colors.add(makeParticleColorArray(Color.WHITE, Color.BLUE, Color.CYAN));

    colorsIterator = Iterators.cycle(colors);

    worldBounds = new Rectangle();
    for (int i = 0; i < 10; i++) {
        addChild(new ParticleEffectManager(new ParticleEffect(particleEffect), colorsIterator, worldBounds));
    }
}
RuleParticleEffect.java 文件源码 项目:c2d-engine 阅读 21 收藏 0 点赞 0 评论 0
@Override
public boolean match(FileHandle file) {
    boolean result = file.extension().equals("p");
    if(result) {
        Engine.getAssetManager().load(file.path().replace("\\", "/"),ParticleEffect.class);
        return result;
    }
    result = file.extension().equals("pp");
    if(result) {
        ParticleEffectParameter parameter = new ParticleEffectParameter();
        parameter.atlasFile = file.pathWithoutExtension().replace("\\", "/")+".atlas";
        Engine.getAssetManager().load(file.path().replace("\\", "/"),ParticleEffect.class,parameter);
        return result;
    }
    return  false;
}
AchievementButton.java 文件源码 项目:droidtowers 阅读 30 收藏 0 点赞 0 评论 0
public AchievementButton(TextureAtlas hudAtlas, AchievementEngine achievementEngine) {
    super(hudAtlas.findRegion("achievements"), Colors.ICS_BLUE);

    activeAnimation = new Animation(ANIMATION_DURATION, hudAtlas.findRegions("achievements-active"));
    nextAnimationTime = 0;

    particleEffect = new ParticleEffect();
    particleEffect.load(Gdx.files.internal("particles/sparkle.p"), Gdx.files.internal("particles"));

    addListener(new VibrateClickListener() {
        public void onClick(InputEvent event, float x, float y) {
            new AchievementListView(getStage()).show();
        }
    });

    setVisible(false);
}
AbstractActor.java 文件源码 项目:MathAttack 阅读 32 收藏 0 点赞 0 评论 0
/**
 * Set particle for this actor, centerPosition is used to center the
 * particle on this actor sizes.
 *
 * @param particleEffect the particle effect
 * @param isParticleEffectActive the is particle effect active
 * @param isStart the is start
 * @param centerPosition the center position
 */
public void setParticleEffect(ParticleEffect particleEffect,
        boolean isParticleEffectActive, boolean isStart,
        boolean centerPosition) {
    this.particleEffect = particleEffect;
    this.isParticleEffectActive = isParticleEffectActive;
    if (!centerPosition) {
        this.particleEffect.setPosition(getX(), getY());
    } else {
        particlePosX = getWidth() / 2.0f;
        particlePosY = getHeight() / 2.0f;
        this.particleEffect.setPosition(getX() + particlePosX, getY()
                + particlePosY);
    }

    if (isStart) {
        this.particleEffect.start();
    }
}
AbstractGroup.java 文件源码 项目:MathAttack 阅读 18 收藏 0 点赞 0 评论 0
/**
 * Set particle for this actor, centerPosition is used to center the
 * particle on this actor sizes.
 *
 * @param particleEffect the particle effect
 * @param isParticleEffectActive the is particle effect active
 * @param isStart the is start
 * @param centerPosition the center position
 */
public void setParticleEffect(ParticleEffect particleEffect,
        boolean isParticleEffectActive, boolean isStart,
        boolean centerPosition) {
    this.particleEffect = particleEffect;
    this.isParticleEffectActive = isParticleEffectActive;
    if (!centerPosition) {
        this.particleEffect.setPosition(getX(), getY());
    } else {
        particlePosX = getWidth() / 2.0f;
        particlePosY = getHeight() / 2.0f;
        this.particleEffect.setPosition(getX() + particlePosX, getY()
                + particlePosY);
    }

    if (isStart) {
        this.particleEffect.start();
    }
}
PoisonDrop.java 文件源码 项目:CatchDROP 阅读 21 收藏 0 点赞 0 评论 0
public PoisonDrop(final CDGame game) {
    super(game);
    x = MathUtils.random(0, game.GAME_WIDTH-64);
    y = game.GAME_HEIGHT;
    width = 64;
    height = 64;
    loseOnMiss = false;
    gainValue = 0;
    loseValue = 2;
    rectImg = new Texture("poison.png");

    poisonTimer = 10;
    nowTimeInSeconds = TimeUtils.nanosToMillis(TimeUtils.nanoTime())/1000;
    lastTimeInSeconds = nowTimeInSeconds;

    fireEffect = new ParticleEffect();
    fireEffect.load(Gdx.files.internal("fire.p"), Gdx.files.internal(""));
    fireEffectPool = new ParticleEffectPool(fireEffect, 1, 2);
    firePEffect = fireEffectPool.obtain();
}
PoisonDrop.java 文件源码 项目:CatchDROP 阅读 32 收藏 0 点赞 0 评论 0
public PoisonDrop(final CDGame game, float x, float y, BitmapFont timerFont) {
    super(game);
    this.x = x;
    this.y = y;
    width = 64;
    height = 64;
    loseOnMiss = false;
    gainValue = 0;
    loseValue = 2;
    rectImg = new Texture("poison.png");

    poisonTimer = 10;
    nowTimeInSeconds = TimeUtils.nanosToMillis(TimeUtils.nanoTime())/1000;
    lastTimeInSeconds = nowTimeInSeconds;

    fireEffect = new ParticleEffect();
    fireEffect.load(Gdx.files.internal("fire.p"), Gdx.files.internal(""));
    fireEffectPool = new ParticleEffectPool(fireEffect, 1, 2);
    firePEffect = fireEffectPool.obtain();

    this.timerFont = timerFont;
}
Assets.java 文件源码 项目:Simple-Isometric-Game 阅读 24 收藏 0 点赞 0 评论 0
public void enqueueAssets() {
    // Textures
    manager.load(PlayerTex, Texture.class);
    manager.load(CoinTex, Texture.class);

    // Particles
    manager.load(CoinPrt, ParticleEffect.class);

    // Fonts
    manager.load(DefaultFnt, BitmapFont.class);

    // Skins
    manager.load(DefaultSkin, Skin.class);

    // Sounds
    manager.load(CoinSound, Sound.class);
    manager.load(FinishSound, Sound.class);
}
RenderingSystem.java 文件源码 项目:0Bit-Engine 阅读 25 收藏 0 点赞 0 评论 0
@Override
public void update(float deltaTime) {
    Gdx.gl.glClearColor(bgColour[0], bgColour[1], bgColour[2], bgColour[3]);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
    batch.setProjectionMatrix(camera.combined);

    batch.begin();
    super.update(deltaTime);
    for (ParticleEffect particle : particles) particle.draw(batch, deltaTime);
    batch.end();

    if (ZeroBit.debugEnabled) {
        shapeRenderer.setProjectionMatrix(camera.combined);
        shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
            for (Entity entity : getEntities()) debugRender(entity);
        shapeRenderer.end();
    }
}
Overlap2DLoader.java 文件源码 项目:0Bit-Engine 阅读 25 收藏 0 点赞 0 评论 0
/**
 * Adds a ParticleEffect from a ParticleEffectVO. Uses ParticleEmitterBox2D
 * @param item ParticleEffectVO to add
 */
private static void addParticle(ParticleEffectVO item) {
    ParticleEffect particleEffect = new ParticleEffect();
    particleEffect.load(Gdx.files.internal(particlesPath + "/" + item.particleName), atlas);
    particleEffect.scaleEffect(ZeroBit.pixelsToMeters * item.scaleX);

    for (int i=0; i < particleEffect.getEmitters().size; i++) {
        particleEffect.getEmitters().set(i, new ParticleEmitterBox2D(b2dSystem.getB2World(), particleEffect.getEmitters().get(i)));
        ParticleEmitter emitter = particleEffect.getEmitters().get(i);

        // Spawn scaling doesn't seem to alter the actual dimensions of the effect like in the editor
        /*emitter.getSpawnWidth().setHigh(emitter.getSpawnWidth().getHighMin() * item.scaleX, emitter.getSpawnWidth().getHighMax() * item.scaleX);
        emitter.getSpawnWidth().setLow(emitter.getSpawnWidth().getLowMin() * item.scaleX, emitter.getSpawnWidth().getLowMax() * item.scaleX);
        emitter.getSpawnHeight().setHigh(emitter.getSpawnHeight().getHighMin() * item.scaleY, emitter.getSpawnHeight().getHighMax() * item.scaleY);
        emitter.getSpawnHeight().setLow(emitter.getSpawnHeight().getLowMin() * item.scaleY, emitter.getSpawnHeight().getLowMax() * item.scaleY);*/

        emitter.setPosition(item.x * ZeroBit.pixelsToMeters, item.y * ZeroBit.pixelsToMeters);
    }
    //entityManager.getEngine().getSystem(RenderingSystem.class).addParticle(particleEffect);
    ParticleComponent pc = new ParticleComponent();
    pc.addParticle(particleEffect);
    addEntity(item, null, pc, new VisualComponent());
}
MainMenuScreen.java 文件源码 项目:SMC-Android 阅读 30 收藏 0 点赞 0 评论 0
@Override
  public void loadAssets()
  {
      loader.parseLevel(world);
game.assets.manager.load("data/hud/hud.pack", TextureAtlas.class);
      game.assets.manager.load("data/hud/controls.pack", TextureAtlas.class);
      game.assets.manager.load("data/maryo/small.pack", TextureAtlas.class);
      game.assets.manager.load("data/game/logo/smc_big_1.png", Texture.class, game.assets.textureParameter);
      game.assets.manager.load("data/game/background/more_hills.png", Texture.class, game.assets.textureParameter);
      game.assets.manager.load("data/sounds/audio_on.mp3", Sound.class);
      cloudsPEffect = new ParticleEffect();
      cloudsPEffect.load(game.assets.resolver.resolve("data/animation/particles/clouds_emitter.p"), game.assets.resolver.resolve("data/clouds/default_1/"));
      cloudsPEffect.setPosition(Constants.MENU_CAMERA_WIDTH / 2, Constants.MENU_CAMERA_HEIGHT);
      cloudsPEffect.start();

      game.assets.manager.load("data/hud/lock.png", Texture.class, game.assets.textureParameter);
      exitDialog.loadAssets();
      settingsDialog.loadAssets();

  }
Box.java 文件源码 项目:SMC-Android 阅读 29 收藏 0 点赞 0 评论 0
private static Item createFireplant(Box box, boolean loadAssets, Assets assets)
{
    if(loadAssets)
    {
        assets.manager.load("data/animation/particles/box_activated.p", ParticleEffect.class, assets.particleEffectParameter);
        assets.manager.load("data/sounds/item/fireplant.mp3", Sound.class);
        assets.manager.load("data/game/items/fireplant.pack", TextureAtlas.class);
        assets.manager.load("data/animation/particles/fireplant_emitter.p", ParticleEffect.class, assets.particleEffectParameter);
    }
    else
    {
        Vector2 size = new Vector2(Fireplant.DEF_SIZE, Fireplant.DEF_SIZE);
        Vector3 pos = new Vector3(box.position);
        pos.x = box.position.x + box.mDrawRect.width * 0.5f - size.x * 0.5f;
        Fireplant fireplant = new Fireplant(box.world, size, pos);
        fireplant.initAssets();
        fireplant.visible = false;
        return fireplant;
    }
    return null;
}
Box.java 文件源码 项目:SMC-Android 阅读 29 收藏 0 点赞 0 评论 0
public static Item createMoon(World world, Vector3 position, boolean loadAssets, Assets assets, boolean initAssets)
{
    if(loadAssets)
    {
        assets.manager.load("data/animation/particles/box_activated.p", ParticleEffect.class, assets.particleEffectParameter);
        assets.manager.load("data/game/items/moon.pack", TextureAtlas.class);
        assets.manager.load("data/sounds/item/moon.mp3", Sound.class);
    }
    else
    {
        Moon moon = new Moon(world, new Vector2(Moon.DEF_SIZE, Moon.DEF_SIZE), new Vector3(position));
        if(initAssets)moon.initAssets();
        moon.visible = false;
        return moon;
    }

    return null;
}
Box.java 文件源码 项目:SMC-Android 阅读 29 收藏 0 点赞 0 评论 0
public static Item createStar(World world, Vector3 position, boolean loadAssets, Assets assets, boolean initAssets)
{
    if(loadAssets)
    {
        assets.manager.load("data/animation/particles/box_activated.p", ParticleEffect.class, assets.particleEffectParameter);
        assets.manager.load("data/game/items/star.png", Texture.class, assets.textureParameter);
    }
    else
    {
        Star star = new Star(world, new Vector2(Star.DEF_SIZE, Star.DEF_SIZE), new Vector3(position));
        if(initAssets)star.initAssets();
        star.visible = false;

        return star;
    }
    return null;
}
Assets.java 文件源码 项目:SMC-Android 阅读 27 收藏 0 点赞 0 评论 0
public Assets()
{
    textureParameter = new TextureLoader.TextureParameter();
    //textureParameter.genMipMaps = true;
    textureParameter.magFilter = Texture.TextureFilter.Linear;
    textureParameter.minFilter = Texture.TextureFilter.Linear;

    resolver = new MaryoFileHandleResolver();
    manager = new AssetManager(resolver);

    particleEffectParameter = new ParticleEffectLoader.ParticleEffectParameter();
    particleEffectParameter.imagesDir = resolver.resolve("data/animation/particles");

    // set the loaders for the generator and the fonts themselves
    manager.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(resolver));
    manager.setLoader(BitmapFont.class, ".ttf", new FreetypeFontLoader(resolver));
    manager.setLoader(ParticleEffect.class, ".p", new ParticleEffectLoader(resolver));
    manager.setLoader(Sound.class, ".mp3", new SoundLoader(new InternalFileHandleResolver()));
    manager.setLoader(Music.class, ".mp3", new MusicLoader(new InternalFileHandleResolver()));
}
ParticleRenderSystem.java 文件源码 项目:vis-editor 阅读 19 收藏 0 点赞 0 评论 0
@Override
protected void process (int entityId) {
    VisParticle particle = particleCm.get(entityId);
    Transform transform = transformCm.get(entityId);

    ParticleEffect effect = particle.getEffect();

    if (transform.isDirty()) {
        particle.updateValues(transform.getX(), transform.getY());
    }

    if (ignoreActive || particle.isActiveOnStart())
        effect.update(world.delta);

    effect.draw(batch);

    if (effect.isComplete())
        effect.reset();
}
EditorParticleInflater.java 文件源码 项目:vis-editor 阅读 19 收藏 0 点赞 0 评论 0
@Override
protected void inserted (int entityId) {
    AssetReference assetRef = assetCm.get(entityId);
    ProtoVisParticle protoComponent = protoCm.get(entityId);

    VisParticle particle = partcielCm.create(entityId);

    try {
        particle.setEffect(particleCache.get(assetRef.asset, 1f / pixelsPerUnit));
    } catch (EditorRuntimeException e) {
        Log.exception(e);
        particle.setEffect(new ParticleEffect());
        loadingMonitor.addFailedResource(assetRef.asset, e);
    }

    protoComponent.fill(particle);

    protoCm.remove(entityId);
}
GameParticleHandler.java 文件源码 项目:maze 阅读 29 收藏 0 点赞 0 评论 0
@Override
public void onRemoveTrailColor(MonsterColor color) {

    Maze maze = color.getMonster().getMaze();
    ParticleEffect effect = manager.create(Assets.getInstance().get(Assets.FLARE, ParticleEffect.class), false);
    float x = color.getX() * maze.getBlockSize() + maze.getX() + maze.getBlockSize() / 2;
    float y = color.getY() * maze.getBlockSize() + maze.getY() + maze.getBlockSize() / 2;

    effect.setPosition(x, y);

    manager.setColor(effect, new float[]{color.r, color.g, color.b}, new float[]{0f});
    effect.start();

    for (ParticleEmitter e : effect.getEmitters()) {
        e.getScale().setLow(Gdx.graphics.getWidth() / 30f);
        e.getDuration().setLow(Monster.LENGTH * StupidMonsterLogic.INTERVAL / 104);
        e.getLife().setLow(Monster.LENGTH * StupidMonsterLogic.INTERVAL / 140);
        e.getDuration().setLowMin(Monster.LENGTH * StupidMonsterLogic.INTERVAL / 140);
        e.getLife().setLowMin(Monster.LENGTH * StupidMonsterLogic.INTERVAL / 140);
        e.getVelocity().setLow(Gdx.graphics.getWidth() / 50f);
    }

    effects.put(color, effect);

    Gdx.input.vibrate(20);
}


问题


面经


文章

微信
公众号

扫码关注公众号