If you think the Android project DolphinOES listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/*******************************************************************************
* Copyright 2015 See AUTHORS file./*www.java2s.com*/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/package com.sidereal.dolphinoes.behaviors.renderer.sprite;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.Vector2;
import com.sidereal.dolphinoes.behaviors.renderer.DrawerBuilder;
/** Builder for {@link SpriteDrawer}
*
* @author Claudiu Bele */publicclass SpriteBuilder extends DrawerBuilder<SpriteDrawer>
{
// region fields
private String filepath;
private Vector2 size;
private Vector2 offsetPosition;
private Vector2 origin;
privatefloat rotationDegrees;
private Color tintColor;
privatefloat transparency;
// endregion fields
// region constructors
public SpriteBuilder(String filepath)
{
super();
this.filepath = filepath;
this.transparency = 1;
}
// endregion constructors
// region methods
@Override
protected SpriteDrawer build(String name)
{
SpriteDrawer drawer = new SpriteDrawer(renderer, name, filepath);
if (size != null)
drawer.setSize(size.x, size.y);
if (offsetPosition != null)
drawer.setOffsetPosition(offsetPosition.x, offsetPosition.y);
if (origin != null)
drawer.setOrigin(origin.x, origin.y);
if (tintColor != null)
drawer.setColor(tintColor);
drawer.setRotation(rotationDegrees, false);
drawer.setTransparency(transparency, false);
return drawer;
}
// region setters and getters
public SpriteBuilder setSize(Vector2 size)
{
this.size = size;
returnthis;
}
public SpriteBuilder setSizeAndCenter(Vector2 size)
{
this.size = size;
this.offsetPosition = new Vector2(-size.x / 2, -size.y / 2);
returnthis;
}
public SpriteBuilder setOffsetPosition(Vector2 offsetPosition)
{
this.offsetPosition = offsetPosition;
returnthis;
}
public SpriteBuilder setOrigin(Vector2 origin)
{
this.origin = origin;
returnthis;
}
public SpriteBuilder setRotation(float rotationDegrees)
{
this.rotationDegrees = rotationDegrees;
returnthis;
}
public SpriteBuilder setColor(Color tintColor)
{
this.tintColor = tintColor;
returnthis;
}
public SpriteBuilder setTransparency(float transparency)
{
this.transparency = transparency;
returnthis;
}
// endregion
// endregion methods
}