从cocos2d-html5中提取出来的,用做前端开发的框架——cc.js

  1. /****************************************************************************
  2. Copyright (c) 2010-2012 cocos2d-x.org
  3. Copyright (c) 2008-2010 Ricardo Quesada
  4. Copyright (c) 2011 Zynga Inc.
  5.  
  6. http://www.cocos2d-x.org
  7.  
  8. Permission is hereby granted, free of charge, to any person obtaining a copy
  9. of this software and associated documentation files (the "Software"), to deal
  10. in the Software without restriction, including without limitation the rights
  11. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. copies of the Software, and to permit persons to whom the Software is
  13. furnished to do so, subject to the following conditions:
  14.  
  15. The above copyright notice and this permission notice shall be included in
  16. all copies or substantial portions of the Software.
  17.  
  18. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24. THE SOFTWARE.
  25. ****************************************************************************/
  26. /* Managed JavaScript Inheritance
  27. * Based on John Resig's Simple JavaScript Inheritance http://ejohn.org/blog/simple-javascript-inheritance/
  28. * MIT Licensed.
  29. */
  30.  
  31. /**
  32. * @namespace
  33. */
  34. var cc = cc || {};
  35.  
  36. //
  37. function ClassManager(){
  38. //tells own name
  39. return arguments.callee.name || (arguments.callee.toString()).match(/^function ([^(]+)/)[1];
  40. }
  41. ClassManager.id=(0|(Math.random()*998));
  42. ClassManager.instanceId=(0|(Math.random()*998));
  43. ClassManager.compileSuper=function(func, name, id){
  44. //make the func to a string
  45. var str = func.toString();
  46. //find parameters
  47. var pstart = str.indexOf('(');
  48. var pend = str.indexOf(')');
  49. var params = str.substring(pstart+1, pend);
  50. params = params.trim();
  51.  
  52. //find function body
  53. var bstart = str.indexOf('{');
  54. var bend = str.lastIndexOf('}');
  55. var str = str.substring(bstart+1, bend);
  56.  
  57. //now we have the content of the function, replace this._super
  58. //find this._super
  59. while(str.indexOf('this._super')!= -1)
  60. {
  61. var sp = str.indexOf('this._super');
  62. //find the first '(' from this._super)
  63. var bp = str.indexOf('(', sp);
  64.  
  65. //find if we are passing params to super
  66. var bbp = str.indexOf(')', bp);
  67. var superParams = str.substring(bp+1, bbp);
  68. superParams = superParams.trim();
  69. var coma = superParams? ',':'';
  70.  
  71. //find name of ClassManager
  72. var Cstr = arguments.callee.ClassManager();
  73.  
  74. //replace this._super
  75. str = str.substring(0, sp)+ Cstr+'['+id+'].'+name+'.call(this'+coma+str.substring(bp+1);
  76. }
  77. return Function(params, str);
  78. };
  79. ClassManager.compileSuper.ClassManager = ClassManager;
  80. ClassManager.getNewID=function(){
  81. return this.id++;
  82. };
  83. ClassManager.getNewInstanceId=function(){
  84. return this.instanceId++;
  85. };
  86.  
  87. (function () {
  88. var initializing = false, fnTest = /\b_super\b/;
  89. var releaseMode = (document['ccConfig'] && document['ccConfig']['CLASS_RELEASE_MODE']) ? document['ccConfig']['CLASS_RELEASE_MODE'] : null;
  90. if(releaseMode) {
  91. console.log("release Mode");
  92. }
  93.  
  94. /**
  95. * The base Class implementation (does nothing)
  96. * @class
  97. */
  98. cc.Class = function () {
  99. };
  100.  
  101. /**
  102. * Create a new Class that inherits from this Class
  103. * @param {object} prop
  104. * @return {function}
  105. */
  106. cc.Class.extend = function (prop) {
  107. var _super = this.prototype;
  108.  
  109. // Instantiate a base Class (but only create the instance,
  110. // don't run the init constructor)
  111. var prototype = Object.create(_super);
  112.  
  113. var classId = ClassManager.getNewID();
  114. ClassManager[classId] = _super;
  115. // Copy the properties over onto the new prototype. We make function
  116. // properties non-eumerable as this makes typeof === 'function' check
  117. // unneccessary in the for...in loop used 1) for generating Class()
  118. // 2) for cc.clone and perhaps more. It is also required to make
  119. // these function properties cacheable in Carakan.
  120. var desc = { writable: true, enumerable: false, configurable: true };
  121. for (var name in prop) {
  122. if(releaseMode && typeof prop[name] == "function" && typeof _super[name] == "function" && fnTest.test(prop[name])) {
  123. desc.value = ClassManager.compileSuper(prop[name], name, classId);
  124. Object.defineProperty(prototype, name, desc);
  125. } else if(typeof prop[name] == "function" && typeof _super[name] == "function" && fnTest.test(prop[name])){
  126. desc.value = (function (name, fn) {
  127. return function () {
  128. var tmp = this._super;
  129.  
  130. // Add a new ._super() method that is the same method
  131. // but on the super-Class
  132. this._super = _super[name];
  133.  
  134. // The method only need to be bound temporarily, so we
  135. // remove it when we're done executing
  136. var ret = fn.apply(this, arguments);
  137. this._super = tmp;
  138.  
  139. return ret;
  140. };
  141. })(name, prop[name]);
  142. Object.defineProperty(prototype, name, desc);
  143. } else if(typeof prop[name] == "function") {
  144. desc.value = prop[name];
  145. Object.defineProperty(prototype, name, desc);
  146. } else{
  147. prototype[name] = prop[name];
  148. }
  149. }
  150. prototype.__instanceId = null;
  151.  
  152. // The dummy Class constructor
  153. function Class() {
  154. this.__instanceId = ClassManager.getNewInstanceId();
  155. // All construction is actually done in the init method
  156. if (this.ctor)
  157. this.ctor.apply(this, arguments);
  158. }
  159.  
  160. Class.id = classId;
  161. // desc = { writable: true, enumerable: false, configurable: true,
  162. // value: XXX }; Again, we make this non-enumerable.
  163. desc.value = classId;
  164. Object.defineProperty(prototype, '__pid', desc);
  165.  
  166. // Populate our constructed prototype object
  167. Class.prototype = prototype;
  168.  
  169. // Enforce the constructor to be what we expect
  170. desc.value = Class;
  171. Object.defineProperty(Class.prototype, 'constructor', desc);
  172.  
  173. // And make this Class extendable
  174. Class.extend = arguments.callee;
  175.  
  176. //add implementation method
  177. Class.implement = function (prop) {
  178. for (var name in prop) {
  179. prototype[name] = prop[name];
  180. }
  181. };
  182. return Class;
  183. };
  184.  
  185. Function.prototype.bind = Function.prototype.bind || function (bind) {
  186. var self = this;
  187. return function () {
  188. var args = Array.prototype.slice.call(arguments);
  189. return self.apply(bind || null, args);
  190. };
  191. };
  192.  
  193. })();
  194.  
  195. //my only
  196. cc.ArrayRemoveObject = function (arr, delObj) {
  197. for (var i = 0, l = arr.length; i < l; i++) {
  198. if (arr[i] == delObj) {
  199. arr.splice(i, 1);
  200. break;
  201. }
  202. }
  203. };
  204. cc.log = function (message) {
  205. if (!cc.IS_SHOW_DEBUG_ON_PAGE) {
  206. console.log.apply(console, arguments);
  207. } else {
  208. cc._logToWebPage(message);
  209. }
  210. };
  211. cc.NODE_TAG_INVALID = -1;
  212.  
  213. cc.s_globalOrderOfArrival = 1;
  214.  
  215. cc.Node = cc.Class.extend(/** @lends cc.Node# */{
  216. _zOrder:0,
  217. // children (lazy allocs),
  218. _children:null,
  219. _parent:null,
  220. _tag:cc.NODE_TAG_INVALID,
  221. _orderOfArrival:0,
  222. _initializedNode:false,
  223. _initNode:function () {
  224. this._children = [];
  225. this._initializedNode = true;
  226. },
  227. ctor:function () {
  228. if (this._initializedNode === false)
  229. this._initNode();
  230. return true;
  231. },
  232. init:function () {
  233. if (this._initializedNode === false)
  234. this._initNode();
  235. return true;
  236. },
  237. _child:function(func){
  238. var arr=this._children
  239. if(arr.length){
  240. for (i = 0; i < arr.length; i++) {
  241. if(false==arr[i]._child(func)){
  242. return false
  243. }
  244. }
  245. }
  246.  
  247. if(func.apply(this)==false){
  248. return false
  249. }
  250. return true
  251. },
  252. _arrayMakeObjectsPerformSelector:function (array, callbackType) {
  253. if (!array || array.length === 0)
  254. return;
  255.  
  256. var i, len = array.length,node;
  257. var nodeCallbackType = cc.Node.StateCallbackType;
  258. switch (callbackType) {
  259. case nodeCallbackType.onEnter:
  260. for (i = 0; i < len; i++) {
  261. node = array[i];
  262. if (node)
  263. node.onEnter();
  264. }
  265. break;
  266. case nodeCallbackType.onExit:
  267. for (i = 0; i < len; i++) {
  268. node = array[i];
  269. if (node)
  270. node.onExit();
  271. }
  272. break;
  273. case nodeCallbackType.cleanup:
  274. for (i = 0; i < len; i++) {
  275. node = array[i];
  276. if (node)
  277. node.cleanup();
  278. }
  279. break;
  280. case nodeCallbackType.updateTransform:
  281. for (i = 0; i < len; i++) {
  282. node = array[i];
  283. if (node)
  284. node.updateTransform();
  285. }
  286. break;
  287. case nodeCallbackType.sortAllChildren:
  288. for (i = 0; i < len; i++) {
  289. node = array[i];
  290. if (node)
  291. node.sortAllChildren();
  292. }
  293. break;
  294. default :
  295. throw "Unknown callback function";
  296. break;
  297. }
  298. },
  299.  
  300. getZOrder:function () {
  301. return this._zOrder;
  302. },
  303.  
  304. _setZOrder:function (z) {
  305. this._zOrder = z;
  306. },
  307.  
  308. setZOrder:function (z) {
  309. this._setZOrder(z);
  310. if (this._parent)
  311. this._parent.reorderChild(this, z);
  312. },
  313.  
  314. reorderChild:function (child, zOrder) {
  315. if(!child)
  316. throw "cc.Node.reorderChild(): child must be non-null";
  317. child.setOrderOfArrival(cc.s_globalOrderOfArrival++);
  318. child._setZOrder(zOrder);
  319. this._reorderChildDirty = true;
  320. },
  321.  
  322. getChildrenCount:function () {
  323. return this._children.length;
  324. },
  325.  
  326. getChildren:function () {
  327. return this._children;
  328. },
  329.  
  330. isRunning:function () {
  331. return this._running;
  332. },
  333.  
  334. getParent:function () {
  335. return this._parent;
  336. },
  337.  
  338. setParent:function (Var) {
  339. this._parent = Var;
  340. },
  341.  
  342. getTag:function () {
  343. return this._tag;
  344. },
  345.  
  346. setTag:function (Var) {
  347. this._tag = Var;
  348. },
  349.  
  350. getChildByTag:function (aTag) {
  351. var __children = this._children;
  352. if (__children != null) {
  353. for (var i = 0; i < __children.length; i++) {
  354. var node = __children[i];
  355. if (node && node._tag == aTag)
  356. return node;
  357. }
  358. }
  359. //throw "not found";
  360. return null;
  361. },
  362.  
  363. addChild:function (child, zOrder, tag) {
  364. if(!child)
  365. throw "cc.Node.addChild(): child must be non-null";
  366. if (child === this) {
  367. cc.log('cc.Node.addChild(): An Node can\'t be added as a child of itself.');
  368. return;
  369. }
  370.  
  371. if (child._parent !== null) {
  372. cc.log("cc.Node.addChild(): child already added. It can't be added again");
  373. return;
  374. }
  375.  
  376. var tmpzOrder = (zOrder != null) ? zOrder : child._zOrder;
  377. child._tag = (tag != null) ? tag : child._tag;
  378. this._insertChild(child, tmpzOrder);
  379. child._parent = this;
  380.  
  381. if (this._running) {
  382. child.onEnter();
  383. }
  384. },
  385.  
  386. removeFromParent:function (cleanup) {
  387. if (this._parent) {
  388. if (cleanup == null)
  389. cleanup = true;
  390. this._parent.removeChild(this, cleanup);
  391. }
  392. },
  393.  
  394. removeChild:function (child, cleanup) {
  395. // explicit nil handling
  396. if (this._children.length === 0)
  397. return;
  398.  
  399. if (cleanup == null)
  400. cleanup = true;
  401. if (this._children.indexOf(child) > -1)
  402. this._detachChild(child, cleanup);
  403.  
  404. },
  405.  
  406. removeChildByTag:function (tag, cleanup) {
  407. if(tag === cc.NODE_TAG_INVALID)
  408. cc.log("cc.Node.removeChildByTag(): argument tag is an invalid tag");
  409.  
  410. var child = this.getChildByTag(tag);
  411. if (child == null)
  412. cc.log("cocos2d: removeChildByTag(tag = " + tag + "): child not found!");
  413. else
  414. this.removeChild(child, cleanup);
  415. },
  416.  
  417. removeAllChildren:function (cleanup) {
  418. // not using detachChild improves speed here
  419. var __children = this._children;
  420. if (__children != null) {
  421. if (cleanup == null)
  422. cleanup = true;
  423. for (var i = 0; i < __children.length; i++) {
  424. var node = __children[i];
  425. if (node) {
  426. // IMPORTANT:
  427. // -1st do onExit
  428. // -2nd cleanup
  429. if (this._running) {
  430. node.onExit();
  431. }
  432. if (cleanup)
  433. node.cleanup();
  434. // set parent nil at the end
  435. node.setParent(null);
  436. }
  437. }
  438. this._children.length = 0;
  439. }
  440. },
  441.  
  442. _detachChild:function (child, doCleanup) {
  443. // IMPORTANT:
  444. // -1st do onExit
  445. // -2nd cleanup
  446. if (this._running) {
  447. child.onExit();
  448. }
  449.  
  450. // If you don't do cleanup, the child's actions will not get removed and the
  451. // its scheduledSelectors_ dict will not get released!
  452. if (doCleanup)
  453. child.cleanup();
  454.  
  455. // set parent nil at the end
  456. child.setParent(null);
  457.  
  458. cc.ArrayRemoveObject(this._children, child);
  459. },
  460.  
  461. _insertChild:function (child, z) {
  462. this._children.push(child);
  463. child._setZOrder(z);
  464. this._reorderChildDirty = true;
  465. },
  466.  
  467. setOrderOfArrival:function (Var) {
  468. this._orderOfArrival = Var;
  469. },
  470.  
  471. sortAllChildren:function () {
  472. if (this._reorderChildDirty) {
  473. var _children = this._children;
  474. var i, j, length = _children.length,tempChild;
  475.  
  476. // insertion sort
  477. for (i = 0; i < length; i++) {
  478. var tempItem = _children[i];
  479. j = i - 1;
  480. tempChild = _children[j];
  481.  
  482. //continue moving element downwards while zOrder is smaller or when zOrder is the same but mutatedIndex is smaller
  483. while (j >= 0 && ( tempItem._zOrder < tempChild._zOrder ||
  484. ( tempItem._zOrder == tempChild._zOrder && tempItem._orderOfArrival < tempChild._orderOfArrival ))) {
  485. _children[j + 1] = tempChild;
  486. j = j - 1;
  487. tempChild = _children[j];
  488. }
  489. _children[j + 1] = tempItem;
  490. }
  491.  
  492. //don't need to check children recursively, that's done in visit of each child
  493. this._reorderChildDirty = false;
  494. }
  495. },
  496.  
  497. onEnter:function () {
  498. this._running = true;//should be running before resumeSchedule
  499. this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.onEnter);
  500.  
  501. },
  502.  
  503. onExit:function () {
  504. this._running = false;
  505. this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.onExit);
  506.  
  507. },
  508. cleanup:function () {
  509. // timers
  510. this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.cleanup);
  511. },
  512. updateTransform:function () {
  513. // Recursively iterate over children
  514. this._arrayMakeObjectsPerformSelector(this._children, cc.Node.StateCallbackType.updateTransform);
  515. }
  516.  
  517. });
  518.  
  519. cc.Node.create = function () {
  520. return new cc.Node();
  521. };
  522.  
  523. cc.Node.StateCallbackType = {onEnter:1, onExit:2, cleanup:3, updateTransform:5, sortAllChildren:7};
  524.  
  525. cc.Sprite=cc.Node.extend({
  526. })
  527. cc.Sprite.create = function () {
  528. return new cc.Sprite();
  529. };
  530. cc.Layer=cc.Node.extend({
  531. })
  532. cc.Layer.create = function () {
  533. return new cc.Layer();
  534. };
  535. cc.Scene=cc.Node.extend({
  536. })
  537. cc.Scene.create = function () {
  538. return new cc.Scene();
  539. };
  540. cc.Middle=function(){
  541. var next=function(func1,func2){
  542. return function(){
  543. var arg=Array.prototype.slice.call(arguments)
  544. var arr=[].concat(arg)
  545. arg.push(function(){
  546. func2.apply(this,arr)
  547. })
  548. return func1.apply(this,arg);
  549. }
  550. }
  551. var arg=Array.prototype.slice.call(arguments)
  552. var func=arg[arg.length-1]
  553. for(var i=arg.length-2;i>=0;i--){
  554. func=next(arg[i],func)
  555. }
  556. return func
  557. }
  558. cc.Director={
  559. _runningScene:null,
  560. replaceScene:function(scene){
  561. if(this._runningScene){
  562. this._runningScene.onExit()
  563. }
  564. scene.onEnter()
  565. scene._arrayMakeObjectsPerformSelector(scene._children, cc.Node.StateCallbackType.sortAllChildren);
  566. this._runningScene=scene
  567.  
  568. }
  569. }

