hi people i'm doing conect4 , want circle fall since pixel number 200 example correspondent pixel or row. did before animations in xml , know how animate canvas didn't find question translate circle make sensation falling. sorry if mi english bad i'm 1 of bachillerato student of spain. did ontocuh , ondraw methods :
public class myview extends view { public myview(context context) { super(context); } public void caidaficha () { valueanimator caidaficha = objectanimator.ofint(this,"caida",200,1000); caidaficha.setduration(10000); caidaficha.setevaluator(new intevaluator()); caidaficha.setrepeatcount(valueanimator.infinite); caidaficha.setrepeatmode(valueanimator.reverse); caidaficha.start(); } public void ondraw(canvas canvas) { super.ondraw(canvas); int x = getwidth(); int y = getheight(); anchox = x; anchoy = y; paint paint = new paint(); paint.setstyle(paint.style.fill); paint.setcolor(color.blue); canvas.drawpaint(paint); /*texto*/ paint.setcolor(color.black); paint.settextsize(80); canvas.drawtext("conecta 4", 70, 130, paint); /*separador*/ paint.setcolor(color.parsecolor("#5c5c5c")); canvas.drawrect(0, 200, 600, 210, paint); /*tablero*/ int radius = 25; (int = 0; < game.nfilas; i++) (int j = 0; j < game.ncolumnas; j++){ if (game.estavacio(i,j)){ color = color.white; paint.setcolor(color); canvas.drawcircle(getpixelfromcolumna(j), getpixelfromfila(i), radius, paint); } else if (game.estajugador(i,j)){ paint.setcolor(coloreado); canvas.drawcircle(getpixelfromcolumna(j), getpixelfromfila(i), radius, paint); } else { color = color.red; paint.setcolor(color); canvas.drawcircle(getpixelfromcolumna(j),getpixelfromfila(i), radius, paint); } } } public boolean ontouchevent(motionevent event) { int fila; int columna; int pixel_x; int pixel_y; if(event.getaction() == motionevent.action_down) { pixel_x = (int) event.getx(); pixel_y = (int) event.gety(); fila = getfila(pixel_y); columna = getcolumna(pixel_x); if (game.tablerolleno()) { toast.maketext(getapplicationcontext(), r.string.fin_del_juego, toast.length_long).show(); } if (game.sepuedecolocarficha(fila, columna) != true) { toast.maketext(getapplicationcontext(), r.string.nosepuedecolocarficha, toast.length_short).show(); return false; } if(pixel_y > 200){ game.ponerjugador(fila, columna); if(game.comprobarcuatro(game.jugador)){ toast.maketext(getapplicationcontext(), "ha ganado " + nombrefinal, toast.length_long).show(); if(game.fin()) { fragmento_dialogo dialogo = new fragmento_dialogo(); dialogo.show(getfragmentmanager(), "alert dialog"); } } game.juegamaquina(); if(game.comprobarcuatro(game.maquina)){ toast.maketext(getapplicationcontext(), "has perdido " + nombrefinal, toast.length_long).show(); if(game.fin()) { fragmento_dialogo dialogo = new fragmento_dialogo(); dialogo.show(getfragmentmanager(), "alert dialog"); } } } } invalidate(); return true; } }
Comments
Post a Comment