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
if (timeCount == 90)
{
GameOver gameover = new GameOver();
myWorld. addObject(gameover, myWorld, getWidth()/2, getHeight()/2);
}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);
}
}
}
