Skip to content

Commit

Permalink
update Android build. refactor example codes a little.
Browse files Browse the repository at this point in the history
  • Loading branch information
pigpigyyy committed Dec 11, 2023
1 parent 7190adb commit dd621cb
Show file tree
Hide file tree
Showing 28 changed files with 245 additions and 226 deletions.
16 changes: 8 additions & 8 deletions Assets/Script/Example/Body.yue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
_ENV = Dorothy builtin.ImGui
_ENV = Dorothy!

const gravity = Vec2 0, -10

Expand Down Expand Up @@ -56,10 +56,10 @@ windowFlags =
* "NoMove"
threadLoop ->
const :width = App.visualSize
SetNextWindowBgAlpha 0.35
SetNextWindowPos Vec2(width - 10, 10), "Always", Vec2 1, 0
SetNextWindowSize Vec2(240, 0), "FirstUseEver"
Begin "Body", windowFlags, ->
Text "Body"
Separator!
TextWrapped "Basic usage to create physics bodies!"
ImGui.SetNextWindowBgAlpha 0.35
ImGui.SetNextWindowPos Vec2(width - 10, 10), "Always", Vec2 1, 0
ImGui.SetNextWindowSize Vec2(240, 0), "FirstUseEver"
ImGui.Begin "Body", windowFlags, ->
ImGui.Text "Body"
ImGui.Separator!
ImGui.TextWrapped "Basic usage to create physics bodies!"
14 changes: 7 additions & 7 deletions Assets/Script/Example/Camera.yue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
_ENV = Dorothy builtin.ImGui
_ENV = Dorothy!

with Node!
\addChild with Model "Model/xiaoli.model"
Expand Down Expand Up @@ -32,9 +32,9 @@ windowFlags =
* "NoMove"
threadLoop ->
const :width = App.visualSize
SetNextWindowPos Vec2(width - 10, 10), "Always", Vec2 1, 0
SetNextWindowSize Vec2(240, 0), "FirstUseEver"
Begin "Camera", windowFlags, ->
Text "Camera"
Separator!
TextWrapped "View camera motions, use 3D camera as default!"
ImGui.SetNextWindowPos Vec2(width - 10, 10), "Always", Vec2 1, 0
ImGui.SetNextWindowSize Vec2(240, 0), "FirstUseEver"
ImGui.Begin "Camera", windowFlags, ->
ImGui.Text "Camera"
ImGui.Separator!
ImGui.TextWrapped "View camera motions, use 3D camera as default!"
18 changes: 9 additions & 9 deletions Assets/Script/Example/ClipNode.yue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
_ENV = Dorothy builtin.ImGui
_ENV = Dorothy!

StarVertices = (radius, line = false)->
a = math.rad 36
Expand Down Expand Up @@ -74,16 +74,16 @@ windowFlags =
* "NoMove"
threadLoop ->
const :width = App.visualSize
SetNextWindowPos Vec2(width - 10, 10), "Always", Vec2 1, 0
SetNextWindowSize Vec2(240, 0), "FirstUseEver"
Begin "Clip Node", windowFlags, ->
Text "Clip Node"
Separator!
TextWrapped "Render children nodes with mask!"
if changed, inverted := Checkbox "Inverted", inverted
ImGui.SetNextWindowPos Vec2(width - 10, 10), "Always", Vec2 1, 0
ImGui.SetNextWindowSize Vec2(240, 0), "FirstUseEver"
ImGui.Begin "Clip Node", windowFlags, ->
ImGui.Text "Clip Node"
ImGui.Separator!
ImGui.TextWrapped "Render children nodes with mask!"
if changed, inverted := ImGui.Checkbox "Inverted", inverted
clipNodeA.inverted = inverted
clipNodeB.inverted = inverted
frame.visible = not inverted
if changed, withAlphaThreshold := Checkbox "With alphaThreshold", withAlphaThreshold
if changed, withAlphaThreshold := ImGui.Checkbox "With alphaThreshold", withAlphaThreshold
exampleB.visible = withAlphaThreshold
exampleA.visible = not withAlphaThreshold
18 changes: 9 additions & 9 deletions Assets/Script/Example/Contact.yue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
_ENV = Dorothy builtin.ImGui
_ENV = Dorothy!

gravity = Vec2 0, -10

