@Override public void Draw(GameTime gameTime) { _sprites.get(0).Draw((SpriteBatch) Game().GetService("SpriteBatch"), _position, Color.WHITE); Clicked.occur(!_isPanelButtonAdded); if (_isPanelButtonAdded) { _itemPanel.Draw(gameTime); } super.Draw(gameTime); }
@Override public void Update(GameTime gameTime) { _delayTime = TimeSpan.Add(_delayTime, gameTime.ElapsedGameTime()); if (_delayTime.miliseconds() <= 100) return; _delayTime = TimeSpan.Zero(); if (_isClicked) { _sprites.get(0).Update(); if (_sprites.get(0).FrameIndex() == 0) { Clicked.Add(DoClick.GetInstance(this)); _isClicked = false; } } super.Update(gameTime); }
@Override public void Initialize() { int id = Factory.getResourceID(_path, ResourceType.xml); XmlResourceParser xrp = _game.Resource().getXml(id); String tagName = ""; String value = ""; int numFrame; int frameWidth; int frameHeight; int xCenterPoint; int yCenterPoint; int bitmapResID; boolean isVertical; try { while (xrp.getEventType() != XmlResourceParser.END_DOCUMENT) { if (xrp.getEventType() == XmlResourceParser.START_TAG) { tagName = xrp.getName(); if (tagName.equals("Definition")) { numFrame = xrp.getAttributeIntValue(null, "NumFrame", 0); frameWidth = xrp.getAttributeIntValue(null, "FrameWidth", 0); frameHeight = xrp.getAttributeIntValue(null, "FrameHeight", 0); xCenterPoint = xrp.getAttributeIntValue(null, "XCenterPoint", 0); yCenterPoint = xrp.getAttributeIntValue(null, "YCenterPoint", 0); bitmapResID = xrp.getAttributeResourceValue(null, "SheetName", 0); isVertical = xrp.getAttributeBooleanValue(null, "IsVertical", false); Bitmap bmp = BitmapFactory.decodeResource(Game().Resource(), bitmapResID); _sprites.add( new Sprite( null, bmp, numFrame, new Vector2(frameWidth, frameHeight), new Vector2(xCenterPoint, yCenterPoint), isVertical)); } } if (xrp.getEventType() == XmlResourceParser.TEXT) { if (tagName.equals("Panel")) { value = xrp.getText(); if (value != "") { _itemPanel = new PanelButton(_game, _owner, value); } } } xrp.next(); } xrp.close(); } catch (XmlPullParserException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } super.Initialize(); }