I have a game over text bu6t I am trying to make it so when a timer gets to 90 seconds it appears.
this is my code that i am using it is in the my world editor
it says that the addObject "int cannot be differenced and the (timeCount == 90) is says bad oprands types for binary oporator
this is the whole code
1 2 3 4 5 | if (timeCount == 90 ) { GameOver gameover = new GameOver(); myWorld. addObject(gameover, myWorld, getWidth()/ 2 , getHeight()/ 2 ); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | import greenfoot.Actor; import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class MyWorld here. * * @author (your name) * @version (a version number or a date) */ public class MyWorld extends World { int cookieSpawnTimer = 50 ; public static int score = 0 ; int resetscore = 0 ; SimpleTimer tim = new SimpleTimer(); Counter timeCount = new Counter(); private Actor gameover; int myWorld; /** * Constructor for objects of class MyWorld. * */ public MyWorld() { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super ( 873 , 479 , 1 ); prepare(); addObject(timeCount, 809 , 21 ); tim.mark(); } /** * Prepare the world for the start of the program. * That is: create the initial objects and add them to the world. */ private void prepare() { score = resetscore; grany grany = new grany(); addObject(grany, 432 , 399 ); } public void act() { cookieSpawnTimer --; showText( "Cookies : " + score, 75 , 25 ); if (cookieSpawnTimer == 0 ) { Actor coookie; coookie Coookie = new coookie(); addObject( new coookie(),(Greenfoot.getRandomNumber( 873 )), 0 ); cookieSpawnTimer = 30 ; } timeCount.setValue(tim.millisElapsed()/ 1000 ); if (timeCount == 90 ) { GameOver gameover = new GameOver(); myWorld. addObject(gameover, myWorld, getWidth()/ 2 , getHeight()/ 2 ); } } } |