Expand Down Expand Up @@ -56,13 +56,13 @@ windowFlags =
:receivingContact = disk
threadLoop ->
const :width = App.visualSize
SetNextWindowBgAlpha 0.35
SetNextWindowPos Vec2(width - 10, 10), "Always", Vec2 1, 0
SetNextWindowSize Vec2(240, 0), "FirstUseEver"
Begin "Contact", windowFlags, ->
Text "Contact"
Separator!
TextWrapped "Receive events when physics bodies contact."
if changed, receivingContact := Checkbox "Receiving Contact", receivingContact
ImGui.SetNextWindowBgAlpha 0.35
ImGui.SetNextWindowPos Vec2(width - 10, 10), "Always", Vec2 1, 0
ImGui.SetNextWindowSize Vec2(240, 0), "FirstUseEver"
ImGui.Begin "Contact", windowFlags, ->
ImGui.Text "Contact"
ImGui.Separator!
ImGui.TextWrapped "Receive events when physics bodies contact."
if changed, receivingContact := ImGui.Checkbox "Receiving Contact", receivingContact
disk.receivingContact = receivingContact
label.text = ""
16 changes: 8 additions & 8 deletions Assets/Script/Example/Dorothy Xml.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<!-- example ends here, print xml and compiled lua codes below -->
<Yue>
_ENV = Dorothy builtin.ImGui
_ENV = Dorothy!
xmlCodes = Content\load "Example/Dorothy Xml.xml"
luaCodes = xml.tolua xmlCodes
print "[Xml Codes]\n\n#{xmlCodes}\n[Compiled Lua Codes]\n\n#{luaCodes}"
Expand All @@ -33,12 +33,12 @@
* "NoMove"
entry\schedule ->
:width = App.visualSize
SetNextWindowBgAlpha 0.35
SetNextWindowPos Vec2(width - 10, 10), "Always", Vec2 1,0
SetNextWindowSize Vec2(240, 0), "FirstUseEver"
Begin "Dorothy Xml", windowFlags, ->
Text "Dorothy Xml"
Separator!
TextWrapped "View related codes in log window!"
ImGui.SetNextWindowBgAlpha 0.35
ImGui.SetNextWindowPos Vec2(width - 10, 10), "Always", Vec2 1,0
ImGui.SetNextWindowSize Vec2(240, 0), "FirstUseEver"
ImGui.Begin "Dorothy Xml", windowFlags, ->
ImGui.Text "Dorothy Xml"
ImGui.Separator!
ImGui.TextWrapped "View related codes in log window!"
</Yue>
</Node>
18 changes: 9 additions & 9 deletions Assets/Script/Example/DragonBones.yue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
_ENV = Dorothy builtin.ImGui
_ENV = Dorothy!

boneStr = "DragonBones/NewDragon"

Expand Down Expand Up @@ -42,12 +42,12 @@ windowFlags =
:showDebug = bone
threadLoop ->
const :width = App.visualSize
SetNextWindowBgAlpha 0.35
SetNextWindowPos Vec2(width - 10, 10), "Always", Vec2 1, 0
SetNextWindowSize Vec2(240, 0), "FirstUseEver"
Begin "DragonBones", windowFlags, ->
Text "DragonBones"
Separator!
TextWrapped "Basic usage to create dragonBones! Tap it for a hit test."
if changed, showDebug := Checkbox "BoundingBox", showDebug
ImGui.SetNextWindowBgAlpha 0.35
ImGui.SetNextWindowPos Vec2(width - 10, 10), "Always", Vec2 1, 0
ImGui.SetNextWindowSize Vec2(240, 0), "FirstUseEver"
ImGui.Begin "DragonBones", windowFlags, ->
ImGui.Text "DragonBones"
ImGui.Separator!
ImGui.TextWrapped "Basic usage to create dragonBones! Tap it for a hit test."
if changed, showDebug := ImGui.Checkbox "BoundingBox", showDebug
bone.showDebug = showDebug
16 changes: 8 additions & 8 deletions Assets/Script/Example/DrawNode.yue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
_ENV = Dorothy builtin.ImGui
_ENV = Dorothy!

