apply isoprojection in Sprite
This commit is contained in:
parent
88ded18d50
commit
5699d70be6
2 changed files with 8 additions and 6 deletions
|
@ -21,8 +21,8 @@ func init() {
|
||||||
|
|
||||||
// Sprite combines an Actor with the ability to Draw from a single spritesheet.
|
// Sprite combines an Actor with the ability to Draw from a single spritesheet.
|
||||||
type Sprite struct {
|
type Sprite struct {
|
||||||
Actor Actor
|
Actor Actor
|
||||||
FrameOffset image.Point
|
DrawOffset image.Point
|
||||||
Hidden
|
Hidden
|
||||||
Sheet Sheet
|
Sheet Sheet
|
||||||
|
|
||||||
|
@ -56,9 +56,11 @@ func (s *Sprite) SetAnim(a *Anim) {
|
||||||
s.anim = a
|
s.anim = a
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transform returns a translation by the FrameOffset.
|
// Transform returns a translation by the DrawOffset and the iso-projected Pos.
|
||||||
func (s *Sprite) Transform(pt Transform) (tf Transform) {
|
func (s *Sprite) Transform(pt Transform) (tf Transform) {
|
||||||
tf.Opts.GeoM.Translate(cfloat(s.Actor.Pos.XY().Add(s.FrameOffset)))
|
tf.Opts.GeoM.Translate(cfloat(
|
||||||
|
s.Actor.Pos.IsoProject(pt.IsoProjection).Add(s.DrawOffset),
|
||||||
|
))
|
||||||
return tf.Concat(pt)
|
return tf.Concat(pt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
4
main.go
4
main.go
|
@ -197,10 +197,10 @@ func level1() *engine.Scene {
|
||||||
Sprite: engine.Sprite{
|
Sprite: engine.Sprite{
|
||||||
Actor: engine.Actor{
|
Actor: engine.Actor{
|
||||||
CollisionDomain: "level_1",
|
CollisionDomain: "level_1",
|
||||||
Pos: engine.Pt3(100, 100, 9),
|
Pos: engine.Pt3(100, 100, 0),
|
||||||
Size: engine.Pt3(8, 16, 8),
|
Size: engine.Pt3(8, 16, 8),
|
||||||
},
|
},
|
||||||
FrameOffset: image.Pt(-1, 0),
|
DrawOffset: image.Pt(-1, 0),
|
||||||
Sheet: engine.Sheet{
|
Sheet: engine.Sheet{
|
||||||
AnimDefs: map[string]*engine.AnimDef{
|
AnimDefs: map[string]*engine.AnimDef{
|
||||||
"idle_left": {Steps: []engine.AnimStep{
|
"idle_left": {Steps: []engine.AnimStep{
|
||||||
|
|
Loading…
Reference in a new issue