创建一个 Eclipse 游戏插件,第 2 部分: 构建和发射 BB 枪
2009-12-14 00:00:00 来源:WEB开发网
清单 1. 把视图捆绑到 OpenGL 代码public class ShootoutView extends ViewPart {
public static TableViewer viewer;
private boolean sceneRunning;
private Action action1;
...
gridData.horizontalAlignment = SWT.FILL;
viewer = new TableViewer(parent, SWT.MULTI |
SWT.H_SCROLL | SWT.V_SCROLL);
viewer.setContentProvider(new ViewContentProvider());
viewer.setLabelProvider(new ViewLabelProvider());
...
startGameButton.setText("Start Game");
startGameButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
try {
if(!ShootoutView.this.sceneRunning){
ShootoutView.this.scene =
new GameScene(ShootoutView.this.parent);
new Refresher(ShootoutView.this.scene).run();
ShootoutView.this.sceneRunning = true;
}
}
catch (Exception e) {
showMessage("startGameButton.widgetSelected()"+
":exception. " + e.getMessage());
e.printStackTrace();
}
}
});
更多精彩
赞助商链接