Updated to work with new media architecture.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1477 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: ScrollingTestApp.java,v 1.14 2002/06/11 00:04:43 mdb Exp $
|
||||
// $Id: ScrollingTestApp.java,v 1.15 2002/06/18 22:38:55 mdb Exp $
|
||||
|
||||
package com.threerings.miso.scene;
|
||||
|
||||
@@ -20,9 +20,12 @@ import com.threerings.resource.ResourceManager;
|
||||
import com.threerings.media.FrameManager;
|
||||
import com.threerings.media.ImageManager;
|
||||
|
||||
import com.threerings.media.sprite.Sprite;
|
||||
import com.threerings.media.sprite.MultiFrameImage;
|
||||
import com.threerings.media.sprite.MultiFrameImageImpl;
|
||||
import com.threerings.media.sprite.PathCompletedEvent;
|
||||
import com.threerings.media.sprite.Sprite;
|
||||
import com.threerings.media.sprite.SpriteEvent;
|
||||
import com.threerings.media.sprite.SpriteObserver;
|
||||
|
||||
import com.threerings.media.tile.bundle.BundledTileSetRepository;
|
||||
import com.threerings.media.util.LinePath;
|
||||
@@ -94,22 +97,7 @@ public class ScrollingTestApp
|
||||
charmgr.setCharacterClass(MisoCharacterSprite.class);
|
||||
|
||||
// create our scene view panel
|
||||
_panel = new SceneViewPanel(_framemgr, new IsoSceneViewModel()) {
|
||||
protected void viewFinishedScrolling () {
|
||||
// keep scrolling for a spell
|
||||
if (++_sidx < DX.length) {
|
||||
int x = _viewmodel.bounds.width/2,
|
||||
y = _viewmodel.bounds.height/2;
|
||||
LinePath path = new LinePath(
|
||||
x, y, x + DX[_sidx], y + DY[_sidx], 3000l);
|
||||
setPath(path);
|
||||
}
|
||||
}
|
||||
protected int _sidx = -1;
|
||||
protected final int[] DX = { 162, 0, 1000, -1000, 1000, 2000 };
|
||||
protected final int[] DY = { 140, 1000, 0, 1000, -1000, 1000 };
|
||||
};
|
||||
_panel.setScrolling(0, 1000, 3000l);
|
||||
_panel = new SceneViewPanel(_framemgr, new IsoSceneViewModel());
|
||||
_frame.setPanel(_panel);
|
||||
|
||||
// create our "ship" sprite
|
||||
@@ -120,13 +108,14 @@ public class ScrollingTestApp
|
||||
new int[] { ccomp.componentId }, null);
|
||||
|
||||
// now create the actual sprite and stick 'em in the scene
|
||||
MisoCharacterSprite s =
|
||||
(MisoCharacterSprite)charmgr.getCharacter(desc);
|
||||
if (s != null) {
|
||||
s.setRestingAction("sailing");
|
||||
s.setActionSequence("sailing");
|
||||
s.setLocation(160, 144);
|
||||
_panel.addSprite(s);
|
||||
_ship = (MisoCharacterSprite)charmgr.getCharacter(desc);
|
||||
if (_ship != null) {
|
||||
_ship.setFollowingPathAction("sailing");
|
||||
_ship.setRestingAction("sailing");
|
||||
_ship.setActionSequence("sailing");
|
||||
_ship.setLocation(_panel.getModel().bounds.width/2,
|
||||
_panel.getModel().bounds.height/2);
|
||||
_panel.addSprite(_ship);
|
||||
}
|
||||
|
||||
} catch (NoSuchComponentException nsce) {
|
||||
@@ -134,6 +123,28 @@ public class ScrollingTestApp
|
||||
", name=" + scname + "].");
|
||||
}
|
||||
|
||||
_ship.addSpriteObserver(new SpriteObserver() {
|
||||
public void handleEvent (SpriteEvent event) {
|
||||
if (event instanceof PathCompletedEvent) {
|
||||
// keep scrolling for a spell
|
||||
if (++_sidx < DX.length) {
|
||||
int x = _ship.getX(), y = _ship.getY();
|
||||
LinePath path = new LinePath(
|
||||
x, y, x + DX[_sidx], y + DY[_sidx], 30000l);
|
||||
_ship.move(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
protected int _sidx = -1;
|
||||
protected final int[] DX = { 1620, 0, 1000, -1000, 1000, 2000 };
|
||||
protected final int[] DY = { 1400, 1000, 0, 1000, -1000, 1000 };
|
||||
});
|
||||
|
||||
// make the panel follow the ship around
|
||||
_panel.setFollowsPathable(_ship);
|
||||
int x = _ship.getX(), y = _ship.getY();
|
||||
_ship.move(new LinePath(x, y, x, y + 1000, 3000l));
|
||||
|
||||
// set the scene to our scrolling scene
|
||||
try {
|
||||
_panel.setScene(new ScrollingScene(ctx));
|
||||
@@ -205,4 +216,7 @@ public class ScrollingTestApp
|
||||
|
||||
/** The main panel. */
|
||||
protected SceneViewPanel _panel;
|
||||
|
||||
/** The ship in the center of our screen. */
|
||||
protected MisoCharacterSprite _ship;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
//
|
||||
// $Id: ViewerSceneViewPanel.java,v 1.49 2002/05/31 07:34:11 mdb Exp $
|
||||
// $Id: ViewerSceneViewPanel.java,v 1.50 2002/06/18 22:38:55 mdb Exp $
|
||||
|
||||
package com.threerings.miso.viewer;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
@@ -53,6 +53,7 @@ public class ViewerSceneViewPanel extends SceneViewPanel
|
||||
|
||||
// create the manipulable sprite
|
||||
_sprite = createSprite(_spritemgr, charmgr, _descUser);
|
||||
setFollowsPathable(_sprite);
|
||||
|
||||
// create the decoy sprites
|
||||
createDecoys(_spritemgr, charmgr);
|
||||
@@ -123,9 +124,9 @@ public class ViewerSceneViewPanel extends SceneViewPanel
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void paintBetween (Graphics2D g, Rectangle[] dirty)
|
||||
public void paint (Graphics g)
|
||||
{
|
||||
super.paintBetween(g, dirty);
|
||||
super.paint(g);
|
||||
PerformanceMonitor.tick(this, "paint");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user