add Preload() into Scene class
This commit is contained in:
parent
48cfca9f63
commit
b9331d87a8
@ -1,8 +1,12 @@
|
||||
package dothack;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.microedition.lcdui.Display;
|
||||
import javax.microedition.midlet.MIDlet;
|
||||
|
||||
import sillysagiri.Sagiri;
|
||||
import sillysagiri.scene.Intro;
|
||||
import sillysagiri.scene.MainMenu;
|
||||
|
||||
public class DotHack extends MIDlet implements Runnable {
|
||||
public DotHackC game;
|
||||
@ -21,6 +25,13 @@ public class DotHack extends MIDlet implements Runnable {
|
||||
thread = new Thread(this);
|
||||
thread.setPriority(Thread.MAX_PRIORITY);
|
||||
thread.start();
|
||||
|
||||
try {
|
||||
sagiri.Set_Scene(new Intro());
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void pauseApp() {}
|
||||
|
@ -144,13 +144,6 @@ public class DotHackC extends Canvas {
|
||||
state_main = 9;
|
||||
bool_preload = true;
|
||||
counter100 = -1;
|
||||
|
||||
try {
|
||||
sagiri.Set_Scene(new Intro());
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void paint(Graphics g)
|
||||
@ -3167,6 +3160,7 @@ public class DotHackC extends Canvas {
|
||||
this.bgG.drawImage(Image.createImage("/t_2.png"), 2, 84, 20);
|
||||
this.bgG.drawImage(Image.createImage("/t_3.png"), 1, 125, 20);
|
||||
this.bgG.drawImage(Image.createImage("/t_4.png"), 1, 1, 20);
|
||||
|
||||
} else if (paramInt == 11) {
|
||||
this.bgG.setColor(255, 109, 0);
|
||||
this.bgG.fillRect(0, 0, 120, 133);
|
||||
@ -3174,7 +3168,9 @@ public class DotHackC extends Canvas {
|
||||
for (byte b = 0; b < 7; b++)
|
||||
this.bgG.drawImage(image, 0, 1 + b * 20, 20);
|
||||
this.bgG.drawImage(Image.createImage("/c_0.png"), 48, 50, 20);
|
||||
} else if (paramInt == 20) {
|
||||
}
|
||||
|
||||
else if (paramInt == 20) {
|
||||
this.bgG.setColor(255, 109, 0);
|
||||
this.bgG.fillRect(0, 0, 120, 133);
|
||||
Image image = Image.createImage("/m_2.png");
|
||||
|
@ -27,10 +27,20 @@ public class Sagiri
|
||||
|
||||
public void Update(Graphics g)
|
||||
{
|
||||
input.Update();
|
||||
if (_scene_current != null)
|
||||
{
|
||||
|
||||
while (!_scene_current.preloaded)
|
||||
{
|
||||
_scene_current.preloaded = true;
|
||||
_scene_current.Preload();
|
||||
}
|
||||
|
||||
_scene_current.Update(time_delta, g);
|
||||
}
|
||||
input.Update();
|
||||
|
||||
}
|
||||
|
||||
public Scene Get_Scene() { return _scene_current; }
|
||||
public void Set_Scene(Scene scene)
|
||||
|
@ -3,11 +3,17 @@ package sillysagiri;
|
||||
import javax.microedition.lcdui.Graphics;
|
||||
|
||||
public abstract class Scene {
|
||||
protected Sagiri sagiri;
|
||||
public boolean preloaded = false;
|
||||
|
||||
public Scene()
|
||||
{
|
||||
if (Sagiri._instance != null)
|
||||
sagiri = Sagiri._instance;
|
||||
}
|
||||
|
||||
// override this
|
||||
public abstract void Preload();
|
||||
public abstract void Destroy();
|
||||
public abstract void Update(long dt, Graphics g);
|
||||
|
||||
|
@ -21,10 +21,15 @@ public class Intro extends Scene {
|
||||
|
||||
public Intro() throws IOException
|
||||
{
|
||||
super();
|
||||
|
||||
img_logo = Image.createImage("/t_1.png");
|
||||
img_ez = Image.createImage("/pEZ.png");
|
||||
}
|
||||
|
||||
public void Preload() {
|
||||
}
|
||||
|
||||
public void Destroy()
|
||||
{
|
||||
img_logo = null;
|
||||
@ -103,12 +108,17 @@ public class Intro extends Scene {
|
||||
g.drawImage(img_project, 5, Utils.GetScreenHeight()-5, Graphics.LEFT | Graphics.BOTTOM);
|
||||
g.drawImage(img_vol1, 5, 5, Graphics.LEFT | Graphics.TOP);
|
||||
|
||||
if (counter >= 1000) counter = 0;
|
||||
if (counter < 600)
|
||||
if (counter >= 600) counter = 0;
|
||||
if (counter < 400)
|
||||
g.drawImage(
|
||||
img_ez,
|
||||
Utils.GetScreenWidth()/2, (int)(Utils.GetScreenHeight()*0.75),
|
||||
Graphics.VCENTER | Graphics.HCENTER);
|
||||
|
||||
if (sagiri.input.IsKeyDownAny())
|
||||
{
|
||||
sagiri.Set_Scene(new MainMenu());
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user