Archive for category Uncategorized

Cocos2D基本概念

基本概念

Cocos2D由下面这些基本概念:

  • Scenes
  • Director
  • Layers
  • Sprites

Scense 场景

场景是一个相对独立的流程,对于游戏来说,可能会有这些场景:开场动画,主菜单,第一关,过场动画,第二关。。。。最终过关动画,最高分等等。场景也常常叫做screen或者stage。

每个场景包含多个Layer

Director 导演

CCDirector 负责场景间的调度,也就是怎样,何时从一个场景切换到另一个场景。

CCDirector是一个共享的对象(singleton),它知道当前活动场景,并且维持一个场景堆栈,用来实现(scene calls,也就是暂停一个场景,切换到另一个,并且可以回到暂停的场景继续执行)。

同时,CCDirector还负责初始化OpenGL ES。

Layers 层

CCLayer 对象的size是整个drawable区域,并且可以自己绘制自己。每个层可以是透明,半透明或者部分透明的(例如,不透明的层上有一些透明的洞,可以看到下面的层)。层定义了表现和行为,所以大部分的程序量是编写CCLayer的子类。

CCLayer也是定义事件驱动的地方。事件在各个层中从上到下传递,直到有一层处理它为止。

Cocos2D也提供了很多现成的CCLayer子类可供直接使用。

Sprites 精灵

cocos2d’ sprite是2D的image,可以移动,旋转,缩放以及动画。

精灵可以有父子关系,父精灵移动,旋转等变换时,子精灵也跟随变换。

No Comments

game engine again

下面介绍几个重量级的game engine

  • Unity3D是一个完整的跨平台的game engine,同样的source可以在PC,mac,网页,ios,android和游戏机等多个平台运行(当然对于不同平台的license费用不同)。
  • UDK – Epic公司的Unreal Development Kit,鼎鼎大名的Unreal engine, 听说过这些游戏么?他们有一个共同点,都使用了Unreal Engine。Gears of War, Mass Effect, BioShock, Unreal Tournament, Deus Ex, GRAW, Red Steel, Borderlands, Brothers in Arms, Homefront, Mirror’s Edge, Singularity, Rainbow Six: Vegas. UDK支持各个平台,包括IOS和android的游戏开发,对于教育和非商业应用免费,商业应用需要商业license,具体为99美金的 license费用。另外收入超过5万美金的部分要分给Epic 25%的分成
  • Panda3D 是一个免费开源的3D渲染和game engine,采用修改过的BSD license,可以用于商业开发。Panda3D的核心使用C++写成,提供pythyon bindding所以游戏开发的大部分工作都可以用python进行。Panda3D是由迪士尼为他们的大型多人在线游戏“Toontown”(卡通城) 而开发的。2002年它作为免费软件发布。Panda3D 现在由迪士尼和卡耐基梅隆大学娱乐技术中心联合开发。

, , , ,

No Comments

upgrade to 321

升级到最新的wordpress3.2.1,貌似没有问题

No Comments

django 403 error

遇到一个奇怪的问题,一个很简单的django页面,GET方式可以正常访问但是在POST报403错误。

后来查到是1.3版本settings.py 文件中 ‘django.middleware.csrf.CsrfViewMiddleware’, 造成的,把这句注掉就可以了。

No Comments

Sunrise@PoonHill

Sunrise@PoonHill by johnskiller
Sunrise@PoonHill, a photo by johnskiller on Flickr.

第一次看到日照金山,壮观的雪山日出

No Comments

a photo by bruce zhou

IMGP6889 by Bruce Zhou
IMGP6889, a photo by Bruce Zhou on Flickr.

nice work, maybe more detail in the sky is better

No Comments

Croissants de France

image

image

最近经常在这家吃饭,红酒牛肉是我的最爱,奶油蘑菇汤也不错,不过我也会做,不亚于他们的

No Comments

iPad2 rumers

iPad2的谣言现在已经漫天飞了,总结如下(括号中是ipad一代的数据):

  • Multi-core ARM Cortex-A9 CPU (single-core ARM Cortex-A8)
  • Dual-core SGX543 GPU (single-core SGX535)
  • 2048 x 1536 display at 260 dpi (1024 x 768 at 132 dpi)
  • GSM/CDMA chipset (GSM only)
  • Front- and rear-facing cameras
  • SD card slot
  • Redesigned, flatter case

其中retina液晶屏的分辨率为260 dpi,比iphone4的326 dpi要低一些,也没达到一般人视力极限的300 dpi,不过考虑到现在17寸的macbook pro不过只有1920×1200,这个分辨率已经很惊人了。

其他谣言还有4月上市,怎么办?等着呗。

 

,

No Comments

Pasta

某人就要去意大利了,先学学各种意面的叫法吧。

其实我只知道Spaghetti,Maccheroni这么两种。

No Comments

Useful VIM Settings

 Useful VIM Settings for working with Python:

Setting Abbr. Explanation
tabstop=4 ts A four-space tab indent width is the prefered coding style for Python (and everything else!), although of course some disagree. This page generally assumes you want 4-space indents.
shiftwidth=4 sw This allows you to use the < and > keys from VIM’s visual (marking) mode to block indent/unindent regions
smarttab sta Use the “shiftwidth” setting for inserting <TAB>s instead of the “tabstop” setting, when at the beginning of a line. This may be redundant for most people, but some poeple like to keep their tabstop=8 for compatability when loading files, but setting shiftwidth=4 for nicer coding style.
expandtab et Insert spaces instead of <TAB> character when the <TAB> key is pressed. This is also the prefered method of Python coding, since Python is especially sensitive to problems with indenting which can occur when people load files in different editors with different tab settings, and also cutting and pasting between applications (ie email/news for example) can result in problems. It is safer and more portable to use spaces for indenting.
softtabstop=4 sts People like using real tab character instead of spaces because it makes it easier when pressing BACKSPACE or DELETE, since if the indent is using spaces it will take 4 keystrokes to delete the indent. Using this setting, however, makes VIM see multiple space characters as tabstops, and so <BS> does the right thing and will delete four spaces (assuming 4 is your setting).
autoindent ai Very painful to live without this (especially with Python)! It means that when you press RETURN and a new line is created, the indent of the new line will match that of the previous line.
     
     
Remember. You can do :help command to get more info on these settings from inside VIM.

 

More complicated settings:


SmartIndent

The following line sets the smartindent mode for *.py files. It means that after typing lines which start with any of the keywords in the list (ie. def, class, if, etc) the next line will automatically indent itself to the next level of indentation:

autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class

Another approach is to create a key mapping which detects when you type a colon (:) followed by a RETURN (<CR>), and adds a <TAB> keypress to the end.

im :<CR> :<CR><TAB>


Trim Trailing Whitespace

Many people like to remove any extra whitespace from the ends of lines. Here is one way to do it when saving your file.

autocmd BufWritePre *.py normal m`:%s/\s\+$//e ``


No Comments