CircleVertices = (radius, verts = 20)->
newV = (index, radius)->
Expand Down Expand Up @@ -77,10 +77,10 @@ windowFlags =
* "NoMove"
threadLoop ->
const :width = App.visualSize
SetNextWindowBgAlpha 0.35
SetNextWindowPos Vec2(width - 10, 10), "Always", Vec2 1, 0
SetNextWindowSize Vec2(240, 0), "FirstUseEver"
Begin "Draw Node", windowFlags, ->
Text "Draw Node"
Separator!
TextWrapped "Draw shapes and lines!"
ImGui.SetNextWindowBgAlpha 0.35
ImGui.SetNextWindowPos Vec2(width - 10, 10), "Always", Vec2 1, 0
ImGui.SetNextWindowSize Vec2(240, 0), "FirstUseEver"
ImGui.Begin "Draw Node", windowFlags, ->
ImGui.Text "Draw Node"
ImGui.Separator!
ImGui.TextWrapped "Draw shapes and lines!"
91 changes: 45 additions & 46 deletions Assets/Script/Example/Entity Move.yue
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
_ENV = Dorothy builtin.ImGui
_ENV = Dorothy!

sceneGroup = Group {"scene"}
positionGroup = Group {"position"}
sceneGroup = Group ["scene",]
positionGroup = Group ["position",]

with Observer "Add", {"scene"}
with Observer "Add", ["scene",]
\watch (scene)=> with scene
.touchEnabled = true
\slot "TapEnded", (touch)->
:location = touch
positionGroup\each (entity)->
entity.target = location

with Observer "Add", {"sprite"}
\watch (sprite)=>
with Observer "Add", ["image",]
\watch (image)=>
sceneGroup\each (e)->
e.scene\addChild with sprite
e.scene\addChild with @sprite = Sprite image
\runAction Scale 0.5, 0, 0.5, Ease.OutBack

with Observer "Remove", {"sprite"}
with Observer "Remove", ["sprite",]
\watch =>
sceneGroup\each (e)->
e.scene\removeChild @oldValues.sprite

with Observer "Remove", {"target"}
with Observer "Remove", ["target",]
\watch =>
print "remove target from entity #{@index}"

with Group {"position", "direction", "speed", "target"}
with Group ["position", "direction", "speed", "target"]
\watch (position, direction, speed, target)=>
return if target == position
dir = target - position
Expand All @@ -38,57 +38,56 @@ with Group {"position", "direction", "speed", "target"}
@direction = angle
@target = nil if newPos == target

with Observer "AddOrChange", {"position", "direction", "sprite"}
with Observer "AddOrChange", ["position", "direction", "sprite"]
\watch (position, direction, sprite)=>
sprite.position = position
lastDirection = @oldValues.direction or sprite.angle
if math.abs(direction - lastDirection) > 1
sprite\runAction Roll 0.3, lastDirection, direction

Entity
sprite: Sprite "Image/logo.png"
scene: Node!

Entity
image: "Image/logo.png"
position: Vec2.zero
direction: 45.0
speed: 4.0

Entity
sprite: Sprite "Image/logo.png"
image: "Image/logo.png"
position: Vec2 -100, 200
direction: 90.0
speed: 10.0

Entity
scene: Node!

-- example codes ends here, some test ui below --

with Observer "Add", {"scene"}
windowFlags =
* "NoDecoration"
* "AlwaysAutoResize"
* "NoSavedSettings"
* "NoFocusOnAppearing"
* "NoNav"
* "NoMove"
\watch (entity)-> entity.scene\schedule ->
const :width = App.visualSize
SetNextWindowBgAlpha 0.35
SetNextWindowPos Vec2(width - 10, 10), "Always", Vec2 1, 0
SetNextWindowSize Vec2(240, 0), "FirstUseEver"
Begin "ECS System", windowFlags, ->
Text "ECS System"
Separator!
TextWrapped "Tap any place to move entities."
if Button "Create Random Entity"
Entity
sprite: Sprite "Image/logo.png"
position: Vec2 6 * math.random(1, 100), 6 * math.random(1, 100)
direction: 1.0 * math.random 0, 360
speed: 1.0 * math.random 1, 20
if Button "Destroy An Entity"
Group({"sprite", "position"})\each (entity)->
entity.position = nil
with entity.sprite
\runAction Sequence Scale(0.5, 0.5, 0, Ease.InBack), Event("Destroy")
\slot "Destroy", -> entity\destroy!
true
windowFlags =
* "NoDecoration"
* "AlwaysAutoResize"
* "NoSavedSettings"
* "NoFocusOnAppearing"
* "NoNav"
* "NoMove"
threadLoop ->
const :width = App.visualSize
ImGui.SetNextWindowBgAlpha 0.35
ImGui.SetNextWindowPos Vec2(width - 10, 10), "Always", Vec2 1, 0
ImGui.SetNextWindowSize Vec2(240, 0), "FirstUseEver"
ImGui.Begin "ECS System", windowFlags, ->
ImGui.Text "ECS System"
ImGui.Separator!
ImGui.TextWrapped "Tap any place to move entities."
if ImGui.Button "Create Random Entity"
Entity
image: "Image/logo.png"
position: Vec2 6 * math.random(1, 100), 6 * math.random 1, 100
direction: 1.0 * math.random 0, 360
speed: 1.0 * math.random 1, 20
if ImGui.Button "Destroy An Entity"
Group(["sprite", "position"])\each (entity)->
entity.position = nil
with entity.sprite
\runAction Sequence Scale(0.5, 0.5, 0, Ease.InBack), Event "Destroy"
\slot "Destroy", -> entity\destroy!
true
16 changes: 8 additions & 8 deletions Assets/Script/Example/Gesture.yue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
_ENV = Dorothy builtin.ImGui
_ENV = Dorothy!

