redux-devtools.md

Redux DevTools Features Lets you inspect every state and action payload Lets you go back in time by “cancelling” actions If you change the reducer code, each “staged” action will be re-evaluated If the reducers throw, you will see during which action this happened, and what the error was With persistState() store enhancer, you can persist debug sessions across page reloads Overview Redux DevTools is a development time package that provides power-ups for your Redux development workflow.
Read more →

redux.md

Redux Redux is a predictable state container for JavaScript apps. Testimonials “Love what you’re doing with Redux” Jing Chen, creator of Flux “I asked for comments on Redux in FB’s internal JS discussion group, and it was universally praised. Really awesome work.” Bill Fisher, author of Flux documentation “It’s cool that you are inventing a better Flux by not doing Flux at all.” André Staltz, creator of Cycle Developer Experience I wrote Redux while working on my React Europe talk called “Hot Reloading with Time Travel”.
Read more →

rlang.md

Read more →

snake-game1.md

从零开始设计一个类贪吃蛇的框架(一) 从零开始设计一个类贪吃蛇的框架(二) 从零开始设计一个类贪吃蛇的框架(三) 先看看粗糙的效果图 首先在quick-cocos2dx中生成一个模板 设计一个舞台场景 关于场景的分割和布局 我们可以把屏幕分割尾行和列 在 snakeController.lua中定义这个变量,我们很多的坐标计算按这个格栅来 COLUMNS = 15 ROWS = 20 构建场景 snakeController.lua中输入以下代码 local SnakeGameController = class("SnakeController", function() return display.newScene("SnakeController") end) function SnakeGameController:ctor() self.layer = display.newLayer() self:addChild(self.layer) end function SnakeGameController:onTouch(event, x, y) end function SnakeGameController:onEnter() self.layer:addTouchEventListener(function(event, x, y) return self:onTouch(event, x, y) end) self.layer:setTouchEnabled(true) self:Play() end function SnakeGameController:Play() end return SnakeGameController 很简单的,我们设计一个场景,然后添加了onEnter函数 场景有一个图层 可以响应触摸事件 画个方框 下一步要在图层中实现画图,简单绘出一个方框 function SnakeGameController:drawGridNode(x,y,color) local node = display.newRect(45, 45) node:setFill(true) node:setColor(color) node:setLineWidth(3) node:setPosition(x,y) self.
Read more →

snake-game2.md

从零开始设计一个类贪吃蛇的框架(二) 从零开始设计一个类贪吃蛇的框架(一) 从零开始设计一个类贪吃蛇的框架(三) 画蛇身 画出蛇身也很简单,可以把蛇想象成很多节,每节就是一个方框 画蛇全身就是把多个方框连接起来 首先我们定义蛇的一些基本属性 snake ={ x={}, y={}, nodes=5, nodeArray={}, direction=1, life=1, sprite=nil, brain=nil } 其中x和y是我们用来存放每节蛇身坐标的数组 我们的node是蛇身节的数量 首先画蛇身的函数添加到Play中 function SnakeGameController:Play() self:drawSnakeNode(RED) end 接下来就是画蛇身的函数 在ctor函数中增加以下代码来初始化蛇的属性 for i=1,snake["nodes"] do snake["x"][i] = display.cx - (COLUMN-i) *45 snake["y"][i] = display.cy - (ROW-1) *45 print(snake["x"][i]..snake["y"][i]) end 在文件中增加以下函数 function SnakeGameController:drawSnakeNode(color) for i=1,snake["nodes"] do local node = self:drawGridNode(snake["x"][i],snake["y"][i],color) end end 这样我们的蛇就画出来了! 让蛇动起来 激动人心的时候到了,让蛇动起来。 动画离不开帧的概念,我们的思路就是,每一帧把蛇身末尾的一节去除,在头部增加一节,这样蛇身就产生了移动效果了 先增加一个函数SnakeGameController:moveSnake function SnakeGameController:moveSnake() print("original coordinates") local lenght = snake["nodes"] for i=1,snake["nodes"] do--/*蛇每环节往前移动,也贪吃蛇关键算法*/ print(snake["x"][i].
Read more →