smaller textures.

This commit is contained in:
Bryce Covert
2017-05-26 12:48:07 -07:00
parent d8a145bb67
commit 3ee134f062
34 changed files with 174 additions and 90 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -1,58 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>duration</key>
<real>1</real>
</dict>
<dict>
<key>duration</key>
<real>1</real>
</dict>
<dict>
<key>duration</key>
<real>1</real>
</dict>
<dict>
<key>duration</key>
<real>1</real>
</dict>
<dict>
<key>duration</key>
<real>1</real>
</dict>
<dict>
<key>duration</key>
<real>1</real>
</dict>
<dict>
<key>duration</key>
<real>1</real>
</dict>
<dict>
<key>duration</key>
<real>1</real>
</dict>
<dict>
<key>duration</key>
<real>1</real>
</dict>
<dict>
<key>duration</key>
<real>1</real>
</dict>
<dict>
<key>duration</key>
<real>1</real>
</dict>
<dict>
<key>duration</key>
<real>1</real>
</dict>
<dict>
<key>duration</key>
<real>1</real>
</dict>
</array>
</plist>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -1,13 +1,125 @@
global.png
size: 64,32
size: 1024,64
format: RGBA8888
filter: Nearest,Nearest
repeat: none
black
rotate: false
xy: 2, 2
xy: 530, 38
size: 32, 24
orig: 32, 24
offset: 0, 0
index: -1
close
rotate: false
xy: 530, 20
size: 16, 16
orig: 16, 16
offset: 0, 0
index: -1
inventory
rotate: false
xy: 2, 6
size: 42, 56
orig: 42, 56
offset: 0, 0
index: -1
open-inventory-1
rotate: false
xy: 2, 6
size: 42, 56
orig: 42, 56
offset: 0, 0
index: -1
open-inventory-11
rotate: false
xy: 398, 6
size: 42, 56
orig: 42, 56
offset: 0, 0
index: -1
open-inventory-12
rotate: false
xy: 442, 6
size: 42, 56
orig: 42, 56
offset: 0, 0
index: -1
open-inventory-13
rotate: false
xy: 486, 6
size: 42, 56
orig: 42, 56
offset: 0, 0
index: -1
open-inventory-2
rotate: false
xy: 46, 6
size: 42, 56
orig: 42, 56
offset: 0, 0
index: -1
open-inventory-3
rotate: false
xy: 90, 6
size: 42, 56
orig: 42, 56
offset: 0, 0
index: -1
open-inventory-4
rotate: false
xy: 134, 6
size: 42, 56
orig: 42, 56
offset: 0, 0
index: -1
open-inventory-5
rotate: false
xy: 178, 6
size: 42, 56
orig: 42, 56
offset: 0, 0
index: -1
open-inventory-6
rotate: false
xy: 222, 6
size: 42, 56
orig: 42, 56
offset: 0, 0
index: -1
open-inventory-7
rotate: false
xy: 266, 6
size: 42, 56
orig: 42, 56
offset: 0, 0
index: -1
open-inventory-8
rotate: false
xy: 310, 6
size: 42, 56
orig: 42, 56
offset: 0, 0
index: -1
open-inventory-10
rotate: false
xy: 310, 6
size: 42, 56
orig: 42, 56
offset: 0, 0
index: -1
open-inventory-9
rotate: false
xy: 354, 6
size: 42, 56
orig: 42, 56
offset: 0, 0
index: -1
save
rotate: false
xy: 530, 2
size: 16, 16
orig: 16, 16
offset: 0, 0
index: -1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 117 B

After

Width:  |  Height:  |  Size: 5.9 KiB

View File