texture = nvg.GetDorothySSRWhite!
sprite = Sprite texture
Expand Down Expand Up @@ -31,10 +31,10 @@ windowFlags =
* "NoMove"
threadLoop ->
const :width = App.visualSize
SetNextWindowBgAlpha 0.35
SetNextWindowPos Vec2(width - 10, 10), "Always", Vec2 1,0
SetNextWindowSize Vec2(240, 0), "FirstUseEver"
Begin "Gesture", windowFlags, ->
Text "Gesture"
Separator!
TextWrapped "Interact with multi-touches!"
ImGui.SetNextWindowBgAlpha 0.35
ImGui.SetNextWindowPos Vec2(width - 10, 10), "Always", Vec2 1,0
ImGui.SetNextWindowSize Vec2(240, 0), "FirstUseEver"
ImGui.Begin "Gesture", windowFlags, ->
ImGui.Text "Gesture"
ImGui.Separator!
ImGui.TextWrapped "Interact with multi-touches!"
16 changes: 8 additions & 8 deletions Assets/Script/Example/Hello World.yue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
_ENV = Dorothy builtin.ImGui
_ENV = Dorothy!

with Node!
\slot "Enter", -> print "on enter event"
Expand All @@ -21,10 +21,10 @@ windowFlags =
* "NoMove"
threadLoop ->
const :width = App.visualSize
SetNextWindowBgAlpha 0.35
SetNextWindowPos Vec2(width - 10, 10), "Always", Vec2 1, 0
SetNextWindowSize Vec2(240, 0), "FirstUseEver"
Begin "Hello World", windowFlags, ->
Text "Hello World"
Separator!
TextWrapped "Basic Dorothy schedule and signal function usage. Written in Yuescript. View outputs in log window!"
ImGui.SetNextWindowBgAlpha 0.35
ImGui.SetNextWindowPos Vec2(width - 10, 10), "Always", Vec2 1, 0
ImGui.SetNextWindowSize Vec2(240, 0), "FirstUseEver"
ImGui.Begin "Hello World", windowFlags, ->
ImGui.Text "Hello World"
ImGui.Separator!
ImGui.TextWrapped "Basic Dorothy schedule and signal function usage. Written in Yuescript. View outputs in log window!"
16 changes: 8 additions & 8 deletions Assets/Script/Example/Label.yue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
_ENV = Dorothy builtin.ImGui
_ENV = Dorothy!

with Label "sarasa-mono-sc-regular",40
.batched = false
Expand Down Expand Up @@ -32,10 +32,10 @@ windowFlags =
* "NoMove"
threadLoop ->
const :width = App.visualSize
SetNextWindowBgAlpha 0.35
SetNextWindowPos Vec2(width - 10, 10), "Always", Vec2 1, 0
SetNextWindowSize Vec2(240, 0), "FirstUseEver"
Begin "Label", windowFlags, ->
Text "Label"
Separator!
TextWrapped "Render labels with unbatched and batched methods!"
ImGui.SetNextWindowBgAlpha 0.35
ImGui.SetNextWindowPos Vec2(width - 10, 10), "Always", Vec2 1, 0
ImGui.SetNextWindowSize Vec2(240, 0), "FirstUseEver"
ImGui.Begin "Label", windowFlags, ->
ImGui.Text "Label"
ImGui.Separator!
ImGui.TextWrapped "Render labels with unbatched and batched methods!"
Loading

0 comments on commit dd621cb

Please sign in to comment.