Skip to content

Latest commit

 

History

History
64 lines (31 loc) · 1.12 KB

File metadata and controls

64 lines (31 loc) · 1.12 KB

Kotlin Avanzado > Sesión 01 > Reto 1

Reto 1: Animators

1. Objetivos 🎯

  • Aplicar el conocimiento de Animators

2. Requisitos 📋

  1. Android Studio Instalado en nuestra computadora.

3. Desarrollo 💻

Al pulsar sobre cualquier parte de nuestro Constraint Layout (excepto botones o el mismo arwing), mover la nave a dicho punto, centrando el punto con su centro.

Solucion

private fun moveAnywhere(event: MotionEvent): Boolean{

        if (event.action === MotionEvent.ACTION_DOWN) {
            val x = event.x - arwing.width/2
            val y = event.y - arwing.height/2

            Toast.makeText(this, "valor: $y", Toast.LENGTH_SHORT).show()

            arwing.animate().apply {
                x(x)
                y(y)
                duration = 1000
                interpolator = AccelerateInterpolator()
                start()
            }

        }

    return true
}

Anterior | Siguiente