elm-graphics icon indicating copy to clipboard operation
elm-graphics copied to clipboard

Cropped image takes place of image if cropped image is first

Open lethjakman opened this issue 8 years ago • 0 comments

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)

lethjakman avatar Sep 08 '16 04:09 lethjakman