Home > other >  Through a great god help write the angry birds deployment headaches
Through a great god help write the angry birds deployment headaches

Time:09-15

Through a great god help write the angry birds deployment headaches

CodePudding user response:

Public void startTopAndBoom (Boolean isStart) {


DataBean DataBean=new DataBean ();


DataBean. TopTopX=0;
DataBean. TopLiftX=this. GetRight ();
DataBean. TopRightX=this. GetRight (+ 200);

Held at the bottom of the//
DataBean. BoomBoomX=this. GetBottom ();
The e (" startTopAndBoom ", "onLayout:" + enclosing getBottom ());
DataBean. BoomLiftX=this. GetRight ();
DataBean. BoomRightX=this. GetRight (+ 200);

DataBean. TopLiftX=getRight ();
DataBean. TopRightX=getRight () + 200;

DataBean. BoomLiftX=getRight ();
DataBean. BoomRightX=getRight () + 200;

if (! IsStart)
If (arr. The size ()==0)
Arr. Add (dataBean);


If (isStart)
Arr. Add (dataBean);
Ran=new Random ();
Int Y=ran. NextInt (enclosing getBottom ());

The e (" - ", "startTopAndBoom:" + Y);
If (Y & lt; (this getBottom () - 500)) {
DataBean. TopBoomX=Y - 500;
DataBean. BoomTopX=Y;
//the e (" - ", "rectangle above under" + topBoomX + "--" + "under rectangular on the" + boomTopX);
} else if (Y & lt; 500) {
DataBean. TopBoomX=0;
DataBean. BoomTopX=500;
} else {
DataBean. TopBoomX=this. GetBottom () - 500;
DataBean. BoomTopX=this. GetBottom ();

}


}

All the code

Package com. Example. Downlist. View;

The import android. The content. The Context;
The import android. Graphics. BitmapFactory;
The import android. Graphics. Canvas;
The import android. Graphics. Color;
The import android. Graphics. Paint;
The import android. Util. AttributeSet;
The import android. Util. Log;
The import android. View. The view;
The import android. View. ViewGroup;

The import com. Example. Downlist. Utils. UIUtlis;

Import the Java. Util. ArrayList;
import java.util.Random;

/* *
* cynical way birds
*/

Public class XiaoNiaoView extends ViewGroup implements the View. An OnClickListener {


Private Boolean isStart=false;
ArrayList Arr=new ArrayList<> (a);

Private int niao=400;

Private int boomX=this. GetBottom ();//rectangular bottom

Private Paint Paint.
Private Random ran;
//judgment have hung
Private Boolean isLift=true;

//control thread speed
Private int threadGo=5;

The whereabouts of mark in the//
Private Boolean isUp=false;

//the falling speed
Private int luoxia=0;
//the bird on the left
Private int nLift;
//bird right
Private int nRight;
//integrator
Private int count;
//clicks
Private int thCount=0;

Public XiaoNiaoView Context (Context) {
super(context);
DrawRect ();
StartNiao ();
}

Public XiaoNiaoView (Context Context, AttributeSet attrs) {
super(context, attrs);
DrawRect ();
StartNiao ();
}

Public XiaoNiaoView (Context Context, AttributeSet attrs, int defStyleAttr) {
Super (context, attrs, defStyleAttr);
DrawRect ();
StartNiao ();

}

@ Override
B protected void onLayout (Boolean, int, int i1, int i2, int i3) {

NLift=(enclosing getRight ()/2) + 80.
NRight=(enclosing getRight ()/2) - 80;
StartTopAndBoom (false);

Enclosing setOnClickListener (this);


}

Public void startTopAndBoom (Boolean isStart) {


DataBean DataBean=new DataBean ();


DataBean. TopTopX=0;
DataBean. TopLiftX=this. GetRight ();
DataBean. TopRightX=this. GetRight (+ 200);

Held at the bottom of the//
DataBean. BoomBoomX=this. GetBottom ();
The e (" startTopAndBoom ", "onLayout:" + enclosing getBottom ());
DataBean. BoomLiftX=this. GetRight ();
DataBean. BoomRightX=this. GetRight (+ 200);

DataBean. TopLiftX=getRight ();
DataBean. TopRightX=getRight () + 200;

DataBean. BoomLiftX=getRight ();
DataBean. BoomRightX=getRight () + 200;

if (! IsStart)
If (arr. The size ()==0)
Arr. Add (dataBean);


If (isStart)
Arr. Add (dataBean);
Ran=new Random ();
Int Y=ran. NextInt (enclosing getBottom ());

The e (" - ", "startTopAndBoom:" + Y);
If (Y & lt; (this getBottom () - 500)) {
DataBean. TopBoomX=Y - 500;
DataBean. BoomTopX=Y;
//the e (" - ", "rectangle above under" + topBoomX + "--" + "under rectangular on the" + boomTopX);
} else if (Y & lt; 500) {
DataBean. TopBoomX=0;
DataBean. BoomTopX=500;
} else {
DataBean. TopBoomX=this. GetBottom () - 500;
DataBean. BoomTopX=this. GetBottom ();

}


}

//control bird thread

Public void startNiao () {
UIUtlis. RunOnThread (new Runnable () {
@ Override
Public void the run () {
While (isLift) {


Try {
Thread.sleep (threadGo);
{} catch InterruptedException (e)
e.printStackTrace();
}

If (isUp) {
Niao -=3;

If (niao & lt; Luoxia) {
IsUp=false;
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related