Testing card placement
This commit is contained in:
parent
1c30720348
commit
49bf42e1fb
3 changed files with 42 additions and 26 deletions
|
@ -10,7 +10,7 @@ CONF =
|
|||
|
||||
bigcard:
|
||||
x: (2000 - 1200) / 2
|
||||
y: (2000 - 1675) / 2
|
||||
y: ( 0 - 1675) / 2
|
||||
w: 1200
|
||||
h: 1675
|
||||
|
||||
|
|
|
@ -21,14 +21,14 @@ Crafty.c 'Card',
|
|||
Crafty.log 'Card was removed!'
|
||||
return
|
||||
|
||||
events:
|
||||
# smooth placement
|
||||
place: (px, py) ->
|
||||
Place: (position) ->
|
||||
@tween {
|
||||
x: px
|
||||
y: py
|
||||
x: position.x
|
||||
y: position.y
|
||||
}, CONF.anim.time, CONF.anim.func
|
||||
|
||||
events:
|
||||
# Tap or untap, pass true iff you want to tap
|
||||
Tap: (newState) ->
|
||||
# store new state in property as boolean value
|
||||
|
@ -89,7 +89,7 @@ Crafty.c 'EnemyCard',
|
|||
################
|
||||
Crafty.c 'AllyCard',
|
||||
# is a card
|
||||
required: 'Card, Draggable'
|
||||
required: 'Card'
|
||||
|
||||
# normally oriented by default
|
||||
init: ->
|
||||
|
@ -102,12 +102,3 @@ Crafty.c 'AllyCard',
|
|||
DoubleClick: ->
|
||||
@trigger 'ToggleTap'
|
||||
return
|
||||
|
||||
# snap to 100×100 grid (TODO)
|
||||
StopDrag: ->
|
||||
|
||||
round100 = (v) ->
|
||||
Math.round(v / 100) * 100
|
||||
|
||||
@place round100(@_x), round100(@_y)
|
||||
return
|
||||
|
|
|
@ -8,14 +8,39 @@ Crafty.sprite 480, 670, '//www.fftcgmognet.com/images/cards/hd/1/1/107.jpg',
|
|||
0
|
||||
]
|
||||
|
||||
Crafty.e 'shantotto, AllyCard, Backup'
|
||||
.place 0, 0
|
||||
backups = [
|
||||
|
||||
Crafty.e 'shantotto, AllyCard, Backup'
|
||||
.place 300, 0
|
||||
Crafty.e 'shantotto, AllyCard'
|
||||
.attr {
|
||||
card:
|
||||
type: 'backup'
|
||||
}
|
||||
|
||||
Crafty.e 'shantotto, AllyCard, Backup'
|
||||
.place 600, 0
|
||||
Crafty.e 'shantotto, AllyCard'
|
||||
.attr {
|
||||
card:
|
||||
type: 'backup'
|
||||
}
|
||||
|
||||
Crafty.e 'shantotto, EnemyCard, Backup'
|
||||
.place 900, 0
|
||||
Crafty.e 'shantotto, AllyCard'
|
||||
.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
|
||||
|
|
Reference in a new issue