Greenfoot最終クラスのプロジェクトでは、 "Doggie the Super Catcher"というゲームを作ることにしました。このゲームが基本的にしているのは、俳優のDoggieが、画面上を前後に走ることで木から落ちているようなクローバーや特別扱いを捕まえることです(ユーザーの左右矢印キーボード入力、もちろん)。しかし、私は複数のレベルを作成したいと思っています。そして、私は、第一世界(GameWorldという名前)がレベル1に現れることを望んでいます。これは別の世界にあります。私はどうしたらいいのですか?言い換えれば、特定の条件が満たされた場合(すなわち、特定のポイント数に達した場合)、同じことをGameWorldからLevel1に転送することはできません。レベル1には、クローバー、キャンディー、スコアボードが含まれます。参考:私はスコアボードのために別の俳優を使用しました。あなたの誰かが方法を知っていますか?ありがとう。同じ内容を別のGreenfootワールドに表示
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
public class Doggie extends Actor
{
// Declare arrays of Greenfoot images for animation
private GreenfootImage[] runningLeft;
private GreenfootImage[] runningRight;
// Declare Greenfoot images for standing still facing left and right
private GreenfootImage standingStill;
private GreenfootImage standingLeft;
private GreenfootImage standingRight;
//
boolean facingLeft;
// Integers that help control the speed of movement and animation
private int animationCounter;
private int animationDelay;
private int animationDelayCounter;
private int animationSpeed;
Clover c;
SpecialTreat1 c1;
SpecialTreat2 c2;
public Doggie()
{
String fileName;
String fileNamePrefix = "left0";
String fileNameSuffix = ".png";
runningLeft = new GreenfootImage[3];
runningRight = new GreenfootImage[3];
for (int imageCounter = 0; imageCounter < runningLeft.length; imageCounter++)
{
fileName = fileNamePrefix + (imageCounter + 1) + fileNameSuffix;
runningLeft[imageCounter] = new GreenfootImage(fileName);
runningRight[imageCounter] = new GreenfootImage (runningLeft[imageCounter]);
runningRight[imageCounter].mirrorHorizontally();
}
standingStill = new GreenfootImage ("still01.png");
standingLeft = new GreenfootImage ("left01.png");
standingRight = new GreenfootImage (standingLeft);
standingRight.mirrorHorizontally();
facingLeft = true;
animationSpeed = 5;
animationDelay = 6;
animationDelayCounter = 0;
animationCounter = 0;
}
/**
* Act - do whatever the Doggie wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
animationDelayCounter++;
if (animationDelayCounter == animationDelay)
{
animationCounter++;
animationDelayCounter = 0;
}
if (animationCounter > runningRight.length - 1)
animationCounter = 0;
c = (Clover)getOneIntersectingObject(Clover.class);
c1 = (SpecialTreat1)getOneIntersectingObject(SpecialTreat1.class);
c2 = (SpecialTreat2)getOneIntersectingObject(SpecialTreat2.class);
if (c != null)
{
c.collect();
GameWorld gW = (GameWorld)getWorld();
gW.showPoints();
}
if (c1 != null)
{
c1.collect();
GameWorld gW = (GameWorld)getWorld();
gW.showPoints();
}
if (c2 != null)
{
c2.collect();
GameWorld gW = (GameWorld)getWorld();
gW.showPoints();
}
}
public void runLeft()
{
if (!(facingLeft))
animationCounter = 0;
facingLeft = true;
setImage (runningLeft[animationCounter]);
setLocation (getX() - animationSpeed, getY());
}
public void runRight()
{
if (facingLeft)
animationCounter = 0;
facingLeft = false;
setImage (runningRight[animationCounter]);
setLocation (getX() + animationSpeed, getY());
}
public void standStill()
{
if (facingLeft)
{
setImage(standingLeft);
}
else
setImage(standingRight);
animationCounter = 0;
animationDelayCounter = 0;
}
}
を助け、申し訳ありませんが、私はまだ、このコードにコメントしていない
希望:レベル1のメソッドのこの種が含まれます。 :( –