I want to have a screen with snowflakes falling (in the spirit of the
Holiday Season) and the snow building in the bottom of the screen. So
far all I have been able to do is show a lone white dot on the black
screen. What should I do to make another 100 or 1000 of those dots and
make them float down to the bottom of the screen just like real
snowflakes?


import android.app.Activity;
import android.os.Bundle;
import java.util.Random;


public class DroidSnowGlobe extends Activity{

        Random generator = new Random();
        @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    snowview sv = new snowview(this);

    setContentView(sv);
     while (true) {
        int x = generator.nextInt(100) +1;
        int y = generator.nextInt(100) +1;
        sv.changepos(x, y); //Does not work at all
        setContentView(sv);
    }
    }
}












snowview class:

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.OvalShape;
import android.view.View;
import java.util.Random;

public class snowview extends View{

        Random generator = new Random();

            private ShapeDrawable mDrawable;

            public snowview(Context context) {
                super(context);


                int x = generator.nextInt(100) +1;
                int y = generator.nextInt(100) +1;
                int width = 3;
                int height = 3;
                mDrawable = new ShapeDrawable(new OvalShape());
                mDrawable.getPaint().setColor(Color.WHITE);
                mDrawable.setBounds(x, y, x + width, y + height);


            }

            protected void onDraw(Canvas canvas) {
                mDrawable.draw(canvas);

            }

            public void changepos(int x, int y){
                int width = 3;
                int height = 3;
                mDrawable.setBounds(x, y, x + width, y + height);

            }

        }


-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to