Crackersanimator is a particle system library that works with the standard Android UI

Overview

Crackersanimator

Crackersanimator is a particle system library that works with the standard Android UI. This library build from https://github.com/plattysoft/Leonids library but make some update to support for latest version of android.

Platform API

Screen

Android Studio / gradle Add the following dependency to the build.gradle of your project

  1. Add the Crackersanimator dependency

    dependencies {
            implementation 'com.github.Suyash171:crackersanimator:2.1'
    }
    
    

Download

Gradle

  1. Define the jitpack remote Maven repository inside the repositories block of your root build.gradle file
allprojects {
   	repositories {
   		...
   		maven { url 'https://jitpack.io' }
   	}
   }

Creating and firing a one-shot particle system is very easy, just 3 lines of code.

Why this library? Particle systems are often used in games for a wide range of purposes: Explosions, fire, smoke, etc. This effects can also be used on normal apps to add an element of "juiciness" or Playful Design.

Precisely because its main use is games, all engines have support for particle systems, but there is no such thing for standard Android UI.

This means that if you are building an Android app and you want a particle system, you have to include a graphics engine and use OpenGL -which is quite an overkill- or you have to implement it yourself.

Crackersanimator is made to fill this gap, bringing particle sytems to developers that use the standard Android UI

Note that the ParticleSystem checks the position of the anchor view when oneShot (or emit) is called, so it requires the views to be measured. This means that ParticleSystem won't work properly if you call oneShot or emit during onCreate. For more information check the comments on issue #22.

When you create the particle system, you tell how many particles will it use as a maximum, the resourceId of the drawable you want to use for the particles and for how long the particles will live.

Then you configure the particle system. In this case we specify that the particles will have a speed between 0.2 and 0.5 pixels per milisecond (support for dips will be included in the future). Since we did not provide an angle range, it will be considered as "any angle".

Finally, we call oneShot, passing the view from which the particles will be launched and saying how many particles we want to be shot.

Usage

  new ParticleSystem(this, numParticles, drawableResId, timeToLive)
.setSpeedRange(0.2f, 0.5f)
.oneShot(anchorView, numParticles);


Finally, we call oneShot, passing the view from which the particles will be launched and saying how many particles we want to be shot.



Emitters
You can configure emitters, which have a constant ratio of particles being emited per second. This is the code for the Confeti example


new ParticleSystem(this, 80, R.drawable.confeti2, 10000)
.setSpeedModuleAndAngleRange(0f, 0.3f, 180, 180)
.setRotationSpeed(144)
.setAcceleration(0.00005f, 90)
.emit(findViewById(R.id.emiter_top_right), 8);

new ParticleSystem(this, 80, R.drawable.confeti3, 10000)
.setSpeedModuleAndAngleRange(0f, 0.3f, 0, 0)
.setRotationSpeed(144)
.setAcceleration(0.00005f, 90)
.emit(findViewById(R.id.emiter_top_left), 8);

It uses an initializer for the Speed as module and angle ranges, a fixed speed rotaion and extenal acceleration.


#Available Methods
List of the methods available on the class ParticleSystem.

Supported drawables are: BitmapDrawable and AnimationDrawable.

* _ParticleSystem(Activity a, int maxParticles, int drawableRedId, long timeToLive)_
* _ParticleSystem(Activity a, int maxParticles, Drawable drawable, long timeToLive)_
* _ParticleSystem(Activity a, int maxParticles, Bitmap bitmap, long timeToLive)_
* _ParticleSystem(Activity a, int maxParticles, AnimationDrawable animation, long timeToLive)_

There are also constructors that recieve a view id to use as the parent so you can put the particle system on the background (or between any two views)

* _ParticleSystem(Activity a, int maxParticles, int drawableRedId, long timeToLive, int parentViewId)_
* _ParticleSystem(Activity a, int maxParticles, Drawable drawable, long timeToLive, int parentViewId)_
* _ParticleSystem(Activity a, int maxParticles, Bitmap bitmap, long timeToLive, int parentViewId)_
* _ParticleSystem(Activity a, int maxParticles, AnimationDrawable animation, long timeToLive, int parentViewId)_

