整体渲染大改
This commit is contained in:
parent
0ce2de0b59
commit
3e8159c100
BIN
Yosin_Engine.exe
BIN
Yosin_Engine.exe
Binary file not shown.
|
|
@ -4,7 +4,7 @@
|
|||
创建日期:2024-05-07 23:25
|
||||
文件用途:动画类
|
||||
*/
|
||||
class Animation extends Actor {
|
||||
class Animation extends CL_SpriteObject {
|
||||
|
||||
//Ani是否可用
|
||||
IsUsability = true;
|
||||
|
|
@ -34,6 +34,15 @@ class Animation extends Actor {
|
|||
//Ani路径
|
||||
AniPath = null;
|
||||
|
||||
//是否描边
|
||||
IsOutline = false;
|
||||
//描边颜色
|
||||
OutlineColor = null;
|
||||
//描边对象List
|
||||
OutlineList = null;
|
||||
//当前描边对象
|
||||
CurrentOutline = null;
|
||||
|
||||
//附加选项
|
||||
AdditionalOptions = null;
|
||||
|
||||
|
|
@ -48,6 +57,8 @@ class Animation extends Actor {
|
|||
SpriteArr = [];
|
||||
//帧数组
|
||||
FrameArr = [];
|
||||
//描边对象List
|
||||
OutlineList = [];
|
||||
|
||||
//判断是否有特殊处理
|
||||
if (vargv.len() > 1) {
|
||||
|
|
@ -110,27 +121,22 @@ class Animation extends Actor {
|
|||
AnimationFlag = Buf.Flag;
|
||||
FrameArr = Buf.Frame;
|
||||
foreach(FrameObj in FrameArr) {
|
||||
local Spritebuf;
|
||||
local SpriteFramebuf;
|
||||
//img路径判空
|
||||
if (FrameObj.Img_Path) {
|
||||
//如果有附加处理 格式化
|
||||
if (AdditionalOptions && AdditionalOptions.rawin("ImgFormat")) FrameObj.Img_Path = AdditionalOptions["ImgFormat"](FrameObj.Img_Path);
|
||||
|
||||
Spritebuf = CL_SpriteObject("sprite/" + FrameObj.Img_Path, FrameObj.Img_Index);
|
||||
|
||||
//线性减淡
|
||||
if ("GRAPHIC_EFFECT_LINEARDODGE" in FrameObj.Flag) {
|
||||
Spritebuf.SetMode(0);
|
||||
}
|
||||
SpriteFramebuf = CL_SpriteFrameObject("sprite/" + FrameObj.Img_Path, FrameObj.Img_Index);
|
||||
|
||||
//坐标
|
||||
Spritebuf.SetPosition(FrameObj.Pos);
|
||||
SpriteFramebuf.SetPosition(FrameObj.Pos);
|
||||
} else {
|
||||
Spritebuf = CL_SpriteObject();
|
||||
SpriteFramebuf = CL_SpriteFrameObject("sprite/interface/base.img", 0);
|
||||
}
|
||||
|
||||
|
||||
SpriteArr.append(Spritebuf);
|
||||
SpriteArr.append(SpriteFramebuf);
|
||||
}
|
||||
} else {
|
||||
error("创建Ani失败,找不到Ani数据");
|
||||
|
|
@ -166,19 +172,51 @@ class Animation extends Actor {
|
|||
|
||||
//设置描边
|
||||
function SetOutline(Flag, Color = 0xffffffff) {
|
||||
foreach(Index, Sprite in SpriteArr) {
|
||||
Sprite.SetOutline(Flag, Color);
|
||||
IsOutline = Flag;
|
||||
//如果是开启
|
||||
if (Flag) {
|
||||
//如果没有创建过描边对象就创建
|
||||
if (OutlineList.len() == 0) {
|
||||
foreach(FrameSf in SpriteArr) {
|
||||
local OutlineCanvasObj = FrameSf.CreateOutLine(Color);
|
||||
// OutlineCanvasObj.SetZOrder(-1);
|
||||
// OutlineCanvasObj.SetPosition(-1, -1);
|
||||
// OutlineCanvasObj.SetPosition(-FrameSf.GetSize().w / 2, -FrameSf.GetSize().h);
|
||||
OutlineList.push(OutlineCanvasObj);
|
||||
}
|
||||
}
|
||||
//先把当前帧的描边对象设置上
|
||||
AddOutlineChild();
|
||||
} else {
|
||||
//移除当前描边对象
|
||||
if (CurrentOutline) {
|
||||
Removechild(CurrentOutline);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//添加描边子对象
|
||||
function AddOutlineChild() {
|
||||
//如果有上一个描边对象先移除
|
||||
if (CurrentOutline) {
|
||||
Removechild(CurrentOutline);
|
||||
}
|
||||
//如果没有添加为子对象则添加
|
||||
local OutlineCanvasObj = OutlineList[CurrentFrameIndex];
|
||||
if (OutlineCanvasObj.Parent == null) {
|
||||
CurrentOutline = OutlineCanvasObj;
|
||||
Addchild(CurrentOutline);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function FlushFrame(Index) {
|
||||
//同步当前帧
|
||||
CurrentFrameIndex = Index;
|
||||
//移除上一帧
|
||||
if (CurrentFrame) Removechild(CurrentFrame);
|
||||
|
||||
//当前帧更换为本帧
|
||||
CurrentFrame = SpriteArr[CurrentFrameIndex];
|
||||
Addchild(SpriteArr[CurrentFrameIndex]);
|
||||
SetFrame(CurrentFrame);
|
||||
|
||||
local FrameInfo = FrameArr[CurrentFrameIndex];
|
||||
local FlagBuf = FrameInfo.Flag;
|
||||
|
|
@ -195,6 +233,12 @@ class Animation extends Actor {
|
|||
if ("IMAGE_RATE" in FlagBuf) {
|
||||
SetScale(FlagBuf.IMAGE_RATE.x, FlagBuf.IMAGE_RATE.y);
|
||||
}
|
||||
//线性减淡
|
||||
if ("GRAPHIC_EFFECT_LINEARDODGE" in FrameInfo.Flag) {
|
||||
SetMode(0);
|
||||
}
|
||||
//如果有描边
|
||||
if (IsOutline) AddOutlineChild();
|
||||
|
||||
//Ani对象的大小同步为精灵帧对象的大小
|
||||
if (CurrentFrame) SetSize(CurrentFrame.GetSize());
|
||||
|
|
|
|||
|
|
@ -9,6 +9,10 @@ class CL_SpriteFrameObject extends CL_BaseObject {
|
|||
ImgPath = null;
|
||||
ImgIndex = null;
|
||||
|
||||
function _typeof() {
|
||||
return "SpriteFrame";
|
||||
}
|
||||
|
||||
constructor(...) {
|
||||
if (vargv.len() == 2) {
|
||||
ImgPath = vargv[0];
|
||||
|
|
@ -20,4 +24,26 @@ class CL_SpriteFrameObject extends CL_BaseObject {
|
|||
// base.constructor(C_Object);
|
||||
}
|
||||
|
||||
//重写获取大小
|
||||
function GetSize() {
|
||||
return SpriteFrame_GetSize(this.C_Object);
|
||||
}
|
||||
|
||||
//重写设置坐标
|
||||
function SetPosition(Value, ...) {
|
||||
if (vargv.len() == 0) {
|
||||
X = Value.x;
|
||||
Y = Value.y;
|
||||
SpriteFrame_SetPosition(this.C_Object, Value);
|
||||
} else if (vargv.len() == 1) {
|
||||
X = Value;
|
||||
Y = vargv[0];
|
||||
SpriteFrame_SetPosition(this.C_Object, Value, vargv[0]);
|
||||
}
|
||||
}
|
||||
|
||||
//返回一个画布精灵
|
||||
function CreateOutLine(Color) {
|
||||
return CL_SpriteObject(SpriteFrame_CreateOutLine(this.C_Object, Color));
|
||||
}
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
//游戏逻辑函数Map
|
||||
_Game_Logic_Func_ <- {};
|
||||
|
||||
function _Yosin_Game_Logic_(Dt, GameLister) {
|
||||
function _Yosin_Game_Logic_(Dt, GameListener) {
|
||||
//Socket连接嗅探处理包
|
||||
foreach(SocketObj in _Socket_Map_) {
|
||||
SocketObj.DispatchPacket();
|
||||
|
|
@ -15,6 +15,6 @@ function _Yosin_Game_Logic_(Dt, GameLister) {
|
|||
|
||||
//游戏逻辑函数
|
||||
foreach(Key, Func in _Game_Logic_Func_) {
|
||||
Func(Dt, GameLister);
|
||||
Func(Dt, GameListener);
|
||||
}
|
||||
}
|
||||
|
|
@ -4,9 +4,9 @@
|
|||
创建日期:2024-12-18 13:41
|
||||
文件用途:
|
||||
*/
|
||||
class _Yosin_Cursor extends Actor {
|
||||
class _Yosin_Cursor extends CL_SpriteObject {
|
||||
|
||||
Object = null;
|
||||
CurrentFrame = null;
|
||||
|
||||
_Mouse_Click_Flag = null;
|
||||
|
||||
|
|
@ -26,11 +26,8 @@ class _Yosin_Cursor extends Actor {
|
|||
|
||||
//更换鼠标指针
|
||||
function Change(Frame) {
|
||||
if (Object) {
|
||||
Removechild(Object);
|
||||
}
|
||||
Object = Frame;
|
||||
Addchild(Frame);
|
||||
CurrentFrame = Frame;
|
||||
SetFrame(Frame);
|
||||
}
|
||||
|
||||
//事件
|
||||
|
|
|
|||
|
|
@ -61,7 +61,6 @@ class GameObject.NPC extends GameObject.BaseClass {
|
|||
return NameObj;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function OnMouseLogic(MouseState, Wheel, MousePos_X, MousePos_Y) {
|
||||
|
|
@ -71,7 +70,7 @@ class GameObject.NPC extends GameObject.BaseClass {
|
|||
//设置Ani描边
|
||||
Ani.SetOutline(true, sq_RGBA(155, 255, 0, 250));
|
||||
//设置鼠标
|
||||
Yosin_Cursor.Change(120);
|
||||
Yosin_Cursor.ChangeActive(120, 4);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -85,4 +84,5 @@ class GameObject.NPC extends GameObject.BaseClass {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -10,8 +10,8 @@ function InitGame() {
|
|||
// MySocket("127.0.0.1", 19666);
|
||||
|
||||
//设定全局默认音量
|
||||
_Globa_Audio_Volume_ = 0.1;
|
||||
_Globa_Sound_Volume_ = 0.3;
|
||||
_Globa_Audio_Volume_ = 0.03;
|
||||
_Globa_Sound_Volume_ = 0.03;
|
||||
|
||||
Script();
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ function TestStage() {
|
|||
T.Enter();
|
||||
|
||||
|
||||
// local Window = Sq_CreateWindow(_Login_Window, "登录界面窗口", 0, 0, 1066, 600, 0);
|
||||
local Window = Sq_CreateWindow(_Login_Window, "登录界面窗口", 0, 0, 1066, 600, 0);
|
||||
|
||||
|
||||
// //大背景
|
||||
|
|
@ -25,10 +25,10 @@ function TestStage() {
|
|||
// NPCobj.SetPosition(400, 400, 0);
|
||||
// T.Addchild(NPCobj);
|
||||
|
||||
local TownObj = Town(1);
|
||||
local Charc = GameObject.CreateCharacter(0, [101590007, 27675, 601500060, 601550060, 601560058, 601570053, 601520052, 601500060, 601510059, 601530051, 601540060, 601580023]);
|
||||
TownObj.AddObject(Charc, true);
|
||||
ClientCharacter = Charc;
|
||||
// local TownObj = Town(1);
|
||||
// local Charc = GameObject.CreateCharacter(0, [101590007, 27675, 601500060, 601550060, 601560058, 601570053, 601520052, 601500060, 601510059, 601530051, 601540060, 601580023]);
|
||||
// TownObj.AddObject(Charc, true);
|
||||
// ClientCharacter = Charc;
|
||||
|
||||
|
||||
// local Window = Sq_CreateWindow(_Select_Character_Window, "选择角色界面窗口", 0, 0, 1066, 600, 0);
|
||||
|
|
|
|||
|
|
@ -7,9 +7,16 @@
|
|||
class _IMouse_ extends _Yosin_Cursor {
|
||||
|
||||
NormalC = null;
|
||||
//普通状态0
|
||||
//普通状态0 //动态状态1
|
||||
State = 0;
|
||||
//当前帧数编号
|
||||
Idx = 0;
|
||||
//动态帧 当前帧数
|
||||
ActiveCurrentFrame = 0;
|
||||
//动态帧 总帧数
|
||||
ActiveFrameCount = 0;
|
||||
//动态帧 Timer
|
||||
ActiveFrameTimer = 0;
|
||||
|
||||
constructor() {
|
||||
NormalC = [];
|
||||
|
|
@ -26,12 +33,15 @@ class _IMouse_ extends _Yosin_Cursor {
|
|||
|
||||
//更换为0号指针
|
||||
Change(0);
|
||||
|
||||
//注册Proc
|
||||
_Game_Logic_Func_._IMouse_Proc <- Proc.bindenv(this);
|
||||
}
|
||||
|
||||
//初始化普通鼠标指针
|
||||
function InitSprite() {
|
||||
for (local i = 0; i< 254; i++) {
|
||||
local Sp = CL_SpriteObject("sprite/interface/newstyle/windows/cursor.img", i);
|
||||
local Sp = CL_SpriteFrameObject("sprite/interface/newstyle/windows/cursor.img", i);
|
||||
NormalC.push(Sp);
|
||||
}
|
||||
}
|
||||
|
|
@ -43,6 +53,14 @@ class _IMouse_ extends _Yosin_Cursor {
|
|||
base.Change(Sp);
|
||||
}
|
||||
|
||||
//更换动态鼠标指针
|
||||
function ChangeActive(Idx, Count) {
|
||||
State = 1;
|
||||
this.Idx = Idx;
|
||||
this.ActiveFrameCount = Count;
|
||||
this.ActiveCurrentFrame = 0;
|
||||
}
|
||||
|
||||
function OnMouseProc(MousePos_X, MousePos_Y) {
|
||||
|
||||
}
|
||||
|
|
@ -62,4 +80,18 @@ class _IMouse_ extends _Yosin_Cursor {
|
|||
Change(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function Proc(Dt, Listener) {
|
||||
if (State == 1) {
|
||||
ActiveFrameTimer += Dt;
|
||||
if (ActiveFrameTimer >= 160) {
|
||||
ActiveFrameTimer = 0;
|
||||
ActiveCurrentFrame += 1;
|
||||
if (ActiveCurrentFrame >= ActiveFrameCount) ActiveCurrentFrame = 0;
|
||||
local Sp = NormalC[Idx + ActiveCurrentFrame];
|
||||
base.Change(Sp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -486,7 +486,10 @@ class _Select_Character_Window extends Yosin_Window {
|
|||
BackGroundMusic.Pause();
|
||||
}
|
||||
SetVisible(false);
|
||||
//TODO 发送进入游戏请求
|
||||
//发送进入游戏请求
|
||||
MySocket.Send(PACKET_ID.SELECT_CHARACTER, {
|
||||
cid = UpCharacterList[CurrentSelectCharacterIdx].Info.cid
|
||||
})
|
||||
}.bindenv(this);
|
||||
AddUIChild(StartButton);
|
||||
}
|
||||
|
|
@ -522,8 +525,6 @@ class _Select_Character_Window extends Yosin_Window {
|
|||
LockBox.SetPosition(54 + (i * 142), 10);
|
||||
CharacterMaskBox.Addchild(LockBox);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -254,6 +254,7 @@ class _CreateCharacter extends Yosin_Window {
|
|||
//关闭创建界面
|
||||
NoticeBox.DestroyWindow();
|
||||
DestroyWindow();
|
||||
MySocket.Send(PACKET_ID.QUERY_CHARACTER_LIST, null);
|
||||
} else {
|
||||
// 创建失败.
|
||||
NoticeBox = _Yosin_MessageBox("创建失败.");
|
||||
|
|
@ -363,7 +364,7 @@ class _CreateCharacter extends Yosin_Window {
|
|||
local jobEnum = getJobEnum(jobIndex);
|
||||
MySocket.Send(7, {
|
||||
name = enterName,
|
||||
gkb = jobEnum,
|
||||
job = jobEnum,
|
||||
})
|
||||
}.bindenv(this);
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,9 @@ enum PACKET_ID {
|
|||
CHANGE_PASSWORD = 5
|
||||
//查询账号中的角色列表
|
||||
QUERY_CHARACTER_LIST = 9
|
||||
//选择角色
|
||||
SELECT_CHARACTER = 11
|
||||
//更换角色位置
|
||||
CHANGE_CHARACTER_POSITION = 13
|
||||
CHANGE_CHARACTER_POSITION = 10
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue