This site requires JavaScript, please enable it in your browser!
Greenfoot back
Tryshot
Tryshot wrote ...

2017/4/2

Tennisball: cannot find symbol- method getPlayer()

Tryshot Tryshot

2017/4/2

#
Hey, I wanted to program a tennis match with Greenfoot, but I can't find the error :( private void moveBall(){ if(pScore == 5) { Ball = ((MarioWorld)getWorld()).getPlayer().getPlayer(); locationX = 350; locationY = 300; acceleration = 0; setImage("Tennisball.png"); }else if(cScore == 5){ Ball = ((MarioWorld)getWorld()).getComputer().getBaby(); locationX = 350; locationY = 300; acceleration = 0; setImage("Tennisball.png"); }else if ((locationY > 560) ){ locationX = 350 + (acceleration * Math.cos((Math.PI * 3.1/ 2))); locationY = 300 + (acceleration * Math.sin((Math.PI * 3.1/ 2))); cScore = cScore + 1; setImage("Tennisball.png"); }else if((locationY < 20)){ locationX = 350 + (acceleration * Math.cos((Math.PI * 3.1/ 2))); locationY = 300 + (acceleration * Math.sin((Math.PI * 3.1/ 2))); pScore = pScore + 1; setImage("Tennisball.png"); }else if((getX() == 350) && (getY() == 300)){ acceleration = -15; angle = (Math.PI * 3.1/ 2); locationX = getX() + (acceleration * Math.cos(angle)); locationY = getY() + (acceleration * Math.sin(angle)); setImage("Tennisball.png"); }else if(this.hitLSide() || this.hitRSide()){ angle = (Math.PI * 3.1/ 2); locationX = 350 + (acceleration * Math.cos((angle))); locationY = 300 + (acceleration * Math.sin((angle))); setImage("Tennisball.png"); if(getY() < 300){ pScore = pScore + 1; }else{ cScore = cScore + 1; }; }else if (isHitRacket()){ this.bounceRacket(); }else{ locationX = getX() + (acceleration * Math.cos(angle)); locationY = getY() + (acceleration * Math.sin(angle)); setImage("Tennisball.png"); } }
Super_Hippo Super_Hippo

2017/4/2

#
Please use code tags. In line 3, you use getPlayer twice. Is that wanted?
You need to login to post a reply.