-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathsprite_render.go
More file actions
132 lines (110 loc) · 3.33 KB
/
sprite_render.go
File metadata and controls
132 lines (110 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*
* Copyright (c) 2021 The XGo Authors (xgo.dev). All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package spx
import (
spxlog "github.com/goplus/spx/v2/internal/log"
)
// -----------------------------------------------------------------------------
// Visibility
// -----------------------------------------------------------------------------
func (p *SpriteImpl) setVisible(visible bool) {
if isDebugInstrEnabled() {
spxlog.Debug("%s visible is %t", p.name, visible)
}
if visible == p.spriteState.IsVisible {
return
}
p.spriteState.IsVisible = visible
p.spriteState.IsDirty = true
}
func (p *SpriteImpl) Hide() {
if bubble := p.components.bubble; bubble != nil {
bubble.stopAll()
}
p.setVisible(false)
}
func (p *SpriteImpl) Show() {
p.setVisible(true)
}
func (p *SpriteImpl) Visible() bool {
return p.spriteState.IsVisible
}
// -----------------------------------------------------------------------------
// Costume
// -----------------------------------------------------------------------------
func (p *SpriteImpl) CostumeName() SpriteCostumeName {
return p.getCostumeName()
}
func (p *SpriteImpl) CostumeIndex() int {
return p.getCostumeIndex()
}
func (p *SpriteImpl) setCostume(costume any) {
if isDebugInstrEnabled() {
spxlog.Debug("SetCostume: sprite=%s, costume=%v", p.name, costume)
}
p.goSetCostume(costume)
p.spriteState.DefaultCostumeIndex = p.costumeIndex
p.spriteState.IsDirty = true
}
func (p *SpriteImpl) SetCostume__0(costume SpriteCostumeName) {
p.setCostume(costume)
}
func (p *SpriteImpl) SetCostume__1(index float64) {
p.setCostume(index)
}
func (p *SpriteImpl) SetCostume__2(index int) {
p.setCostume(index)
}
func (p *SpriteImpl) SetCostume__3(action switchAction) {
p.setCostume(action)
}
// -----------------------------------------------------------------------------
// Effects
// -----------------------------------------------------------------------------
func (p *SpriteImpl) SetGraphicEffect(kind EffectKind, val float64) {
p.setGraphicEffect(kind, val)
}
func (p *SpriteImpl) ChangeGraphicEffect(kind EffectKind, delta float64) {
p.changeGraphicEffect(kind, delta)
}
func (p *SpriteImpl) ClearGraphicEffects() {
p.clearGraphicEffects()
}
// -----------------------------------------------------------------------------
// Layer
// -----------------------------------------------------------------------------
func (p *SpriteImpl) SetLayer__0(layer layerAction) {
p.SetLayerTo(layer)
}
func (p *SpriteImpl) SetLayer__1(dir dirAction, delta int) {
p.ChangeLayer(dir, delta)
}
func (p *SpriteImpl) SetLayerTo(layer layerAction) {
switch layer {
case Front:
p.g.gotoFront(p)
case Back:
p.g.gotoBack(p)
}
}
func (p *SpriteImpl) ChangeLayer(dir dirAction, delta int) {
switch dir {
case Forward:
p.g.goBackLayers(p, -delta)
case Backward:
p.g.goBackLayers(p, delta)
}
}