-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'upstream-master' into multi-banners
- Loading branch information
Showing
76 changed files
with
1,917 additions
and
937 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,34 @@ | ||
package com.reco1l.andengine | ||
|
||
/** | ||
* The anchor points in the range of [0, 1]. | ||
*/ | ||
enum class Anchor(val factorX: Float, val factorY: Float) { | ||
import com.reco1l.framework.math.Vec2 | ||
|
||
TopLeft(0f, 0f), | ||
object Anchor { | ||
|
||
TopCenter(0.5f, 0f), | ||
@JvmField | ||
val TopLeft = Vec2(0f, 0f) | ||
|
||
TopRight(1f, 0f), | ||
@JvmField | ||
val TopCenter = Vec2(0.5f, 0f) | ||
|
||
CenterLeft(0f, 0.5f), | ||
@JvmField | ||
val TopRight = Vec2(1f, 0f) | ||
|
||
Center(0.5f, 0.5f), | ||
@JvmField | ||
val CenterLeft = Vec2(0f, 0.5f) | ||
|
||
CenterRight(1f, 0.5f), | ||
@JvmField | ||
val Center = Vec2(0.5f, 0.5f) | ||
|
||
BottomLeft(0f, 1f), | ||
@JvmField | ||
val CenterRight = Vec2(1f, 0.5f) | ||
|
||
BottomCenter(0.5f, 1f), | ||
@JvmField | ||
val BottomLeft = Vec2(0f, 1f) | ||
|
||
BottomRight(1f, 1f) | ||
@JvmField | ||
val BottomCenter = Vec2(0.5f, 1f) | ||
|
||
@JvmField | ||
val BottomRight = Vec2(1f, 1f) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.reco1l.andengine | ||
|
||
import javax.microedition.khronos.opengles.GL10 | ||
|
||
data class BlendInfo( | ||
|
||
/** | ||
* The blending function to use. | ||
*/ | ||
var function: BlendingFunction, | ||
|
||
/** | ||
* Whether to mask the red channel. | ||
*/ | ||
var redMask: Boolean = true, | ||
|
||
/** | ||
* Whether to mask the green channel. | ||
*/ | ||
var greenMask: Boolean = true, | ||
|
||
/** | ||
* Whether to mask the blue channel. | ||
*/ | ||
var blueMask: Boolean = true, | ||
|
||
/** | ||
* Whether to mask the alpha channel. | ||
*/ | ||
var alphaMask: Boolean = true, | ||
|
||
/** | ||
* Whether to clear the color buffer. | ||
*/ | ||
var clear: Boolean = false | ||
|
||
) { | ||
|
||
fun apply(gl: GL10) { | ||
|
||
gl.glColorMask(redMask, greenMask, blueMask, alphaMask) | ||
|
||
if (function != BlendingFunction.Inherit) { | ||
gl.glBlendFunc(function.source, function.destination) | ||
} | ||
|
||
if (clear) { | ||
gl.glClear(GL10.GL_COLOR_BUFFER_BIT) | ||
} | ||
} | ||
|
||
|
||
companion object { | ||
|
||
val Inherit = BlendInfo(BlendingFunction.Inherit) | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
package com.reco1l.andengine | ||
|
||
import com.reco1l.framework.math.Vec2 | ||
import com.reco1l.framework.math.Vec4 | ||
import org.anddev.andengine.entity.IEntity | ||
import org.anddev.andengine.entity.scene.CameraScene | ||
import org.anddev.andengine.entity.shape.IShape | ||
|
||
|
||
fun IEntity?.getPadding() = when (this) { | ||
is ExtendedEntity -> padding | ||
else -> Vec4.Zero | ||
} | ||
|
||
fun IEntity?.getPaddedWidth() = when (this) { | ||
is ExtendedEntity -> drawWidth - padding.horizontal | ||
is CameraScene -> camera.widthRaw | ||
is IShape -> width | ||
else -> 0f | ||
} | ||
|
||
fun IEntity?.getPaddedHeight() = when (this) { | ||
is ExtendedEntity -> drawHeight - padding.vertical | ||
is CameraScene -> camera.heightRaw | ||
is IShape -> height | ||
else -> 0f | ||
} | ||
|
||
|
||
/** | ||
* The size of the entity. | ||
* | ||
* When using the getter this will return the maximum value between the width and height or the same. | ||
* When using the setter this will set the width and height to the same value. | ||
*/ | ||
var ExtendedEntity.size | ||
get() = Vec2(width, height) | ||
set(value) { | ||
width = value.x | ||
height = value.y | ||
} | ||
|
||
|
||
/** | ||
* The total offset applied to the X axis. | ||
*/ | ||
val ExtendedEntity.totalOffsetX | ||
get() = originOffsetX + anchorOffsetX + translationX | ||
|
||
/** | ||
* The total offset applied to the Y axis. | ||
*/ | ||
val ExtendedEntity.totalOffsetY | ||
get() = originOffsetY + anchorOffsetY + translationY | ||
|
||
/** | ||
* The offset applied to the X axis according to the anchor factor. | ||
*/ | ||
val ExtendedEntity.anchorOffsetX: Float | ||
get() = parent.getPaddedWidth() * anchor.x | ||
|
||
/** | ||
* The offset applied to the Y axis according to the anchor factor. | ||
*/ | ||
val ExtendedEntity.anchorOffsetY: Float | ||
get() = parent.getPaddedHeight() * anchor.y | ||
|
||
/** | ||
* The offset applied to the X axis according to the origin factor. | ||
*/ | ||
val ExtendedEntity.originOffsetX: Float | ||
get() = -(drawWidth * origin.x) | ||
|
||
/** | ||
* The offset applied to the Y axis according to the origin factor. | ||
*/ | ||
val ExtendedEntity.originOffsetY: Float | ||
get() = -(drawHeight * origin.y) | ||
|
||
|
||
/** | ||
* Returns the draw width of the entity. | ||
*/ | ||
fun IEntity?.getDrawWidth(): Float = when (this) { | ||
is ExtendedEntity -> drawWidth | ||
is IShape -> width | ||
else -> 0f | ||
} | ||
|
||
/** | ||
* Returns the draw height of the entity. | ||
*/ | ||
fun IEntity?.getDrawHeight(): Float = when (this) { | ||
is ExtendedEntity -> drawHeight | ||
is IShape -> height | ||
else -> 0f | ||
} | ||
|
||
/** | ||
* Returns the draw X position of the entity. | ||
*/ | ||
fun IEntity?.getDrawX(): Float = when (this) { | ||
is ExtendedEntity -> drawX | ||
is IShape -> x | ||
else -> 0f | ||
} | ||
|
||
/** | ||
* Returns the draw Y position of the entity. | ||
*/ | ||
fun IEntity?.getDrawY(): Float = when (this) { | ||
is ExtendedEntity -> drawY | ||
is IShape -> y | ||
else -> 0f | ||
} | ||
|
||
/** | ||
* Attaches the entity to a parent. | ||
*/ | ||
infix fun <T : IEntity> T.attachTo(parent: IEntity): T { | ||
parent.attachChild(this) | ||
return this | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.