⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gameobject.h

📁 游戏框架
💻 H
字号:
// ***************************************************************
//  GameObject   version:  1.0
//  -------------------------------------------------------------
//	File Name:	GameObject.h
//	Created:	2007/07/18
//	Modified:	2007/07/18   15:28
//	Author:		William.Liang
//  Msn:		lwq49@msn.com
//  Email:		lwq49@21cn.com, lwq49@msn.com
//	Description:
//
//	Purpose:	
//  -------------------------------------------------------------
//  license:
//
//  The contents of this file are subject to the Mozilla Public
//  License Version 1.1 (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.mozilla.org/MPL/ Software dis-
//  tributed under the License is distributed on an "AS IS" 
//  basis, WITHOUT WARRANTY OF ANY KIND, either express or im-
//  plied. See the License for the specific language governing
//  rights and limitations under the License.
//
//  The Initial Developer of the Original Code is William.Liang .
//  Copyright (C) 2007 - All Rights Reserved.
// ***************************************************************
#ifndef GAME_OBJECT_HEAD_FILE
#define GAME_OBJECT_HEAD_FILE

#pragma once

#include "Objectcom.h"
//***************************************************************
//	基本游戏元素对象。
//	CGameObject是ObjectCom组件中的基类,其它扩展对象均基于该类。
//	该类实现了基本的对象移动、旋转、变形等方法和拥有对象名、是否
//	可视等属性。
//***************************************************************
class OBJECT_COM_CLASS CGameObject :
	public IGameObject, public IBaseObject
{
protected:
	IUnknownEx*			m_pParent;					//父对象
	BASALINFO			m_BasalInfo;				//基本资料
	GAMEBASALINFO		m_GameBasalInfo;			//对象信息
	TCHAR				m_szName[MAX_NAME];			//对象名称
	LPGDI				m_lpGDI;					//GDI句柄
	enGameObjectType	m_enGameType;				//对象类型
	bool				m_bClipping;				//是否剪载

public:
	//构造函数
	CGameObject(void);
	//析构函数
	virtual ~CGameObject(void);
private:
	//求区域
	virtual void __cdecl CalcRotateRegion();

	//扩展方法
public:
	//设置父对象
	virtual void __cdecl SetParent(IUnknownEx* pIUnknownEx);
	//返回父对象
	virtual IUnknownEx* __cdecl GetParent();

	//坐标相关
public:
	//移动对象
	virtual void __cdecl MoveTo(_POINT piPoint);
	//移动对象
	virtual void __cdecl MoveToOffset(_POINT piPoint);
	// 返回对象坐标相对于屏幕
	virtual _POINT __cdecl GetScreenPosition();
	// 返回对象相对于容器的坐标
	virtual _POINT __cdecl GetLocalPosition();
	// 返回对象容器坐标
	virtual _POINT __cdecl GetContainerPosition();
	//返回中心点
	virtual _POINT __cdecl GetAnchorPosition();
	//计算容器坐标
	virtual void __cdecl CalcContainerPosition();
	//屏幕坐标转本地坐标
	virtual _POINT __cdecl ScreenToLocal(_POINT piScreen);
	//本地坐标转屏幕坐标
	virtual _POINT __cdecl LocalToScreen(_POINT piLocal);

	//共通属性
public:
	//设置名字
	virtual void __cdecl SetObjectName(LPCTSTR lpName);
	//获取名字
	virtual LPCTSTR __cdecl GetObjectName();
	//设置类型
	virtual void __cdecl SetObjectType(enGameObjectType enGameObjectType);
	//返回类型
	virtual enGameObjectType __cdecl GetObjectType();
	//设置缓冲类型
	virtual void __cdecl SetCacheType(WORD wType);
	//返回缓冲类型
	virtual WORD __cdecl GetCacheType();
	//对象创建
	virtual bool __cdecl Create(LPCTSTR lpName, _SIZE siSize, enGameObjectType enType, ...);
	//设置可视
	virtual void __cdecl SetVisabled(bool bFlag);
	//设置禁用
	virtual void __cdecl SetDisabled(bool bFlag);
	//设置点击
	virtual void __cdecl SetClickabled(bool bFlag);
	//是否可视
	virtual bool __cdecl IsVisabled();
	//是否禁用
	virtual bool __cdecl IsDisabled();
	//是否可点击
	virtual bool __cdecl IsClickabled();
	//设置角度
	virtual void __cdecl SetAngle(float fAngle);
	//设置角度
	virtual void __cdecl SetAngleOffset(float fAngle);
	//设置透明
	virtual void __cdecl SetAlpha(WORD wAlpha);
	//设置透明
	virtual void __cdecl SetAlphaOffset(WORD wAlpha);
	//设置Z空间
	virtual void __cdecl SetZ(WORD wZ);
	//设置Z空间
	virtual void __cdecl SetZOffset(WORD wZ);
	//设置缩放
	virtual void __cdecl SetScaling(_SIZE siSize);
	//设置缩放
	virtual void __cdecl SetScalingOffset(_SIZE siSize);
	//设置深度
	virtual void __cdecl SetDepth(DWORD dwDepth);
	//设置中心
	virtual void __cdecl SetAnchorPosition(_POINT piPoint);
	//设置中心
	virtual void __cdecl SetAnchorPositionOffset(_POINT piPoint);
	//设置大小
	virtual void __cdecl SetSize(_SIZE siSize);
	//返回角度
	virtual float __cdecl GetAngle();
	//返回透明
	virtual WORD __cdecl GetAlpha();
	//返回Z空间
	virtual WORD __cdecl GetZ();
	//返回缩放
	virtual _SIZE __cdecl GetScaling();
	//返回深度
	virtual DWORD __cdecl GetDepth();
	//返回大小
	virtual _SIZE __cdecl GetSize();
	//返回区域
	virtual _RECT __cdecl GetRegion();
	//返回基本信息
	virtual BASALINFO& __cdecl GetBasalInfo();
	//返回基本信息
	virtual GAMEBASALINFO& __cdecl GetGameBasalInfo();
	//碰撞检测
	virtual bool __cdecl Hitting(IGameObject* IGameObject, bool bFlag);
	//碰撞检测
	virtual bool __cdecl Hitting(float x, float y);
	//对象渲染
	virtual void __cdecl Render(WPARAM wParam=NULL){return;};
	//设置剪裁
	virtual void __cdecl SetClipping(bool bFlag);
	//通知变动
	virtual void __cdecl NotifiyChange();

	//事件回调
public:
	//鼠标移动
	virtual bool __cdecl OnMouseMove(float x, float y, UINT nComboKey);
	//鼠标点击
	virtual bool __cdecl OnMouseClick(float x, float y, int nType, UINT nMessage, UINT nComboKey);
	//鼠标点击
	virtual bool __cdecl OnMouseDBClick(float x, float y, UINT nMessage, UINT nComboKey);
	////鼠标点击
	//virtual bool __cdecl OnMouseUp(float x, float y, int nKey);
	////鼠标点击
	//virtual bool __cdecl OnMouseDown(float x, float y, int nKey);
	//鼠标移入
	virtual bool __cdecl OnMouseIn(float x, float y, int nType, UINT nMessage, UINT nComboKey);
	//鼠标移出
	virtual bool __cdecl OnMouseOut(float x, float y, int nType, UINT nMessage, UINT nComboKey);
	//鼠标移过
	virtual bool __cdecl OnMouseOver(float x, float y, int nType, UINT nMessage, UINT nComboKey);
	//键盘事件
	virtual bool __cdecl OnKeyPass(TCHAR nKey, UINT nFlag);
	//键盘事件
	virtual bool __cdecl OnKeyUp(UINT nKey, UINT nFlag);
	//键盘事件
	virtual bool __cdecl OnKeyDown(UINT nKey, UINT nFlag);
	//每帧回调消息
	virtual bool __cdecl OnFrameEvent();
	//调用事件消息
	virtual bool __cdecl OnAttemperEvent();

	//Add By Randy
public:
	//失去焦点 Randy 8-27
	virtual void __cdecl FocusLost();
	//重获焦点 Randy 8-27
	virtual void __cdecl FocusGain();

	//模板方法
public:
	//是否有效
	virtual bool __cdecl IsValid() { return AfxIsValidAddress(this,sizeof(CGameObject))?true:false;};
	//释放对象
	virtual bool __cdecl Release() { if (IsValid()) delete this; return true; };
	//接口查询
	virtual void * __cdecl QueryInterface(const IID & Guid, DWORD dwQueryVer);

public:
	//操作重载
	CGameObject& operator=(const CGameObject& GameObject);

};

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -