Updated Tutorial:Screen, colors and squares (markdown)

Hajime Hoshi 2016-12-28 11:37:49 +09:00
parent 72eac1c73a
commit d11b8498af

@ -186,21 +186,21 @@ Our text is covered by the new image. We'll need to set the position of the imag
# Image transforming
There's no position configuration in Ebiten, but you can get the same result by transforming your images. There are many ways to transform your images in Ebiten, but we'll only talk the basic `x`, `y` position translate in this chapter.
To put an image at a position as you like, there's only one way to specify geometry matrix when drawing an image. The geometry matrix is affine matrix and you can translate, enlarge or rotate the image with it.
What we need is to add the `translate` effect to the `option struct` by using `Translate(tx, ty float64)` function, `float64` is the floating point data type, and here're the two parameters that you'll need to pass to the function:
What we need is to add the `translate` effect to the `DrawImageOptions` struct by using `Translate(tx, ty float64)` function. `float64` is the floating point data type, and here're the two parameters that you'll need to pass to the function:
* `tx` Is the distance from the left, it's also called as the x offset.
* `ty` Is the distance from the top, and it's also called as the y offset.
* `tx` Is the distance from the left. It's also called as the x offset.
* `ty` Is the distance from the top. It's also called as the y offset.
So right now, let's add another code to tell the render function that we want to translate the new image while rendering it.
```go
// The previous empty option struct
opts := &ebiten.DrawImageOptions{}
// The previous empty option struct
opts := &ebiten.DrawImageOptions{}
// Add the Translate effect to the option struct.
opts.GeoM.Translate(64, 64)
// Add the Translate effect to the option struct.
opts.GeoM.Translate(64, 64)
```
Save your file, execute your game, and you'll see the new image is 64 pixels far from the top and the left of the screen.