Load our vessel components by name now that we can.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1055 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: ScrollingTestApp.java,v 1.5 2002/02/19 20:03:13 mdb Exp $
|
// $Id: ScrollingTestApp.java,v 1.6 2002/02/19 22:08:25 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.miso.scene;
|
package com.threerings.miso.scene;
|
||||||
|
|
||||||
@@ -25,9 +25,10 @@ import com.threerings.media.sprite.MultiFrameImageImpl;
|
|||||||
import com.threerings.media.tile.TileManager;
|
import com.threerings.media.tile.TileManager;
|
||||||
import com.threerings.media.tile.bundle.BundledTileSetRepository;
|
import com.threerings.media.tile.bundle.BundledTileSetRepository;
|
||||||
|
|
||||||
|
import com.threerings.cast.CharacterComponent;
|
||||||
import com.threerings.cast.CharacterDescriptor;
|
import com.threerings.cast.CharacterDescriptor;
|
||||||
import com.threerings.cast.CharacterManager;
|
import com.threerings.cast.CharacterManager;
|
||||||
import com.threerings.cast.ComponentClass;
|
import com.threerings.cast.NoSuchComponentException;
|
||||||
import com.threerings.cast.bundle.BundledComponentRepository;
|
import com.threerings.cast.bundle.BundledComponentRepository;
|
||||||
|
|
||||||
import com.threerings.miso.Log;
|
import com.threerings.miso.Log;
|
||||||
@@ -83,7 +84,7 @@ public class ScrollingTestApp
|
|||||||
|
|
||||||
// create the various managers
|
// create the various managers
|
||||||
BundledComponentRepository crepo =
|
BundledComponentRepository crepo =
|
||||||
new BundledComponentRepository(rmgr, imgr, "ships");
|
new BundledComponentRepository(rmgr, imgr, "components");
|
||||||
CharacterManager charmgr = new CharacterManager(crepo);
|
CharacterManager charmgr = new CharacterManager(crepo);
|
||||||
charmgr.setCharacterClass(MisoCharacterSprite.class);
|
charmgr.setCharacterClass(MisoCharacterSprite.class);
|
||||||
|
|
||||||
@@ -92,23 +93,25 @@ public class ScrollingTestApp
|
|||||||
_frame.setPanel(_panel);
|
_frame.setPanel(_panel);
|
||||||
|
|
||||||
// create our "ship" sprite
|
// create our "ship" sprite
|
||||||
ComponentClass slclass = crepo.getComponentClass("smsloop");
|
String scclass = "navsail", scname = "smsloop";
|
||||||
Iterator cids = crepo.enumerateComponentIds(slclass);
|
try {
|
||||||
CharacterDescriptor desc = null;
|
CharacterComponent ccomp = crepo.getComponent(scclass, scname);
|
||||||
// there should be only one component in this class, which we use
|
CharacterDescriptor desc = new CharacterDescriptor(
|
||||||
// to create our character descriptor
|
new int[] { ccomp.componentId });
|
||||||
if (cids.hasNext()) {
|
|
||||||
int cid = ((Integer)cids.next()).intValue();
|
|
||||||
desc = new CharacterDescriptor(new int[] { cid });
|
|
||||||
}
|
|
||||||
|
|
||||||
// now create the actual sprite and stick 'em in the scene
|
// now create the actual sprite and stick 'em in the scene
|
||||||
MisoCharacterSprite s =
|
MisoCharacterSprite s =
|
||||||
(MisoCharacterSprite)charmgr.getCharacter(desc);
|
(MisoCharacterSprite)charmgr.getCharacter(desc);
|
||||||
if (s != null) {
|
if (s != null) {
|
||||||
s.setActionSequence(MisoCharacterSprite.STANDING);
|
s.setRestingAction("sailing");
|
||||||
s.setLocation(160 - s.getWidth()/2, 144 + s.getHeight()/2);
|
s.setActionSequence("sailing");
|
||||||
_panel.addSprite(s);
|
s.setLocation(160 - s.getWidth()/2, 144 + s.getHeight()/2);
|
||||||
|
_panel.addSprite(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (NoSuchComponentException nsce) {
|
||||||
|
Log.warning("Can't locate ship component [class=" + scclass +
|
||||||
|
", name=" + scname + "].");
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the scene to our scrolling scene
|
// set the scene to our scrolling scene
|
||||||
|
|||||||
Reference in New Issue
Block a user