Skip to content

Commit

Permalink
add new TSX test Birdy. [skip CI]
Browse files Browse the repository at this point in the history
  • Loading branch information
pigpigyyy committed Apr 26, 2024
1 parent d003aaf commit 6f25613
Show file tree
Hide file tree
Showing 7 changed files with 237 additions and 11 deletions.
135 changes: 135 additions & 0 deletions Assets/Script/Test/Birdy.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
-- [tsx]: Birdy.tsx
local ____lualib = require("lualib_bundle") -- 1
local __TS__ArrayMap = ____lualib.__TS__ArrayMap -- 1
local __TS__ParseFloat = ____lualib.__TS__ParseFloat -- 1
local ____exports = {} -- 1
local ____dora_2Dx = require("dora-x") -- 2
local React = ____dora_2Dx.React -- 2
local toNode = ____dora_2Dx.toNode -- 2
local useRef = ____dora_2Dx.useRef -- 2
local ____dora = require("dora") -- 3
local Ease = ____dora.Ease -- 3
local Line = ____dora.Line -- 3
local Scale = ____dora.Scale -- 3
local Vec2 = ____dora.Vec2 -- 3
local tolua = ____dora.tolua -- 3
toNode(React:createElement("sprite", {file = "Image/logo.png", scaleX = 0.2, scaleY = 0.2})) -- 5
local function Box(____, props) -- 14
local numText = tostring(props.num) -- 15
return React:createElement( -- 16
"body", -- 16
{ -- 16
type = "Dynamic", -- 16
scaleX = 0, -- 16
scaleY = 0, -- 16
x = props.x, -- 16
y = props.y, -- 16
tag = numText -- 16
}, -- 16
React:createElement("rect-fixture", {width = 100, height = 100}), -- 16
React:createElement( -- 16
"draw-node", -- 16
nil, -- 16
React:createElement("rect-shape", { -- 16
width = 100, -- 16
height = 100, -- 16
fillColor = 2281766911, -- 16
borderWidth = 1, -- 16
borderColor = 4278255615 -- 16
}) -- 16
), -- 16
React:createElement("label", {fontName = "sarasa-mono-sc-regular", fontSize = 40}, numText), -- 16
props.children -- 23
) -- 23
end -- 14
local bird = useRef() -- 28
local score = useRef() -- 29
local start = Vec2.zero -- 31
local delta = Vec2.zero -- 32
local line = Line() -- 34
toNode(React:createElement( -- 36
"physics-world", -- 36
{ -- 36
onTapBegan = function(touch) -- 36
start = touch.location -- 39
line:clear() -- 40
end, -- 38
onTapMoved = function(touch) -- 38
delta = delta:add(touch.delta) -- 43
line:set({ -- 44
start, -- 44
start:add(delta) -- 44
}) -- 44
end, -- 42
onTapEnded = function() -- 42
if not bird.current then -- 42
return -- 47
end -- 47
bird.current.velocity = delta:mul(Vec2(10, 10)) -- 48
start = Vec2.zero -- 49
delta = Vec2.zero -- 50
line:clear() -- 51
end -- 46
}, -- 46
React:createElement( -- 46
"body", -- 46
{type = "Static"}, -- 46
React:createElement("rect-fixture", {centerY = -200, width = 2000, height = 10}), -- 46
React:createElement( -- 46
"draw-node", -- 46
nil, -- 46
React:createElement("rect-shape", {centerY = -200, width = 2000, height = 10, fillColor = 4294689792}) -- 46
) -- 46
), -- 46
__TS__ArrayMap( -- 62
{ -- 62
10, -- 62
20, -- 62
30, -- 62
40, -- 62
50 -- 62
}, -- 62
function(____, num, i) return React:createElement( -- 62
Box, -- 63
{num = num, x = 200, y = -150 + i * 100}, -- 63
React:createElement( -- 63
"sequence", -- 63
nil, -- 63
React:createElement("delay", {time = i * 0.2}), -- 63
React:createElement("scale", {time = 0.3, start = 0, stop = 1}) -- 63
) -- 63
) end -- 63
), -- 63
React:createElement( -- 63
"body", -- 63
{ -- 63
ref = bird, -- 63
type = "Dynamic", -- 63
x = -200, -- 63
y = -150, -- 63
onContactStart = function(other) -- 63
if other.tag ~= "" and score.current then -- 63
local sc = __TS__ParseFloat(score.current.text) + __TS__ParseFloat(other.tag) -- 74
score.current.text = tostring(sc) -- 75
local ____tolua_cast_2 = tolua.cast -- 76
local ____opt_0 = other.children -- 76
local label = ____tolua_cast_2(____opt_0 and ____opt_0.last, "Label") -- 76
if label then -- 76
label.text = "" -- 77
end -- 77
other.tag = "" -- 78
other:perform(Scale(0.2, 0.7, 1)) -- 79
end -- 79
end -- 72
}, -- 72
React:createElement("disk-fixture", {radius = 50}), -- 72
React:createElement( -- 72
"draw-node", -- 72
nil, -- 72
React:createElement("dot-shape", {radius = 50, color = 4294901896}) -- 72
), -- 72
React:createElement("label", {ref = score, fontName = "sarasa-mono-sc-regular", fontSize = 40}, "0"), -- 72
React:createElement("scale", {time = 0.4, start = 0.3, stop = 1, easing = Ease.OutBack}) -- 72
) -- 72
)) -- 72
return ____exports -- 72
91 changes: 91 additions & 0 deletions Assets/Script/Test/Birdy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// @preview-file off
import { React, toNode, useRef } from 'dora-x';
import { Body, BodyMoveType, Ease, Label, Line, Scale, TypeName, Vec2, tolua } from 'dora';