And another constructor that receives a parent viewgroup and drawable for use in places where it is not practical to pass a reference to an Activity

* _ParticleSystem(ViewGroup parentView, int maxParticles, Drawable drawable, long timeToLive)_

### Configuration

Available methods on the Particle system for configuration are:

* _setSpeedRange(float speedMin, float speedMax)_: Uses 0-360 as the angle range
* _setSpeedModuleAndAngleRange(float speedMin, float speedMax, int minAngle, int maxAngle)_
* _setSpeedByComponentsRange(float speedMinX, float speedMaxX, float speedMinY, float speedMaxY)_
* _setInitialRotationRange (int minAngle, int maxAngle)_
* _setScaleRange(float minScale, float maxScale)_
* _setRotationSpeed(float rotationSpeed)_
* _setRotationSpeedRange(float minRotationSpeed, float maxRotationSpeed)_
* _setAcceleration(float acceleration, float angle)_
* _setFadeOut(long milisecondsBeforeEnd, Interpolator interpolator)_: Utility method for a simple fade out effect using an interpolator
* _setFadeOut(long duration)_:Utility method for a simple fade out

You can start the particle system "in the future" if you want to have the particles already created and moving using

_setStartTime(int time)_

For more complex modifiers, you can use the method _addModifier(ParticleModifier modifier)_. Available modifiers are:

* _AlphaModifier (int initialValue, int finalValue, long startMilis, long endMilis)_
* _AlphaModifier (int initialValue, int finalValue, long startMilis, long endMilis, Interpolator interpolator)_
* _ScaleModifier (float initialValue, float finalValue, long startMilis, long endMilis)_
* _ScaleModifier (float initialValue, float finalValue, long startMilis, long endMilis, Interpolator interpolator)_

### One shot

Make one shot using from the anchor view using the number of particles specified, an interpolator is optional

* _oneShot(View anchor, int numParticles)_
* _oneShot(View anchor, int numParticles, Interpolator interpolator)_

### Emitters

Emits the number of particles per second from the emitter. If emittingTime is set, the emitter stops after that time, otherwise it is continuous.

#### Basic emitters
* _emit (View emitter, int particlesPerSecond)_
* _emit (View emitter, int particlesPerSecond, int emittingTime)_

#### Emit based on (x,y) coordinates
* _emit (int emitterX, int emitterY, int particlesPerSecond)_
* _emit (int emitterX, int emitterY, int particlesPerSecond, int emitingTime)_

#### Emit with Gravity 
* _emitWithGravity (View emiter, int gravity, int particlesPerSecond)_
* _emitWithGravity (View emiter, int gravity, int particlesPerSecond, int emitingTime)_
 
#### Update, stop, and cancel
* _updateEmitPoint (int emitterX, int emitterY)_ Updates dynamically the point of emission.
* _updateEmitPoint (View emiter, int gravity)_ Updates dynamically the point of emission using gravity.
* _stopEmitting ()_ Stops the emission of new particles, but the active ones are updated.
* _cancel ()_ Stops the emission of new particles and cancles the active ones.

## Other details


The library is Free Software, you can use it, extended with no requirement to open source your changes. You can also make paid apps using it.

Each Particle System only uses one image for the particles. If you want different particles to be emitted, you need to create a Particle System for each one of them.


# Author

