protected void onStart() { Log.v("ThemeDetailedActivity", "onStart"); super.onStart(); if (!SceneManager.getInstance().FindThemes(theme.componentName.getPackageName())) { finish(); } }
@Override public void onBackKeyPressed() { SharedPreferences.Editor editor = recordPref.edit(); editor.putInt("RECORD", record); editor.apply(); SceneManager.getInstance().loadMenuScene(engine); birdArray.clear(); plumageArray.clear(); }
public void onCreate(Bundle bundle) { Log.v("ThemeDetailedActivity", "onCreate"); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); super.onCreate(bundle); requestWindowFeature(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); sdactivity = this; mThemeDetailed = new SceneDetailed(this); Bundle extras = getIntent().getExtras(); index = extras.getInt(SceneDetailedActivity.class.getSimpleName()); if (index >= SceneManager.getInstance().getThemeDescriptions().size()) { finish(); } else { theme = SceneManager.getInstance().getThemeDescriptions().elementAt(index); if (!SceneManager.getInstance().FindThemes(theme.componentName.getPackageName())) { finish(); } else { SceneManager.getInstance().pushActivity(this); setContentView(mThemeDetailed); mThemeDetailed.LoadData(index); } } }
public boolean ccTouchesMoved(MotionEvent event) { if (event.getPointerCount() > 1) { currentItem = null; CGPoint current1 = CGPoint.make(event.getX(0), event.getY(0)); CGPoint current2 = CGPoint.make(event.getX(1), event.getY(1)); float before = getDistance(multi1, multi2); float current = getDistance(current1, current2); changeScale(current - before); multi1 = current1; multi2 = current2; } else { if (firstPt != null) { CGPoint convertedLocation = CCDirector.sharedDirector().convertToGL(CGPoint.make(event.getX(), event.getY())); CGPoint current = getPosition(); if (currentItem != null && GameStatus.isShowRoundMenu && isMoving) { currentItem.moveBy(convertedLocation.x - beforePt.x, convertedLocation.y - beforePt.y); SceneManager.getInstance() .interfaceLayer .moveByRoundMenu(convertedLocation.x - beforePt.x, convertedLocation.y - beforePt.y); } else { setPosition( current.x + (convertedLocation.x - beforePt.x), current.y + (convertedLocation.y - beforePt.y)); if (GameStatus.isShowRoundMenu) { SceneManager.getInstance() .interfaceLayer .moveByRoundMenu( convertedLocation.x - beforePt.x, convertedLocation.y - beforePt.y); } } beforePt = convertedLocation; } } return true; }
private void touched(CGPoint pt) { MapItemController item = null; int len = list.size(); for (int i = 0; i < len; i++) { item = list.get(i); if (item.checkDown(pt)) { currentItem = item; break; } } if (currentItem != null) { if (GameStatus.isMapEditMode) { CGPoint worldConvert = CGPoint.zero(); CGPoint itempt = currentItem.getImage().getPositionRef(); this.convertToWorldSpace(itempt.x, itempt.y, worldConvert); Log.i("maplayer_touched", "check"); SceneManager.getInstance().interfaceLayer.showRoundMenu(worldConvert); } else { // if deco -> show tooltip // else if crop -> harvest. } } }
/** * The main function of the game. Something fun starts here. :) * * @param args passed command line arguments. */ public static void main(String[] args) { if (!Resource.getInstance().initialize()) { JOptionPane.showMessageDialog( null, "Resource loading fail.", "Cannot open game", JOptionPane.ERROR_MESSAGE); return; } if (!LevelFileManager.getInstance().initialize()) { JOptionPane.showMessageDialog( null, "Level files loading fail.", "Cannot open game", JOptionPane.ERROR_MESSAGE); return; } // Create JFrame JFrame frame = new JFrame(Constants.PROGRAM_NAME); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // frame.setResizable(false); frame.setMinimumSize(Constants.MINIMUM_WINDOW_SIZE); frame .getContentPane() .addComponentListener( new ComponentListener() { @Override public void componentShown(ComponentEvent arg0) {} @Override public void componentResized(ComponentEvent arg0) { DrawManager.getInstance() .setCanvasSize( frame.getContentPane().getWidth(), frame.getContentPane().getHeight()); } @Override public void componentMoved(ComponentEvent arg0) {} @Override public void componentHidden(ComponentEvent arg0) {} }); if (Constants.IS_FULLSCREEN) { frame.setUndecorated(true); frame.setExtendedState(JFrame.MAXIMIZED_BOTH); } else { frame.getContentPane().setPreferredSize(Constants.DEFAULT_SCREEN_SIZE); frame.pack(); } InputManager.setListenerTo(frame); frame.getContentPane().setBackground(ColorSwatch.BACKGROUND); frame.setVisible(true); // Add canvas to the frame DrawManager.getInstance().addCanvasInto(frame); DrawManager.getInstance() .setCanvasSize(frame.getContentPane().getWidth(), frame.getContentPane().getHeight()); // Set initial scene SceneManager.getInstance().setNextScene(new scene.mainmenu.MainMenuScene(true)); // SceneManager.getInstance().setNextScene(new stage.GameStage(GameStageType.PLAY)); // Game looper final long maximumWaitTime = 1000000000 / Constants.MAX_FRAME_PER_SECOND; long updateTime; Resource.getInstance().themeSong.loop(); while (true) { // Perform a game update (including game logic and painting) updateTime = System.nanoTime(); SceneManager.getInstance().update(); updateTime = System.nanoTime() - updateTime; if (updateTime < maximumWaitTime) { FPSCollector.add(Constants.MAX_FRAME_PER_SECOND); } else { FPSCollector.add(Math.round(1000000000 / updateTime)); } // Perform sleeping to limit maximum FPS if (updateTime < maximumWaitTime) { try { Thread.sleep((maximumWaitTime - updateTime) / 1000000); } catch (InterruptedException e) { Thread.interrupted(); e.printStackTrace(); } } } }
protected void onDestroy() { super.onDestroy(); mThemeDetailed.Release(); SceneManager.getInstance().popupActivity(this); Log.v("ThemeDetailedActivity", "onDestroy"); }
public void manualScreen() { SceneManager.getInstance().loadManualScene(m_engine); }