• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Main repository of MikuMikuStudio


Commit MetaInfo

修訂06fe326423e2d1005b9a96248a10fc8b18460307 (tree)
時間2004-01-05 02:25:14
作者Anakan <Anakan@75d0...>
CommiterAnakan

Log Message

Scene controlling tests

git-svn-id: http://jmonkeyengine.googlecode.com/svn/trunk@193 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

Change Summary

差異

--- a/src/com/jme/test/demo/LoadingScene.java
+++ b/src/com/jme/test/demo/LoadingScene.java
@@ -36,12 +36,15 @@
3636 */
3737 package com.jme.test.demo;
3838
39+import java.util.logging.Level;
40+
3941 import com.jme.image.Texture;
4042 import com.jme.math.Vector3f;
4143 import com.jme.scene.Node;
4244 import com.jme.scene.Text;
4345 import com.jme.scene.state.AlphaState;
4446 import com.jme.scene.state.TextureState;
47+import com.jme.util.LoggingSystem;
4548 import com.jme.util.TextureManager;
4649 import com.jme.util.Timer;
4750
@@ -57,10 +60,11 @@ public class LoadingScene implements Scene {
5760 private Timer timer;
5861 private SceneEnabledGame demo;
5962 private Node loadingNode;
63+ private static boolean firstTime= true;
6064
6165 public void init(SceneEnabledGame game) {
6266 this.demo= game;
63- timer=game.getTimer();
67+ timer= game.getTimer();
6468 loadingNode= new Node();
6569 loadingNode.updateGeometricState(0.0f, true);
6670 text= new Text("Loading Scene");
@@ -68,7 +72,11 @@ public class LoadingScene implements Scene {
6872 TextureState ts= demo.getDisplaySystem().getRenderer().getTextureState();
6973 ts.setEnabled(true);
7074 ts.setTexture(
71- TextureManager.loadTexture("C:/eclipse/workspace/JavaMonkeyEngine/jme/data/Font/font.png", Texture.MM_LINEAR, Texture.FM_LINEAR, true));
75+ TextureManager.loadTexture(
76+ "C:/eclipse/workspace/JavaMonkeyEngine/jme/data/Font/font.png",
77+ Texture.MM_LINEAR,
78+ Texture.FM_LINEAR,
79+ true));
7280 text.setRenderState(ts);
7381 AlphaState as1= demo.getDisplaySystem().getRenderer().getAlphaState();
7482 as1.setBlendEnabled(true);
@@ -78,37 +86,36 @@ public class LoadingScene implements Scene {
7886 as1.setTestFunction(AlphaState.TF_GREATER);
7987 text.setRenderState(as1);
8088 loadingNode.attachChild(text);
81- status=LOAD_NEXT_SCENE;
82-
89+ status= READY;
90+
8391 }
8492
85-
86- public int getStatus() {
93+ public int getStatus() {
8794 return status;
8895 }
8996
90-
9197 public boolean update() {
9298 timeElapsed += timer.getTimePerFrame();
9399 if (timeElapsed > 1) {
94100 timeElapsed= 0;
95101 text.print(text.getText().toString() + ".");
102+
96103 }
97104 timer.update();
98105 return true;
99106 }
100107
101-
102108 public boolean render() {
109+ if (status == READY) {
110+ status= LOAD_NEXT_SCENE;
111+ }
103112 demo.getDisplaySystem().getRenderer().clearBuffers();
104113 demo.getDisplaySystem().getRenderer().draw(loadingNode);
105114 return true;
106115 }
107116
108-
109117 public void cleanup() {
110- // TODO Auto-generated method stub
111-
118+ loadingNode= null;
112119 }
113120
114121 /* (non-Javadoc)
@@ -125,13 +132,15 @@ public class LoadingScene implements Scene {
125132 return "com.jme.test.demo.SoundPlayingScene";
126133 }
127134
128-
129-
130135 /* (non-Javadoc)
131136 * @see com.jme.test.demo.Scene#setStatus(int)
132137 */
133138 public void setStatus(int status) {
134- this.status=status;
139+ this.status= status;
140+ }
141+
142+ public void finalize() {
143+ LoggingSystem.getLogger().log(Level.INFO, "Finalizing " + getClass().getName());
135144 }
136145
137146 }
--- a/src/com/jme/test/demo/SceneController.java
+++ b/src/com/jme/test/demo/SceneController.java
@@ -36,6 +36,10 @@
3636 */
3737 package com.jme.test.demo;
3838
39+import java.util.logging.Level;
40+
41+import com.jme.util.LoggingSystem;
42+
3943 /**
4044 * @author Arman Ozcelik
4145 *
@@ -70,18 +74,20 @@ public class SceneController {
7074
7175 public void update() {
7276 game.getInput().update(1);
77+ if (playingScene.getStatus() == Scene.LOAD_NEXT_SCENE) {
78+ playingScene.setStatus(Scene.LOADING_NEXT_SCENE);
79+ preloadNextScene();
80+ }
7381 if (playingScene.getStatus() == Scene.READY
7482 || playingScene.getStatus() == Scene.LOAD_NEXT_SCENE
7583 || playingScene.getStatus() == Scene.LOADING_NEXT_SCENE) {
7684 playingScene.update();
7785 }
78- if (playingScene.getStatus() == Scene.LOAD_NEXT_SCENE) {
79- playingScene.setStatus(Scene.LOADING_NEXT_SCENE);
80- preloadNextScene();
81- }
8286 if (nextScene != null) {
8387 nextScene.update();
8488 if (nextScene.getStatus() == Scene.READY) {
89+ playingScene.cleanup();
90+ LoggingSystem.getLogger().log(Level.INFO, "Cleaning " + playingScene.getClass().getName());
8591 playingScene= nextScene;
8692 nextScene= null;
8793 }
@@ -94,26 +100,24 @@ public class SceneController {
94100 }
95101
96102 public void preloadNextScene() {
97- if (!preloadStarted) {
98- preloadStarted= true;
99- Runnable r= new Runnable() {
100- public void run() {
101- try {
102- nextScene= (Scene)Class.forName(playingScene.getLinkedSceneClassName()).newInstance();
103- } catch (InstantiationException e) {
104- e.printStackTrace();
105- } catch (IllegalAccessException e) {
106- e.printStackTrace();
107- } catch (ClassNotFoundException e) {
108- e.printStackTrace();
109- }
110- nextScene.init(game);
111103
104+ Runnable r= new Runnable() {
105+ public void run() {
106+ try {
107+ nextScene= (Scene)Class.forName(playingScene.getLinkedSceneClassName()).newInstance();
108+ } catch (InstantiationException e) {
109+ e.printStackTrace();
110+ } catch (IllegalAccessException e) {
111+ e.printStackTrace();
112+ } catch (ClassNotFoundException e) {
113+ e.printStackTrace();
112114 }
113- };
114- Thread t= new Thread(r);
115- t.start();
116- }
115+ nextScene.init(game);
116+
117+ }
118+ };
119+ Thread t= new Thread(r);
120+ t.start();
117121
118122 }
119123
--- a/src/com/jme/test/demo/SoundPlayingScene.java
+++ b/src/com/jme/test/demo/SoundPlayingScene.java
@@ -36,6 +36,10 @@
3636 */
3737 package com.jme.test.demo;
3838
39+
40+
41+import java.util.logging.Level;
42+
3943 import com.jme.entity.Entity;
4044 import com.jme.image.Texture;
4145 import com.jme.math.Vector3f;
@@ -47,6 +51,8 @@ import com.jme.sound.IEffectPlayer;
4751 import com.jme.sound.IRenderer;
4852 import com.jme.sound.utils.EffectRepository;
4953 import com.jme.sound.utils.OnDemandSoundLoader;
54+
55+import com.jme.util.LoggingSystem;
5056 import com.jme.util.TextureManager;
5157 import com.jme.util.Timer;
5258
@@ -71,7 +77,9 @@ public class SoundPlayingScene implements Scene {
7177
7278 private int status;
7379
74- boolean toRight= true, ascending= true;
80+ private boolean toRight= true, ascending= true;
81+
82+
7583
7684 public void init(SceneEnabledGame game) {
7785 this.game= game;
@@ -128,11 +136,16 @@ public class SoundPlayingScene implements Scene {
128136 return false;
129137 }
130138 if (EffectRepository.getRepository().getSource(backgroundMusic.getId()) != null) {
131- status= READY;
139+ status=READY;
132140 } else {
133141 return false;
134142 }
135143 timer.update();
144+ timeElapsed+=timer.getTimePerFrame();
145+ if(timeElapsed>5 && status !=LOAD_NEXT_SCENE){
146+ timeElapsed=0;
147+ status=LOAD_NEXT_SCENE;
148+ }
136149 if (soundRenderer.getSoundPlayer(backgroundMusic).getStatus() != IEffectPlayer.LOOPING) {
137150 soundRenderer.getSoundPlayer(backgroundMusic).loop(
138151 EffectRepository.getRepository().getSource(backgroundMusic.getId()));
@@ -151,8 +164,7 @@ public class SoundPlayingScene implements Scene {
151164 toRight= true;
152165 ascending=true;
153166 }
154- }
155-
167+ }
156168 soundRenderer.getSoundPlayer(backgroundMusic).setPosition(soundPosition);
157169 text.print("Position " + soundPosition);
158170 return true;
@@ -171,8 +183,9 @@ public class SoundPlayingScene implements Scene {
171183 * @see com.jme.test.demo.Scene#cleanup()
172184 */
173185 public void cleanup() {
174- // TODO Auto-generated method stub
175-
186+ soundRenderer.getSoundPlayer(backgroundMusic).stop();
187+ EffectRepository.getRepository().remove(backgroundMusic.getId());
188+ soundNode=null;
176189 }
177190
178191 /* (non-Javadoc)
@@ -187,8 +200,7 @@ public class SoundPlayingScene implements Scene {
187200 * @see com.jme.test.demo.Scene#getLinkedSceneClassName()
188201 */
189202 public String getLinkedSceneClassName() {
190- // TODO Auto-generated method stub
191- return null;
203+ return "com.jme.test.demo.LoadingScene";
192204 }
193205
194206 /* (non-Javadoc)
@@ -197,5 +209,10 @@ public class SoundPlayingScene implements Scene {
197209 public void setStatus(int status) {
198210 this.status= status;
199211 }
200-
212+
213+ public void finalize(){
214+ LoggingSystem.getLogger().log(
215+ Level.INFO,
216+ "Finalizing "+getClass().getName());
217+ }
201218 }