植物大战僵尸向日葵
定义一个向日葵的类,向日葵每隔 10 秒产生的太阳也是一个类。
【文件 3-14】
.;
.;
.;
.;
.;
public class SunPlantextends ProductPlant {
publicSunPlant() {
super("image/plant/sunflower/");
life =100;
baseAction();
create();
}
***@Override
publicvoidcreate() {
//每隔 10 秒产生一个阳光
().schedule("create", this,10,false);
}
/**
* 产生阳光
* ***@paramf
*/
publicvoidcreate(float f) {
newSun((), , ccp(getPosition().x, getPosition().y + 40)
,ccp(getPosition().x+ 25,
25.
getPosition().y));
}
***@Override
publicvoidbaseAction() {
("image/plant/sunflower/p_1_%", 8
, true);
runAction(animate);
}
}
【文件 3-15】
.;
.;
.;
.;
.;
.;
.;
.;
.;
.;
.;
.;
.;
.;
.;
import ;
/**
*阳光
*/
public class Sunextends Product {
publicstaticfinal CopyOnWriteArrayList<Sun>suns= new
CopyOnWriteArrayList
安卓教程:植物大战僵尸向日葵 来自淘豆网m.daumloan.com转载请标明出处.