[Suyash Raikar](https://github.com/Suyash171)


# Credits
https://github.com/plattysoft
You might also like...

An android application to make students life easier by reducing their backpack weight.

An android application to make students life easier by reducing their backpack weight.

Smart-Schooling An android application to make students life easier by reducing their backpack weight. Dont forget to ⭐ the repo Overview Almost every

Jan 31, 2022

A todo app with Alan AI smart voice assistant android application

A todo app with Alan AI smart voice assistant android application

Todo App A todo app with Alan AI smart voice assistant android application. Experience a hands-free voice app where you can add, edit, delete and make

Jan 26, 2022

RealmeDirac - an open-source Android application written in java

RealmeDirac - an open-source Android application written in java

RealmeDirac is an open-source Android application written in java. RealmeDirac is a feature introduced by realme & dirac in realmeUI for sound optimisation, trying to recreate same thing, this is scratch written app aiming to provide same features as realmeDirac..

Feb 21, 2022

Java XML library. A really cool one. Obviously.

XMLBeam This is a Java XML library with an extraordinary expressive API. By using XPath for read and write operations, many operations take only one l

Aug 25, 2022

icecream-java is a Java port of the icecream library for Python.

icecream-java is a Java port of the icecream library for Python.

Apr 7, 2022

This library provides facilities to match an input string against a collection of regex patterns.

This library provides facilities to match an input string against a collection of regex patterns. This library acts as a wrapper around the popular Chimera library, which allows it to be used in Java.

Oct 26, 2022

Apache OpenNLP library is a machine learning based toolkit for the processing of natural language text

Welcome to Apache OpenNLP! The Apache OpenNLP library is a machine learning based toolkit for the processing of natural language text. This toolkit is

Dec 29, 2022

Java serialization library, proto compiler, code generator

Java serialization library, proto compiler, code generator

A java serialization library with built-in support for forward-backward compatibility (schema evolution) and validation. efficient, both in speed and

Dec 23, 2022

Discord IPC - Pure Java 16 library

Pure Java 16 library for interacting with locally running Discord instance without the use of JNI.

Nov 14, 2022
Owner
null
CodeLocator is a toolset that includes Android SDK and Android Studio plugins

CodeLocator is a toolset that includes Android SDK and Android Studio plugins. It has the following functions(Support Mac Only):

Bytedance Inc. 948 Jan 5, 2023
Cordova plugin for Android Serial USB communication (easily connect an Arduino board to an Android device).

PR-DC cordova-plugin-serialusb Cordova plugin for Android Serial USB communication. This plugin makes a connection to the external board trivial, for

PR-DC 3 May 8, 2022
STxMobile is a proof of concept of an Android app for remotely controlling the Raymarine ST2000+ tiller pilot from an Android phone.

STxMobile is a proof of concept of an Android app for remotely controlling the Raymarine ST2000+ tiller pilot from an Android phone.

Marco 8 Sep 1, 2022
An in-memory file system for Java 7+

Jimfs Jimfs is an in-memory file system for Java 7 and above, implementing the java.nio.file abstract file system APIs. Getting started The latest rel

Google 2.2k Jan 3, 2023
ONLINE DYNAMIC UNIVERSITY VOTING SYSTEM

WEVOTE ONLINE DYNAMIC UNIVERSITY VOTING SYSTEM Online university voting system is developed as a web-based application using html for front-end design

null 3 May 7, 2021
A super simple system for easily creating messages and putting them in in a file, whilst also being able to add replacements without struggle.

A super simple system for easily creating messages and putting them in in a file, whilst also being able to add replacement values without struggle. Please remember: Give constructive feedback, not negative feedback. There are probably a million things to improve, and I am aware of that.

Solyze 2 Sep 21, 2021
Leveraging Java 8, create an API with a multi-tier user system.

Project 0 Description Leveraging Java 8, create an API with a multi-tier user system. You may choose the actual use case for your application as long

null 1 Jan 9, 2022
This is a Blog & Report System with Java, JSP, AJAX

Blog-Report-System-in-Java This is a Blog & Report System with Java, JSP, AJAX Java project based on JDBC, JSP, Java Servlet & Server Deployment Proje

Muhammad Asad 5 Feb 2, 2022
An open source, modular alternative of sketchware. Create your own app in android using block programming like scratch!

OpenBlocks An open source, modular alternative of sketchware. Create your own app in android using block programming like scratch! What is OpenBlocks?

OpenBlocks 30 Dec 16, 2022
An easy to use Hindi keyboard Android app

AasaanHindi-Keyboard-app An easy to use Hindi keyboard Android app. Easy and fast Hindi typing.

Ankit Kumar 1 Jan 20, 2022