cc.js源码

不好意思又一次用别人的东西………

cocos2d-html5框架无疑是一款优秀、出色的跨平台的开源游戏框架,历经众多产品的考验,核心类cc.Node采用多叉树的结构、cc.Class类可以方便自由的扩充新的对象,一切都是如此美好,使用了一年多时间的cocos2d框架,也做过一些jsb的移植开发,深刻的感受到了coco2d做游戏开发的便利和强大,赞一个!

同时我也在想,前端开发是不是也能方便的用到cocos2d呢?特别是现在的移动web开发,页面的交互逻辑特别多,跟游戏如此相似,所以小wo努力思考、客观实践,终于把coco2d中的核心cc.Class和cc.Node提取出来了(去掉与游戏相关的属性和方法),新添加了cc.Middle(http://www.cnblogs.com/caoke/p/middle.html),也重写了下cc.Director的replaceScene.

工具准备好了,剩下就等着下周1的项目开始了

  1. var layer1=cc.Layer.extend({
  2.     context:$("#id"),
  3.     name:true,
  4.     init:function(){
  5.  
  6.     },
  7.     initAnimate:function(){
  8.       var sprite=new cc.Sprite
  9.       sprite.name=22
  10.       this.addChild(sprite,2)
  11.       var sprite=new cc.Sprite
  12.       sprite.name=32
  13.       this.addChild(sprite,1)
  14.       var sprite=new cc.Sprite
  15.       sprite.name=42
  16.       this.addChild(sprite,1)
  17.       var sprite=new cc.Sprite
  18.  
  19.       this.addChild(sprite,1)
  20.   },
  21. //点击交互事件
  22.   initMenu:function(){
  23.   },
  24. })
  25. var Scene1=cc.Scene.extend({
  26.   init:function(){
  27.     this._super()
  28.     var layer=new layer1()
  29.     layer.init()
  30.     this.addChild(layer)
  31.   }
  32. })
  33. var scene=new Scene1()
  34. scene.init()
  35. //显示页面
  36. scene.onEnter()
  37.  

最终效果: http://weixin.koo.cn/test.html

从cocos2d-html5中提取出来的,用做前端开发的框架——cc.js的更多相关文章

  1. html5中视频播放问题总结

    html5中视频播放问题总结 文章 1.问题一 框架? 加个标签就OK! <video id="video1" src="/video1.mp4" con ...

  2. web前端开发学习:jQuery的原型中的init

    web前端开发学习:jQuery的原型中的init 有大量web前端开发工具及学习资料,可以搜群[ web前端学习部落22群 ]进行下载,遇到学习问题也可以问群内专家以及课程老师哟 jQuery.fn ...

  3. html5中的video标签和audio标签

    不管是否承认,flash早已不像过往那样如日中天了.亚马逊全面放弃flash.苹果放弃flash.安卓也放弃了移动端的flash支持.事实上flash已经不太适合web开发了,因为HTML5中的vid ...

  4. html5中time元素详解

    html5中time元素详解 一.总结 一句话总结: time的使用的话主要是将时间放在datetime属性里面:<time datetime="2015-10-22"> ...

  5. html5中canvas的使用 获取鼠标点击页面上某点的RGB

    1.html5中的canvas在IE9中可以跑起来.在IE8则跑不起来,这时候就需要一些东西了. 我推荐这种方法,这样显得代码不乱. <!--[if lt IE9]> <script ...

  6. [数据科学] 从csv, xls文件中提取数据

    在python语言中,用丰富的函数库来从文件中提取数据,这篇博客讲解怎么从csv, xls文件中得到想要的数据. 点击下载数据文件http://seanlahman.com/files/databas ...

  7. html5中新增的form表单属性

    html5中新增两个表单属性,分别autocomplete和novalidate属性 1.autocomplete属性 该属性用于控制自动完成功能的开启和关闭.可以设置表单或者input元素,有两个属 ...

  8. HTML5 中的 canvas 画布(一)

    ---恢复内容开始--- 在HTML5中新添加的元素,canvas 现在支持 IE9+的版本 注意:HTML5 <canvas> 元素用于图形的绘制,通过脚本 (通常是JavaScript ...

  9. 如何使用免费PDF控件从PDF文档中提取文本和图片

             如何使用免费PDF控件从PDF文档中提取文本和图片 概要 现在手头的项目有一个需求是从PDF文档中提取文本和图片,我以前也使用过像iTextSharp, PDFBox 这些免费的PD ...

随机推荐

  1. Luogu 1379 八数码难题

    吐槽:此题就是一点一点卡过去的 警告: 1.千万不能用dfs搜这种东西(dfs需要遍历所有状态才能找到最优解), 分分钟爆炸 2.写结构体的时候要综合判断&的加和不加 Code: // luo ...

  2. Yii2验证登录得User类

    Yii2中的  Class yii\web\User 是如果进行验证登录,如果我们使用User类验证登录会给我们减少很多麻烦.在此就拿Yii2中自带的登录功能进行说明. 配置.在应用配置文件compo ...

  3. 跨域问题hbuilder

    1.借助jquery-jsonp插件 $.jsonp({ url: url, data: { 'name': usd, 'passwd': pass }, callbackParameter: &qu ...

  4. JavaScript -- Array中的push()方法和concat()方法介绍

    Array => push()方法向数组的末尾添加一个或者多个元素,也就是说它会改变数组本身 concat() => concat()方法用于连接2个或者多个数组,但它的特殊之处在于,它会 ...

  5. Terminologies in MVC: Part 2 (Razor Engine Syntax vs Web Form)

    By Abhishek Jaiswal :) on Mar 21, 2015 In this article we learn about Razor Engine Syntax vs Web For ...

  6. css总结4:input 去掉外边框,placeholder的字体颜色、字号

    1 input 标签去除外边框: 在进行webAPP开发时,input外边框非常影响美观,去除外边框方法如下: <input style="border: 0px;outline:no ...

  7. 编写高质量代码改善C#程序的157个建议——建议38:小心闭包中的陷阱

    建议38:小心闭包中的陷阱 先看一下下面的代码,设想一下输出的是什么? static void Main(string[] args) { List<Action> lists = new ...

  8. eclipse中的项目无法在build/classes目录下生成.class字节码

    转载 原文链接:https://www.cnblogs.com/iceblow/p/6648715.html 1.首先确定project->Build Automatically是否勾选上:  ...

  9. Python实现wc.exe

    github传送门 项目相关要求 基本功能 -c file.c 返回文件file.c的字符数 (实现) -w file.c 返回文件file.c的词的数目(实现) -l file.c 返回文件file ...

  10. Android Canvas的save(),saveLayer()和restore()浅谈

    save()  saveLayer()  restore() 1.在自定义控件当中你onMeasure和onLayout的工作做完成以后就该绘制该控件了,有时候需要自己在控件上添加一些修饰来满足需求 ...