@@ -1478,7 +1478,6 @@
(tween/tween :fade-out screen [:fade :opacity] 0.0 1.0 1.0
:finish #(do
(utils/stop-all-sounds! %)
(asset-manager! @(resolve 'advent.core/am) :clear)
(set-screen! @(resolve 'advent.core/advent) @(resolve 'advent.screens.title/title-screen))
%))))))
@@ -1848,7 +1847,8 @@
:on-show
(fn [screen entities options]
(let [screen (assoc screen :total-time 0)
(let [[screen global-atlas] (utils/acquire-atlas screen "packed/global.atlas")
screen (assoc screen :total-time 0)
screen (utils/setup-viewport screen 320 240)]
@@ -1860,29 +1860,29 @@
:pending-states []}
:already-saved? false
:close (assoc (utils/get-texture "close.png")
:close (assoc (utils/atlas->texture global-atlas "close")
:x 320 :y 240
:origin-x 16 :origin-y 16
:width 16 :height 16
:scale-x utils/ui-scale :scale-y utils/ui-scale
:baseline 9000
:opacity 0.8)
:save (assoc (utils/get-texture "save.png")
:save (assoc (utils/atlas->texture global-atlas "save")
:x (- 320 (* utils/ui-scale 16) 4) :y 240
:origin-x 16 :origin-y 16
:width 16 :height 16
:baseline 9000
:opacity 0.8)
:inventory (assoc (utils/get-texture "inventory.png") :x (* 21 utils/ui-scale ) :y (* 27 utils/ui-scale ) :baseline 9000
:inventory (assoc (utils/atlas->texture global-atlas "inventory") :x (* 21 utils/ui-scale ) :y (* 27 utils/ui-scale ) :baseline 9000
:intersect-width 42 :intersect-height 48
:width 42 :height 56
:origin-x 21 :origin-y 27
:scale-x utils/ui-scale :scale-y utils/ui-scale
:open (utils/flip (doto (utils/make-anim-seq "open-inventory" [42 56] 0.055 (flatten [(range 6) 6 7 8 7 ]))
(animation! :set-play-mode (play-mode :normal))))
:anim (utils/flip (utils/make-anim "inventory.png" [42 56] 0.1 [0]))
:anim (utils/flip (utils/make-anim global-atlas "inventory" [42 56] 0.1 [0]))
:anim-loop? false
:default (utils/flip (utils/make-anim "inventory.png" [42 56] 0.1 [0]))
:default (utils/flip (utils/make-anim global-atlas "inventory" [42 56] 0.1 [0]))
:opened (utils/flip (utils/make-anim-seq "open-inventory" [42 56] 0.1 [7]))
:closing (utils/flip (doto (utils/make-anim-seq "open-inventory" [42 56] 0.055 [7 7 7 7 7 7 7 9 10 11 12 0])
(animation! :set-play-mode (play-mode :normal))))
@@ -2050,4 +2050,7 @@
(assoc entities :already-saved? true))
:else
nil)))))
nil))))
:on-hide
(fn [screen entities options]
(utils/release-resources screen)))

View File

@@ -160,11 +160,14 @@
(defn atlas->texture
([atlas path]
(let [region-name (str/replace path #".png" "")]
(texture (texture-atlas! atlas :find-region region-name))))
(if-let [region (texture-atlas! atlas :find-region region-name)]
(texture region)
(log/error path "not found"))))
([atlas path index]
(let [region-name (str/replace path #".png" "")]
(texture (texture-atlas! atlas :find-region region-name index)))))
(if-let [region (texture-atlas! atlas :find-region region-name index)]
(texture region)
(log/error path index "not found")))))
(defn get-texture
([path]
@@ -349,28 +352,46 @@
(texture! frame :flip true false)
frame))))
(defn split-texture [file [^int tile-width ^int tile-height] frames]
(let [sheet (get-texture file)
sheet-obj ^TextureRegion (:object sheet)
width ^int (int (.getRegionWidth sheet-obj))
x ^int (int (.getRegionX sheet-obj))
y ^int (int (.getRegionY sheet-obj))]
(for [frame frames
:let [new-tex ^TextureRegion (TextureRegion. sheet-obj)]]
(do
(.setRegion new-tex
^int (unchecked-add x (unchecked-multiply tile-width frame))
y
tile-width
tile-height)
(->TextureEntity new-tex)))))
(defn split-texture
([file [^int tile-width ^int tile-height] frames]
(let [sheet (get-texture file)
sheet-obj ^TextureRegion (:object sheet)
width ^int (int (.getRegionWidth sheet-obj))
x ^int (int (.getRegionX sheet-obj))
y ^int (int (.getRegionY sheet-obj))]
(for [frame frames
:let [new-tex ^TextureRegion (TextureRegion. sheet-obj)]]
(do
(.setRegion new-tex
^int (unchecked-add x (unchecked-multiply tile-width frame))
y
tile-width
tile-height)
(->TextureEntity new-tex)))))
(defn make-anim [file [w h] speed frames]
(animation speed (split-texture file [w h] frames)))
([atlas file [^int tile-width ^int tile-height] frames]
(let [sheet (atlas->texture atlas file)
sheet-obj ^TextureRegion (:object sheet)
width ^int (int (.getRegionWidth sheet-obj))
x ^int (int (.getRegionX sheet-obj))
y ^int (int (.getRegionY sheet-obj))]
(for [frame frames
:let [new-tex ^TextureRegion (TextureRegion. sheet-obj)]]
(do
(.setRegion new-tex
^int (unchecked-add x (unchecked-multiply tile-width frame))
y
tile-width
tile-height)
(->TextureEntity new-tex))))))
(defn make-anim-seq [file [w h] speed frames]
(animation speed (map #(get-texture (str file "-" (inc %) ".png")) frames)))
(defn make-anim
([file [w h] speed frames]
(animation speed (split-texture file [w h] frames)))
([atlas file [w h] speed frames]
(animation speed (split-texture atlas file [w h] frames))))
=
(defn make-bird [screen p]
(let [bird-sheet (texture! (get-texture "outside-castle/bird.png") :split 1 2)
bird-stand (animation 0.15 (for [i [0 1]]
@@ -755,3 +776,9 @@
(doseq [resource (:resources screen)]
(asset-manager! *asset-manager* :unload resource))
(app! :log "info"(str "Released resources " (.getDiagnostics *asset-manager*))))
(defn make-anim-seq
([file [w h] speed frames]
(animation speed (map #(get-texture (str file "-" (inc %) ".png")) frames)))
([atlas file [w h] speed frames]
(animation speed (map #(atlas->texture atlas file %) frames))))