Testing card placement

This commit is contained in:
Jörn-Michael Miehe 2018-10-01 21:39:53 +02:00
parent 1c30720348
commit 49bf42e1fb
3 changed files with 42 additions and 26 deletions

View file

@ -10,7 +10,7 @@ CONF =
bigcard: bigcard:
x: (2000 - 1200) / 2 x: (2000 - 1200) / 2
y: (2000 - 1675) / 2 y: ( 0 - 1675) / 2
w: 1200 w: 1200
h: 1675 h: 1675

View file

@ -21,14 +21,14 @@ Crafty.c 'Card',
Crafty.log 'Card was removed!' Crafty.log 'Card was removed!'
return return
events:
# smooth placement # smooth placement
place: (px, py) -> Place: (position) ->
@tween { @tween {
x: px x: position.x
y: py y: position.y
}, CONF.anim.time, CONF.anim.func }, CONF.anim.time, CONF.anim.func
events:
# Tap or untap, pass true iff you want to tap # Tap or untap, pass true iff you want to tap
Tap: (newState) -> Tap: (newState) ->
# store new state in property as boolean value # store new state in property as boolean value
@ -89,7 +89,7 @@ Crafty.c 'EnemyCard',
################ ################
Crafty.c 'AllyCard', Crafty.c 'AllyCard',
# is a card # is a card
required: 'Card, Draggable' required: 'Card'
# normally oriented by default # normally oriented by default
init: -> init: ->
@ -102,12 +102,3 @@ Crafty.c 'AllyCard',
DoubleClick: -> DoubleClick: ->
@trigger 'ToggleTap' @trigger 'ToggleTap'
return return
# snap to 100×100 grid (TODO)
StopDrag: ->
round100 = (v) ->
Math.round(v / 100) * 100
@place round100(@_x), round100(@_y)
return

View file

@ -8,14 +8,39 @@ Crafty.sprite 480, 670, '//www.fftcgmognet.com/images/cards/hd/1/1/107.jpg',
0 0
] ]
Crafty.e 'shantotto, AllyCard, Backup' backups = [
.place 0, 0
Crafty.e 'shantotto, AllyCard, Backup' Crafty.e 'shantotto, AllyCard'
.place 300, 0 .attr {
card:
type: 'backup'
}
Crafty.e 'shantotto, AllyCard, Backup' Crafty.e 'shantotto, AllyCard'
.place 600, 0 .attr {
card:
type: 'backup'
}
Crafty.e 'shantotto, EnemyCard, Backup' Crafty.e 'shantotto, AllyCard'
.place 900, 0 .attr {
card:
type: 'backup'
}
]
Crafty 'AllyCard'
.each (index) ->
switch @card.type
when 'backup'
@trigger 'Place',
x: CONF.coord.x.main + index * CONF.coord.x.step
y: CONF.coord.y.bkup
return
Crafty.e 'shantotto, EnemyCard'
.trigger 'Place',
x: 900
y: 0