public void animate() { switch (shieldType) { case REDBALL: float beta = 0.0f; float coeff = 1.0f; for (CompositeElement composite : composites) { composite.animate(); Element elem = composite.getRefElement(); elem.x = (int) (affected.x + 5 * Math.sin((alpha * alpha + beta) * coeff)); elem.y = (int) (affected.y + 10 + 2 * Math.cos((alpha + beta) * coeff)); elem.z = 20; // - beta * 10; elem.y -= elem.getSprModel().getTaille_y() / 2; elem.setAjustedX((int) elem.x); elem.setAjustedY((int) elem.y); beta += 0.8f; // gamma; //0.9;//Math.PI / 4; coeff *= -1f; } alpha += 0.1; gamma += 0.2; break; } }
// ///////////////////////////////////////////////////////////////////////////////////// // spawnElement // ///////////////////////////////////////////////////////////////////////////////////// // IN:nBank, nSpr, x, y // ///////////////////////////////////////////////////////////////////////////////////// // Spawn an element with minimal requirements // -build an element with given parameters // -add it to the sprite engine public Element spawnElement( int nBank, int nSpr, int x, int y, int z, Reverse reverse, Rotation rotation) { // SpriteEntity informations Element element; if (nBank == SpriteBank.BANK_GEAR) { element = new ElementGear(x, y); element.setAjustedX(x); element.setAjustedY(y); } else { element = new Element(); } element.setX(x); element.setY(y); element.setZ(z); element.setNSpr(nSpr); element.setNBank(nBank); element.reverse = reverse; element.rotation = rotation; spawnSprite(element); return element; }