Partial on Android?I want to do animation.

Asked 2 years ago, Updated 2 years ago, 62 views

I'm sorry it's not a clear question, but
An animation on Android, for example, where petals flutter down on the screen?If I want to make particles, how can I make them?
Also, if you have any recommendations, please let me know.

The image is like this.
See also

I'd like to make something like fluttering petals when I open the screen.

android

2022-09-30 20:45

2 Answers

I have already received an answer, but how about using Animation?
In the example below, there is only one flower petal and only simple movement. Change Animation speed, movement, etc., multiple views, change movement per view,
I think you will be able to see it better by modifying the flower petal image to be realistic.

res/layout/activity_main.xml

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android: orientation="vertical">
    <ImageView
        android: id="@+id/hana_image"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android: src="@drawable/hana"/>
</LinearLayout>

res/anim/fall_anim.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
        android: duration="6000"
        android: fromXDelta="50%p"
        android: fromYDelta = "0%p"
        android: repeatCount="-1"
        android: repeatMode="restart"
        android:toXDelta="50%p"
        android:toYDelta="100% p"/>

    <translate
        android: duration="1000"
        android: fromXDelta="-150%"
        android: fromYDelta = "0%"
        android: repeatCount="-1"
        android:repeatMode="reverse"
        android:toXDelta="150%"
        android:toYDelta="0%"/>
</set>

res/drawable/hana.xml

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="#ffc0cb"/>
    <corners
        android:bottomLeftRadius="0dp"
        android:bottomRightRadius="40dp"
        android:topLeftRadius="40dp"
        android —topRightRadius="0dp"/>
</shape>

src/MainActivity.java

public class MainActivity extensions ActionBarActivity{

    @ Override
    protected void onCreate (Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Animation anim = AnimationUtils.loadAnimation(this, R.anim.fall_anim);
        ImageView imageView= (ImageView) v.findViewById (R.id.hana_image);
        imageView.startAnimation(anim);
    }
}


2022-09-30 20:45

The language will be C++ instead of Java, but how about using cocos2d-x v3?
http://www.cocos2d-x.org/

The cocos2d-x supports particles as standard.
The latest v3.5 also supports new 3D particles.

For specific implementation of particles on cocos2d-x, refer to the included cpp-test
You will find out by looking at .


2022-09-30 20:45

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.