toNode(<sprite file='Image/logo.png' scaleX={0.2} scaleY={0.2}/>);

interface BoxProps {
num: number;
x?: number;
y?: number;
children?: any | any[];
}

const Box = (props: BoxProps) => {
const numText = props.num.toString();
return (
<body type={BodyMoveType.Dynamic} scaleX={0} scaleY={0} x={props.x} y={props.y} tag={numText}>
<rect-fixture width={100} height={100}/>
<draw-node>
<rect-shape width={100} height={100} fillColor={0x8800ffff} borderWidth={1} borderColor={0xff00ffff}/>
</draw-node>
<label fontName='sarasa-mono-sc-regular' fontSize={40}>{numText}</label>
{props.children}
</body>
);
};

const bird = useRef<Body.Type>();
const score = useRef<Label.Type>();

let start = Vec2.zero;
let delta = Vec2.zero;

const line = Line();

toNode(
<physics-world
onTapBegan={(touch) => {
start = touch.location;
line.clear();
}}
onTapMoved={(touch) => {
delta = delta.add(touch.delta);
line.set([start, start.add(delta)]);
}}
onTapEnded={() => {
if (!bird.current) return;
bird.current.velocity = delta.mul(Vec2(10, 10));
start = Vec2.zero;
delta = Vec2.zero;
line.clear();
}}
>
<body type={BodyMoveType.Static}>
<rect-fixture centerY={-200} width={2000} height={10}/>
<draw-node>
<rect-shape centerY={-200} width={2000} height={10} fillColor={0xfffbc400}/>
</draw-node>
</body>

{
[10, 20, 30, 40, 50].map((num, i) =>
<Box num={num} x={200} y={-150 + i * 100}>
<sequence>
<delay time={i * 0.2}/>
<scale time={0.3} start={0} stop={1}/>
</sequence>
</Box>
)
}

<body ref={bird} type={BodyMoveType.Dynamic} x={-200} y={-150} onContactStart={(other) => {
if (other.tag !== '' && score.current) {
const sc = parseFloat(score.current.text) + parseFloat(other.tag);
score.current.text = sc.toString();
const label = tolua.cast(other.children?.last, TypeName.Label);
if (label) label.text = '';
other.tag = '';
other.perform(Scale(0.2, 0.7, 1.0));
}
}}
>
<disk-fixture radius={50}/>
<draw-node>
<dot-shape radius={50} color={0xffff0088}/>
</draw-node>
<label ref={score} fontName='sarasa-mono-sc-regular' fontSize={40}>0</label>
<scale time={0.4} start={0.3} stop={1.0} easing={Ease.OutBack}/>
</body>
</physics-world>
);
4 changes: 2 additions & 2 deletions Project/Android/Dora/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "org.ippclub.dorassr"
minSdkVersion 28
targetSdkVersion 34
versionCode 51
versionName "1.3.19"
versionCode 52
versionName "1.3.20"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
externalNativeBuild {
cmake {
Expand Down
8 changes: 4 additions & 4 deletions Project/Windows/Dora/Resource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ IDI_ICON1 ICON "Dora SSR.ico"
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,3,19,0
PRODUCTVERSION 1,3,19,0
FILEVERSION 1,3,20,0
PRODUCTVERSION 1,3,20,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -79,12 +79,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "IppClub"
VALUE "FileDescription", "A game engine for rapid game development."
VALUE "FileVersion", "1.3.19.0"
VALUE "FileVersion", "1.3.20.0"
VALUE "InternalName", "Dora.exe"
VALUE "LegalCopyright", "Copyright (C) 2024"
VALUE "OriginalFilename", "Dora.exe"
VALUE "ProductName", "Dora SSR"
VALUE "ProductVersion", "1.3.19.0"
VALUE "ProductVersion", "1.3.20.0"
END
END
BLOCK "VarFileInfo"
Expand Down
4 changes: 2 additions & 2 deletions Project/iOS/Dora/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.3.19</string>
<string>1.3.20</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>51</string>
<string>52</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
Expand Down
4 changes: 2 additions & 2 deletions Project/macOS/Dora/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.3.19</string>
<string>1.3.20</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>51</string>
<string>52</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.developer-tools</string>
<key>LSMinimumSystemVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion Source/Basic/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#include <ctime>
#include <thread>

#define DORA_VERSION "1.3.19"_slice
#define DORA_VERSION "1.3.20"_slice

#if BX_PLATFORM_ANDROID
#include <jni.h>
Expand Down

0 comments on commit 6f25613

Please sign in to comment.