Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync main to dev #347

Merged
merged 49 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
bc71ea6
add Awake event, add default animation binding #builder #603
JiepengTan Jun 19, 2024
3265d35
add animation rebinding
JiepengTan Jun 21, 2024
ee2bd48
merge main
JiepengTan Jun 21, 2024
7f07850
remove sprite event Awake
JiepengTan Jun 21, 2024
5e4b01d
make the "Awake" method private
JiepengTan Jun 21, 2024
ea894f5
Merge pull request #289 from JiepengTan/builder#603_Animation_binding
xushiwei Jun 25, 2024
c349c2b
sprite's pivot should scaled by current costume's bitmapResolution
JiepengTan Jun 27, 2024
57e7990
animation binding: support "step"
JiepengTan Jul 2, 2024
2490632
Update format
JiepengTan Jul 2, 2024
0f1bb64
Bump github.com/hajimehoshi/ebiten/v2 from 2.7.5 to 2.7.6
dependabot[bot] Jul 3, 2024
8dc1222
Merge pull request #295 from JiepengTan/#builder#603animation_step_st…
xushiwei Jul 3, 2024
0ba83dd
Merge pull request #296 from goplus/dependabot/go_modules/github.com/…
xushiwei Jul 3, 2024
72b5b4f
Merge pull request #294 from JiepengTan/builder#sprite_pivot_scale_by…
xushiwei Jul 3, 2024
cd833f2
fix: Click-capture issue with sprite pivot #297
JiepengTan Jul 3, 2024
283112a
extract a function to eliminate duplicate code
JiepengTan Jul 3, 2024
e7b8b95
remove return value
JiepengTan Jul 3, 2024
b827a6e
Bump github.com/hajimehoshi/ebiten/v2 from 2.7.6 to 2.7.7
dependabot[bot] Jul 8, 2024
c43227c
Merge pull request #302 from goplus/dependabot/go_modules/github.com/…
xushiwei Jul 8, 2024
8f9159a
Merge pull request #299 from JiepengTan/builder#297_sprite_pivot_clic…
xushiwei Jul 8, 2024
f61b480
Bump github.com/hajimehoshi/ebiten/v2 from 2.7.7 to 2.7.8
dependabot[bot] Jul 23, 2024
d78c2bb
support Widget Monitor
JiepengTan Jul 25, 2024
c2b627c
Update monitor style
JiepengTan Jul 25, 2024
35ba6e4
Support scale monitor
JiepengTan Jul 25, 2024
799d0f7
Merge pull request #305 from goplus/dependabot/go_modules/github.com/…
xushiwei Jul 30, 2024
55d71d4
Rename MonitorWidget => Monitor
JiepengTan Aug 7, 2024
2e32fae
Update monitor style
JiepengTan Aug 7, 2024
ccef49d
Merge pull request #306 from JiepengTan/builder#648
xushiwei Aug 7, 2024
33d8d71
#builder#300 animation group issues (#303)
JiepengTan Aug 12, 2024
426c128
Upgrade monitor config (#307)
JiepengTan Aug 12, 2024
509e597
Builder#303 upgrade test animation config (#309)
JiepengTan Aug 12, 2024
1994744
Builder#648 fix widget (#310)
JiepengTan Aug 15, 2024
3df776b
Builder#648 Convert the "GetWidget" function to a generic function (…
JiepengTan Aug 15, 2024
175be7a
replace audio parser with the parser of Ebiten
qlli Aug 17, 2024
d1b083e
Support ispx with generics (#312)
nighca Aug 28, 2024
bd0c27a
Merge pull request #313 from qlli/ebitenAudio
xushiwei Sep 1, 2024
41a8b10
fix: Initial costumeIndex for sprite not working #317 (#322)
qlli Sep 6, 2024
8c8e86f
fix: Sprite Glide panics #319 (#321)
qlli Sep 6, 2024
1b3a5bf
Revert "replace audio parser with the parser of Ebiten" (#325)
qlli Sep 9, 2024
bd4dcff
Bump github.com/hajimehoshi/ebiten/v2 from 2.7.8 to 2.7.9
dependabot[bot] Sep 9, 2024
cc23ad2
fix: Unify Die behavior of initial / cloned sprite #314
qlli Sep 10, 2024
3cb9319
Rename Destroy => DeleteThisClone (#314)
qlli Sep 11, 2024
68a7f5f
Add Destroy and comment (#314)
qlli Sep 11, 2024
7462a9d
Add comment (#314)
qlli Sep 11, 2024
b1f0ef6
Merge pull request #329 from qlli/main
xushiwei Sep 11, 2024
e8d7bc1
Merge pull request #326 from goplus/dependabot/go_modules/github.com/…
xushiwei Sep 11, 2024
5e8dc87
fix: Die behavior with animation #315 (#333)
qlli Sep 14, 2024
2e78093
fix: Avoid panic when "auto-binding" failed #330 (#336)
qlli Sep 20, 2024
1c08777
update touch event API #298 (#340)
qlli Oct 15, 2024
6ee4234
Type definition for sprite (#338)
qlli Oct 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
.DS_Store
sprite.txt
game.txt
gop.mod
go.work
go.json
gop.json
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ How to show the `score` on the stage? You don't need write code, just add a `sta
{
"zorder": [
{
"type": "stageMonitor",
"type": "monitor",
"name": "dragon",
"size": 1,
"target": "Dragon",
"val": "getVar:score",
"color": 15629590,
Expand Down
6 changes: 3 additions & 3 deletions camera.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ func (c *Camera) On(obj interface{}) {
return
}
obj = sp
case *Sprite:
case *SpriteImpl:
case nil:
case Spriter:
case Sprite:
obj = spriteOf(v)
case specialObj:
if v != Mouse {
Expand All @@ -85,7 +85,7 @@ func (c *Camera) On(obj interface{}) {

func (c *Camera) updateOnObj() {
switch v := c.on_.(type) {
case *Sprite:
case *SpriteImpl:
cx, cy := v.getXY()
c.freecamera.MoveTo(cx, cy)
case nil:
Expand Down
26 changes: 18 additions & 8 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,22 @@ type actionConfig struct {
}

type aniConfig struct {
Duration float64 `json:"duration"`
Fps float64 `json:"fps"`
From interface{} `json:"from"`
To interface{} `json:"to"`
AniType aniTypeEnum `json:"anitype"`
OnStart *actionConfig `json:"onStart"` //start
OnPlay *actionConfig `json:"onPlay"` //play
IsLoop bool `json:"isLoop"`
Duration float64 `json:"duration"`
Fps float64 `json:"fps"`
From interface{} `json:"from"`
To interface{} `json:"to"`
FrameFrom string `json:"frameFrom"`
FrameTo string `json:"frameTo"`
FrameFps int `json:"frameFps"`
StepDuration float64 `json:"stepDuration"`
TurnToDuration float64 `json:"turnToDuration"`

AniType aniTypeEnum `json:"anitype"`
OnStart *actionConfig `json:"onStart"` //start
OnPlay *actionConfig `json:"onPlay"` //play
IsLoop bool `json:"isLoop"`
IsKeepOnStop bool `json:"isKeepOnStop"` //After finishing playback, it stays on the last frame and does not need to switch to the default animation

//OnEnd *actionConfig `json:"onEnd"` //stop
}

Expand All @@ -235,6 +243,8 @@ type spriteConfig struct {
Visible bool `json:"visible"`
IsDraggable bool `json:"isDraggable"`
Pivot math32.Vector2 `json:"pivot"`
DefaultAnimation string `json:"defaultAnimation"`
AnimBindings map[string]string `json:"animBindings"`
}

func (p *spriteConfig) getCostumeIndex() int {
Expand Down
55 changes: 46 additions & 9 deletions event.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ type eventSinkMgr struct {
allWhenIReceive *eventSink
allWhenBackdropChanged *eventSink
allWhenCloned *eventSink
allWhenTouched *eventSink
allWhenTouchStart *eventSink
allWhenTouching *eventSink
allWhenTouchEnd *eventSink
allWhenClick *eventSink
allWhenMoving *eventSink
allWhenTurning *eventSink
Expand All @@ -107,7 +109,9 @@ func (p *eventSinkMgr) reset() {
p.allWhenIReceive = nil
p.allWhenBackdropChanged = nil
p.allWhenCloned = nil
p.allWhenTouched = nil
p.allWhenTouchStart = nil
p.allWhenTouching = nil
p.allWhenTouchEnd = nil
p.allWhenClick = nil
p.allWhenMoving = nil
p.allWhenTurning = nil
Expand All @@ -120,7 +124,9 @@ func (p *eventSinkMgr) doDeleteClone(this interface{}) {
p.allWhenIReceive = p.allWhenIReceive.doDeleteClone(this)
p.allWhenBackdropChanged = p.allWhenBackdropChanged.doDeleteClone(this)
p.allWhenCloned = p.allWhenCloned.doDeleteClone(this)
p.allWhenTouched = p.allWhenTouched.doDeleteClone(this)
p.allWhenTouchStart = p.allWhenTouchStart.doDeleteClone(this)
p.allWhenTouching = p.allWhenTouching.doDeleteClone(this)
p.allWhenTouchEnd = p.allWhenTouchEnd.doDeleteClone(this)
p.allWhenClick = p.allWhenClick.doDeleteClone(this)
p.allWhenMoving = p.allWhenMoving.doDeleteClone(this)
p.allWhenTurning = p.allWhenTurning.doDeleteClone(this)
Expand Down Expand Up @@ -153,12 +159,30 @@ func (p *eventSinkMgr) doWhenClick(this threadObj) {
})
}

func (p *eventSinkMgr) doWhenTouched(this threadObj, obj *Sprite) {
p.allWhenTouched.asyncCall(false, this, func(ev *eventSink) {
func (p *eventSinkMgr) doWhenTouchStart(this threadObj, obj *SpriteImpl) {
p.allWhenTouchStart.asyncCall(false, this, func(ev *eventSink) {
if debugEvent {
log.Println("==> onTouched", nameOf(this), obj.name)
log.Println("===> onTouchStart", nameOf(this), obj.name)
}
ev.sink.(func(*Sprite))(obj)
ev.sink.(func(Sprite))(obj.sprite)
})
}

func (p *eventSinkMgr) doWhenTouching(this threadObj, obj *SpriteImpl) {
p.allWhenTouching.asyncCall(false, this, func(ev *eventSink) {
if debugEvent {
log.Println("==> onTouching", nameOf(this), obj.name)
}
ev.sink.(func(Sprite))(obj.sprite)
})
}

func (p *eventSinkMgr) doWhenTouchEnd(this threadObj, obj *SpriteImpl) {
p.allWhenTouchEnd.asyncCall(false, this, func(ev *eventSink) {
if debugEvent {
log.Println("===> onTouchEnd", nameOf(this), obj.name)
}
ev.sink.(func(Sprite))(obj.sprite)
})
}

Expand Down Expand Up @@ -196,14 +220,27 @@ func (p *eventSinkMgr) doWhenBackdropChanged(name string, wait bool) {
}

// -------------------------------------------------------------------------------------
type IEventSinks interface {
OnAnyKey(onKey func(key Key))
OnBackdrop__0(onBackdrop func(name string))
OnBackdrop__1(name string, onBackdrop func())
OnClick(onClick func())
OnKey__0(key Key, onKey func())
OnKey__1(keys []Key, onKey func(Key))
OnKey__2(keys []Key, onKey func())
OnMsg__0(onMsg func(msg string, data interface{}))
OnMsg__1(msg string, onMsg func())
OnStart(onStart func())
Stop(kind StopKind)
}

type eventSinks struct {
*eventSinkMgr
pthis threadObj
}

func nameOf(this interface{}) string {
if spr, ok := this.(*Sprite); ok {
if spr, ok := this.(*SpriteImpl); ok {
return spr.name
}
if _, ok := this.(*Game); ok {
Expand Down Expand Up @@ -399,7 +436,7 @@ func isGame(obj threadObj) bool {
}

func isSprite(obj threadObj) bool {
_, ok := obj.(*Sprite)
_, ok := obj.(*SpriteImpl)
return ok
}

Expand Down
Loading
Loading