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