Points Versus Pixels in Cocos2D

摘要: Points VS. PixelsWe should konw that Cocos2D uses a point system to help position objects on the normal iPhone display (480 × 320 pixels) and the retina display (960 × 640 pix- els).In the nonretina display a point equals a pixel, but in the retina display a point equals two pixels.When yo 阅读全文
posted @ 2013-01-03 00:10 紫澜 阅读(201) 评论(0) 推荐(0) 编辑

read from plist file

摘要: Read from .plist FileAn Exampletryplist.plistKeyTypeValueRootDictionary(2 items)subroot1Dictionary(3 items)name1Stringthis is string 1name2Number1.5name3Stringthis is string asubroot2Dictionary(3 items)name1Stringthis is string 2name2Number2.5name3Stringthis is string bCodecreate dictionary from fil 阅读全文
posted @ 2013-01-02 23:18 紫澜 阅读(307) 评论(0) 推荐(0) 编辑

cocos2d-iphone 区分ipad和iphone

摘要: iPad or iPhoneiPad if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {// indicates game is running on iPad}iPhoneelse {// indicates game is running on iPhone} 阅读全文
posted @ 2013-01-02 20:30 紫澜 阅读(228) 评论(0) 推荐(0) 编辑

Learning Cocos2D 资源下载链接

摘要: 第1至6章资源下载地址Resources in Chapter 1 to 6原下载地址Learning Cocos2d 阅读全文
posted @ 2013-01-02 19:57 紫澜 阅读(141) 评论(0) 推荐(0) 编辑

Animation Cache in Cocos2d-iphone v2.0.0

摘要: Animation Cache in Cocos2d-iphone v2.0.0你需要了解的 你至少需要先了解怎么使用Animation.你可以参考我的上一篇随笔:Animation in Cocos2d-iphone代码1.add animation to animation cache[[CCAnimationCache sharedAnimationCache] addAnimation: animation name: @"some_animation"];2.get animation from animation cacheid animation1 = [[C 阅读全文
posted @ 2013-01-02 16:07 紫澜 阅读(364) 评论(0) 推荐(0) 编辑

Animation in Cocos2d-iphone

摘要: Animation in Cocos2d-iphone v2.0.0What you need 1.a png file -- default.png 2.a plist file -- default.plist (anim01.png -- anim10.png) (you can get png file and plist file from: ) Zwoptex http://zwoptexapp.comTexturePacker http://texturepacker.comCocos2d-iphone code1.load plist file to CCSpriteFrame 阅读全文
posted @ 2013-01-02 15:52 紫澜 阅读(267) 评论(0) 推荐(0) 编辑

游戏框架类

摘要: #ifndef __Direct3DFrameH__#define __Direct3DFrameH__#include <Windows.h>#include <d3d9.h>#include <d3dx9.h>#include <MMSystem.h>#pragma warning(disable:4018)typedef void (*GAMEINITPROC)(void);typedef void (*GAMELOGICPROC)(float fElapsedTime);typedef void (*GAMERENDERPROC)(flo 阅读全文
posted @ 2012-05-22 00:37 紫澜 阅读(219) 评论(0) 推荐(0) 编辑

模型加载类

摘要: #ifndef __MeshH__#define __MeshH__#include <vector>using namespace std;struct SMesh{ ID3DXMesh* Mesh; vector<D3DMATERIAL9> Mtrls; vector<IDirect3DTexture9*> Textures;};#include <d3d9.h>#include <d3dx9.h>void CreateMesh(IDirect3DDevice9* pDevice, char* sName, SMesh& 阅读全文
posted @ 2012-05-22 00:03 紫澜 阅读(234) 评论(0) 推荐(0) 编辑

加载地形的类

摘要: #ifndef __TerrainH__#define __TerrainH__#include <d3d9.h>#include <d3dx9.h>#include <vector>using namespace std;struct TERRAIN_CUSTOMVERTEX{ FLOAT x, y, z; FLOAT a, b, c; FLOAT u, v; FLOAT tu, tv;};#define TERRAIN_D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX2)class 阅读全文
posted @ 2012-05-22 00:01 紫澜 阅读(251) 评论(0) 推荐(0) 编辑

游戏窗口风格

摘要: 游戏窗口创建时比较好的风格是 WS_POPUP ,没有任何多余的东西 阅读全文
posted @ 2012-05-21 23:59 紫澜 阅读(149) 评论(0) 推荐(0) 编辑

使用bink播放视频

摘要: // Video.h#ifndef __VideoH__#define __VideoH__#include <d3d9.h>#include <d3dx9.h>#include <vector>#include <fstream>using namespace std;#include "bink.h"#pragma comment(lib, "binkw32.lib")struct SVertexVideo{ D3DXVECTOR3 vPos; float fRHW; D3DXVECTOR2 vTex; 阅读全文
posted @ 2012-05-16 18:59 紫澜 阅读(995) 评论(1) 推荐(0) 编辑

[转]Rad Video Tools使用手册

摘要: Rad Video Tools包括Bink Video和Smacker(256色编码器)Bink Video是一个优于MPEG-II的编码方式。它压缩的图像的质量要远高于MPEG-II,并且能供提供3倍于MPEG-II的播放速度。Bink同时使用16种不同的压缩编码技术压缩视频图像(wavelet, DCT, motion compensation, a variety of vector quantizers, Smacker-style, etc)Bink使用基于心理声学的编码方式对声音进行编码,这种方式有能力提供8:1的压缩比例,同时声音质量几乎无失真。所以声音的表现将会和图像一样出色。 阅读全文
posted @ 2012-05-16 12:37 紫澜 阅读(6477) 评论(0) 推荐(0) 编辑

透射

摘要: 最终计算公式:float4 T; T.r = exp((-a.r)*C*distance)+0.000001; // C = 12.0f T.g = exp((-a.g)*C*distance)+0.000001; // distance = depth1 - depth2T.b = exp((-a.b)*C*distance)+0.000001; // a.r = (-log(Color.r))/Du ; Du = 1.0fT.w = 1; // Color为最暗的颜色,直接指定或者计算得到return T*BGColor 阅读全文
posted @ 2012-05-07 00:04 紫澜 阅读(249) 评论(0) 推荐(0) 编辑

波动+灰度图+噪点的简单实现

摘要: 纹理波动的一种简单方案:Tex.x += sin(fTimer+Tex.x*10)*0.01f; Tex.y += cos(fTimer+Tex.y*10)*0.01f;图片反相的简单实现:用1.0f或255减去当前每种颜色的值灰度图的简单实现:1、平均颜色-不推荐;2、灰度强度-人眼对绿色比红色和蓝色更加敏感,g=0.3R+0.59G+0.11B,推荐数值为(0.222,0.707,0.071)噪点-扭曲的简单实现:float NoiseX = iSeed * fTimer * sin(Tex.x * Tex.y+fTimer); //iSeed为随机种子NoiseX=fmod(NoiseX 阅读全文
posted @ 2012-05-06 22:12 紫澜 阅读(435) 评论(0) 推荐(0) 编辑

各种旋转表示方式间的转换

摘要: D3DXQuaternionToAxisAngle(); // 四元数 转 绕轴旋转D3DXQuaternionRotationAxis(); // 绕轴旋转 转 四元数D3DXQuaternionRotationMatrix(); //旋转矩阵 转 四元数D3DXQuaternionRotationYawPitchRoll(); //yawpitchroll 转四元数 阅读全文
posted @ 2012-05-06 00:02 紫澜 阅读(249) 评论(0) 推荐(0) 编辑

Vertex Shader 入门代码

摘要: /*This is a simple vertex shader program which illustrate how to use vertex shader instead of fixed pipeline to perform world, view and projection transform*/#include <d3dx9.h> #include <MMSystem.h>LPDIRECT3D9 g_pD3D = NULL ; // Used to create the D3DDevice LPDIRECT3D... 阅读全文
posted @ 2012-05-05 23:31 紫澜 阅读(1872) 评论(0) 推荐(0) 编辑

Dx多视口

摘要: 先定义视口,如D3DVIEWPORT9 g_ViewPort;然后设置视口参数,如:g_ViewPort.X = g_ViewPort.Y = 0;g_ViewPort.Width = g_ViewPort.Height = 100;g_ViewPort.MinZ= 1.0f;g_ViewPort.MaxZ = 1000.0f;最后启用视口,如:g_pDevice->SetViewport(&g_ViewPort);g_pDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(123,123 阅读全文
posted @ 2012-05-05 20:47 紫澜 阅读(301) 评论(0) 推荐(0) 编辑

Direct2D Simple

摘要: #define SAFE_RELEASE(p) if(p) { p->Release(); p = NULL; }// 2DID2D1Factory* g_pD2DFactory = NULL; // Direct2D factoryID2D1HwndRenderTarget* g_pD2DRenderTarget = NULL; // Direct2D render targetID2D1SolidColorBrush* g_pD2DBlackBrush = NULL; // A black brush fro Direct2DRECT g_D2DRect; // R... 阅读全文
posted @ 2012-05-05 20:36 紫澜 阅读(293) 评论(0) 推荐(0) 编辑

MFPLAY播放视频,可嵌入游戏中

摘要: #ifndef __PlayVedioH__#define __PlayVedioH__#include <new>#include <windows.h>#include <windowsx.h>#include <mfplay.h>#include <mferror.h>#include <shobjidl.h>#include <strsafe.h>#include <Shlwapi.h>#pragma comment(linker, \"\"/manifestdepend 阅读全文
posted @ 2012-05-02 17:12 紫澜 阅读(1031) 评论(0) 推荐(0) 编辑

Dx基本Camera类

摘要: #ifndef __CameraH__#define __CameraH__#include <d3d9.h>#include <d3dx9.h>#include <Windows.h>class CCamera{private:IDirect3DDevice9* m_pDevice;D3DXVECTOR3 m_vPos;POINT m_LastPoint;float m_fYaw, m_fPitch, m_fVelocity;bool m_bIsRot;private:void SetView();public:void SetCamera(IDirect 阅读全文
posted @ 2012-05-01 21:59 紫澜 阅读(431) 评论(0) 推荐(0) 编辑

多动画多动作基本控制的CAnimation类

摘要: //需要包含我之前写的SkinnedMesh.h#ifndef __AnimationH__#define __AnimationH__#include "SkinnedMesh.h"#include <d3d9.h>#include <d3dx9.h>#include <vector>using namespace std;struct SAnimationTime{float fStartTime, fEndTime;};struct SAnimation{LPD3DXFRAME pFrameRoot;ID3DXAnimationCo 阅读全文
posted @ 2012-05-01 21:58 紫澜 阅读(558) 评论(0) 推荐(0) 编辑

x文件处理的SkinnedMesh.h以及使用方法,从Direct3D sample改动得到

摘要: //-------------------文件名为SkinnedMesh.h----------------------#ifndef __SkinnedMeshH__#define __SkinnedMeshH__#include <Windows.h>#include <MMSystem.h>#include <d3d9.h>#include <d3dx9.h>#pragma comment(lib, "d3d9.lib")#pragma comment(lib, "d3dx9.lib")#pragma 阅读全文
posted @ 2012-05-01 17:50 紫澜 阅读(860) 评论(0) 推荐(1) 编辑

控制台和窗口应用程序转换

摘要: 工程属性->链接器->系统->子系统->窗口 (/SUBSYSTEM:WINDOWS)| 控制台 (/SUBSYSTEM:CONSOLE) 阅读全文
posted @ 2012-05-01 11:36 紫澜 阅读(341) 评论(0) 推荐(0) 编辑

ogre非缓冲消息处理

摘要: m_bMouseDown = false; //初始化//以下在每帧中bCurrentMouseDown = mMouse->getMouseState().buttonDown(OIS::MB_Left); //OIS::Mouse* mMouseif(bCurrentMouseDown && !m_bMouseDown){} //鼠标左键被按下m_bMouseDown = bCurrentMouseDown//获取当前鼠标键盘状态mMouse->capture();mKeyboard->capture();mKeyboard->isKeyDown(O 阅读全文
posted @ 2012-05-01 00:33 紫澜 阅读(203) 评论(0) 推荐(0) 编辑

ogre天空和雾

摘要: mSceneMgr->setSkyBox(true, "Examples/SpaceSkyBox"); //设置天空盒mSceneMgr->setSkyDome(true, "Examples/CloudySky", 5.0f, 8.0f); //设置天空穹Plane plane;plane.d = 1000.0f;plane.normal = Vector3::NEGATIVE_UNIT_Y;mSceneMgr->setSkyPlane(true, plane, "Examples/CloudySky", 1500 阅读全文
posted @ 2012-04-30 23:34 紫澜 阅读(569) 评论(0) 推荐(0) 编辑

ogre阴影

摘要: 开启阴影技术:mSceneMgr->setShadowTechnique(SHADOWTYPE_STENCIL_ADDITIVE);某个实体开启和关闭阴影:ent->setCastShadows(false);创建灯光:每个灯光产生一个阴影Light* light = mSceneMgr->createLight("Light1");light->setType(Light::LT_POINT);light->setPosition(Vector3(0.0f, 150.0f, 250.0f));light->setDiffuseColou 阅读全文
posted @ 2012-04-30 22:28 紫澜 阅读(734) 评论(0) 推荐(0) 编辑

ogre_机器人在10个位置循环走动

摘要: #include <ExampleApplication.h>#include <vector>#include <stdlib.h>#include <stdio.h>using namespace std;class MoveDemoListener : public ExampleFrameListener{protected:Vector3 mDirection;Vector3 mPosition;Real mMove;Real mDistance;Real mTime;AnimationState* mAnimationState;En 阅读全文
posted @ 2012-04-30 17:05 紫澜 阅读(681) 评论(0) 推荐(1) 编辑

ogre自动档初始化

摘要: #include <stdio.h>#include <ogre.h>using namespace Ogre;class MyLogListener:public LogListener{public:void messageLogged( const String& message, LogMessageLevel lml, bool maskDebug, const String &logName ){}};class MyFrameListener:public FrameListener{public:bool frameStarted(con 阅读全文
posted @ 2012-04-27 19:31 紫澜 阅读(175) 评论(0) 推荐(0) 编辑

mp3_CSound和CMusic类_转

摘要: #ifndef __MP3H__#define __MP3H__#define _AFXDLL#include <afx.h>#include <mmsystem.h>#include <mixerocx.h>class CSound {long m_device;MIXERCONTROL m_volCtrl;private:bool CSound::GetDevice(int dev,HMIXER &hmixer);public:CSound();virtual ~CSound();bool GetVolumeControl(HMIXER hmix 阅读全文
posted @ 2012-04-26 14:36 紫澜 阅读(706) 评论(0) 推荐(0) 编辑

文件监视_能用_但似乎不太完善

摘要: #include <stdio.h>#include <stdlib.h>#include <string.h>#include <Windows.h>#include <ShellAPI.h>#include <ShlObj.h>#include <ShTypes.h>#define WM_USERDEF_FILECHANGED 0x1000LRESULT CALLBACK WindowProc(HWND hWnd, int uMsg, WPARAM wParam, LPARAM lParam){switch 阅读全文
posted @ 2012-04-25 20:37 紫澜 阅读(497) 评论(0) 推荐(0) 编辑

CSound类源文件

摘要: #ifndef __SoundH__#define __SoundH__#include <dsound.h>#include "SDKwavefile.h"#include <vector>using namespace std;struct SSound{IDirectSoundBuffer8* pSoundBuffer;bool bLooping;SSound() { pSoundBuffer = 0; bLooping = false; }};class CSound{private:IDirectSound8* m_pSound;vecto 阅读全文
posted @ 2012-04-23 17:53 紫澜 阅读(966) 评论(0) 推荐(0) 编辑

使用DSound播放声音

摘要: HWND g_hWnd;IDirectSound8* g_pSound;IDirectSoundBuffer8* g_pSBuffer;CWaveFile* g_pWaveFile;DirectSoundCreate8(0, &g_pSound, 0);g_pSound->SetCooperativeLevel(g_hWnd, DSSCL_PRIORITY);g_pWaveFile = new CWaveFile;ZeroMemory(g_pWaveFile, sizeof(CWaveFile));HRESULT hr;hr = g_pWaveFile->Open(L&qu 阅读全文
posted @ 2012-04-23 16:53 紫澜 阅读(1650) 评论(0) 推荐(0) 编辑

简单播放声音PlaySound

摘要: 播放一次 PlaySoundA("test.wav", NULL, SND_FILENAME | SND_ASYNC);连续播放 PlaySoundA("test.wav", NULL, SND_FILENAME | SND_ASYNC | SND_LOOP);PlaySound的使用需要<mmsystem.h>和"winmm.lib" 阅读全文
posted @ 2012-04-23 16:10 紫澜 阅读(359) 评论(0) 推荐(0) 编辑

X文件的动画类及基本使用方法

摘要: ------------------------------Animation.h--------------------------------------没有Animation.cpp-----------#ifndef __AnimationH__#define __AnimationH__#include <d3d9.h>#include <d3dx9.h>//struct D3DXFRAME_DERIVED & D3DXMESHCONTAINER_DERIVEDstruct D3DXFRAME_DERIVED : public D3DXFRAME{D3 阅读全文
posted @ 2012-04-23 12:34 紫澜 阅读(862) 评论(0) 推荐(0) 编辑

1366X768成为全球最流行屏幕分辨率

摘要: 1366X768 2048x1536 1024x768 1280x800 阅读全文
posted @ 2012-04-23 10:32 紫澜 阅读(216) 评论(0) 推荐(0) 编辑

Vertex Shader And Pixel Shader

摘要: 顶点渲染管线(Vertex Shader)与像素渲染管线(Pixel Shader)是决定显卡性能的决定性因素,由于这两个渲染管线的设计都被标准化,nVIDIA和ATI只能通过增加其数量来达到快速提升性能的目的。顶点渲染单元(Vertex Shader)负责生成3D图像的骨架,三角形的每个顶点信息都是由它计算完成。相对像素渲染,顶点渲染的工作量要轻得多,但它承担了3D运算的基础工作,对GPU的最终效能有着决定性的影响。像素渲染(Pixel Shader)是3D处理中最关键的工作,大家在游戏中看到的大量水面波纹、反光、凹凸质感、旗帜飘扬之类的特效都是由它处理,任务量最为繁重、对性能的影响也最大。 阅读全文
posted @ 2012-04-23 09:36 紫澜 阅读(988) 评论(0) 推荐(0) 编辑

使用DXUT时需要附加的依赖项

摘要: version.lib;imm32.lib;comctl32.lib;d3dx10d.lib;d3dx9d.lib;dxerr.lib;dxguid.lib;winmm.lib;dsound.lib不一定全部要,但加了这些可以用 阅读全文
posted @ 2012-04-23 09:14 紫澜 阅读(147) 评论(0) 推荐(0) 编辑

高精度定时

摘要: BOOL QueryPerformanceFrequency(LARGE_INTEGER *lpFrequency);BOOL QueryPerformanceCounter (LARGE_INTEGER *lpCount); 阅读全文
posted @ 2012-04-22 22:51 紫澜 阅读(108) 评论(0) 推荐(0) 编辑