elm-graphics
elm-graphics copied to clipboard
Cropped image takes place of image if cropped image is first
If you have a cropped image sitting in front of at image in an array that will be passed to collage, the image sitting after the un-cropped image will become the cropped image after a second (which happens to be the time period in which the cropped image is alternating.) The cropped images animation will also be inverted from the cropped image. Perhaps this is because the cropped image is alternating vertically?
view : Model -> Html Msg
view model =
let
{state, player, enemies} = model
{width, height} = model.size
backgroundCollage = [background]
enemyCollage = formEnemies enemies
playerCollage = [make player]
collageData = backgroundCollage ++ playerCollage ++ enemyCollage -- Enemy image will appear for a second and then it becomes the player image. If you swap player and enemy the bug goes away
in
toHtml <|
container width height middle <|
collage gameWidth gameHeight collageData
background =
toForm <| image gameWidth gameHeight "/assets/background.jpg"
formEnemies enemies =
map enemyToForm enemies
enemyToForm enemy =
toForm (image 100 100 "/assets/enemy-sprite.png")
|> move (enemy.x, enemy.y)
make : Player -> Form
make obj =
let
size = 100
sprite = size * obj.spriteNum
in
toForm (croppedImage (0,sprite) size size "/assets/player-sprite.png")
|> move (obj.x, obj.y)