java - Hide Image until a value is given -


i making app , have working somewhat, thankfully know problem is. have sprite moves around border , want sprite shoot ball @ particular spot. currently, app displays ball @ position (0,0) , shoots on when supposed to. adding 10 x in update method animation, can speed slow down changing 10. variable x , y have default of 0. change them specified above. want them remain 0 default not want ball display until moving. right displays ball on startup, , moves. want display ball once give x , y values.

here snippet of current code.

        // moves ball down right side of screen         if (x > ov.getwidth() - width - xspeed){             xspeed = 0;             yspeed = 10;             direction = 1;             shootl(); // shoots ball left towards left side of screen          }                // moves ball screen on left side         if (x + xspeed < 0){             x = 0;             xspeed = 0;             yspeed = -10;             direction = 3;             shootr();  // shoots ball towards right side of screen         }       private void shootr() {         // todo auto-generated method stub         // need manipulate variable q go across screen         q += 10;            // manipulate r shoots @ right spot on screen, not major problem right now.      }       private void shootl() {         // todo auto-generated method stub         // need manipulate variable q go across screen         q += -10;            // manipulate r shoots @ right spot on screen, not major problem right now.     }       public void ondraw(canvas canvas) {         // todo auto-generated method stub         update();         int srcy = direction * height;         rect src = new rect (0, srcy, width, srcy + height);         rect dst = new rect (x, y, x+width, y+height);         canvas.drawbitmap(b, src,  dst, null); // draws sprite around border         paint p = new paint();         canvas.drawbitmap(fire, q, r, p); // draws ball shoots across       }    

anyone have ideas or suggestions? displaying ball @ wrong time , need fix this. must error or something.

wow, clueless. figured out. had changing of coordinates in update method called in ondraw method. ondraw method went through every line of code , called again updating 1 @ time. adding if statement in ondraw , removing changing of q in update , moving if statement didnt draw until if true.

i drawing before changing. need change variables, , draw!


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -