慕无忌4252426
2016-05-08 20:38
require "app.Common"
local Fence = require "app.Fence"
require "app.CollideManager"
local Block = require "app.Block"
local EditorScene = class("EditorScene",function ()
return display.newScene("EditorScene")
end)
function EditorScene:onEnter()
self.fence = Fence.new(cBound,self)
self.curX = 0
self.curY = 0
self.curIndex = 0
self:SwitchCursor(1)
self:ProcessInput()
end
local cMaxBlock = 3
function EditorScene:SwitchCursor( delta )
if self.cur == nil then
self.cur = Block.new(self)
end
local newIndex = self.curIndex + delta
newIndex = math.max(newIndex,1)
newIndex = math.min(newIndex,cMaxBlock)
self.curIndex = newIndex
self.cur:Set(newIndex)
self.cur:SetPos(self.curX,self.curY)
end
function EditorScene:MoveCursor( deltaX,deltaY )
self.cur:SetPos(self.curX+deltaX,self.curY+deltaY)
self.curX = self.cur.x
self.curY = self.cur.y
end
function EditorScene:ProcessInput( )
local function keyboardPressed(keyCode,event )
--up
if keyCode == 28 then
self:MoveCursor(0,1)
--down
elseif keyCode == 29 then
self:MoveCursor(0,-1)
--left
elseif keyCode == 26 then
self:MoveCursor(-1,0)
--right
elseif keyCode == 27 then
self:MoveCursor(1,0)
--page up
elseif keyCode == 38 then
self:SwitchCursor(-1)
--page down
elseif keyCode == 44 then
self:SwitchCursor(1)
end
end
local listener = cc.EventListenerKeyboard:create()
listener:registerScriptHandler(keyboardPressed,cc.Handler.EVENT_KEYBOARD_PRESSED)
local eventDispatcher = self:getEventDispatcher()
eventDispatcher:addEventListenerWithSceneGraphPriority(listener,self)
end
return EditorScene
你知道38和44对应哪个键吗?建议换成32和31,分别对应键盘的-,+号,反正我试了半天键盘,page up,page down都没反应,改了就有了
【蜘蛛侠TG@abin789】-5800
【蜘蛛侠TG@abin789】-5801
【蜘蛛侠TG@abin789】-5802
【蜘蛛侠TG@abin789】-5803
【蜘蛛侠TG@abin789】-5804
【蜘蛛侠TG@abin789】-5805
【蜘蛛侠TG@abin789】-5806
【蜘蛛侠TG@abin789】-5807
【蜘蛛侠TG@abin789】-5808
【蜘蛛侠TG@abin789】-5809
【蜘蛛侠TG@abin789】-5810
【蜘蛛侠TG@abin789】-5811
【蜘蛛侠TG@abin789】-5812
【蜘蛛侠TG@abin789】-5813
【蜘蛛侠TG@abin789】-5814
【蜘蛛侠TG@abin789】-5815
【蜘蛛侠TG@abin789】-5816
【蜘蛛侠TG@abin789】-5817
【蜘蛛侠TG@abin789】-5818
【蜘蛛侠TG@abin789】-5819
【蜘蛛侠TG@abin789】-5820
【蜘蛛侠TG@abin789】-5821
【蜘蛛侠TG@abin789】-5822
【蜘蛛侠TG@abin789】-5823
【蜘蛛侠TG@abin789】-5824
【蜘蛛侠TG@abin789】-5825
【蜘蛛侠TG@abin789】-5826
【蜘蛛侠TG@abin789】-5827
【蜘蛛侠TG@abin789】-5828
【蜘蛛侠TG@abin789】-5829
【蜘蛛侠TG@abin789】-5830
【蜘蛛侠TG@abin789】-5831
【蜘蛛侠TG@abin789】-5832
【蜘蛛侠TG@abin789】-5833
【蜘蛛侠TG@abin789】-5834
【蜘蛛侠TG@abin789】-5835
【蜘蛛侠TG@abin789】-5836
【蜘蛛侠TG@abin789】-5837
【蜘蛛侠TG@abin789】-5838
【蜘蛛侠TG@abin789】-5839
【蜘蛛侠TG@abin789】-5840
【蜘蛛侠TG@abin789】-5841
【蜘蛛侠TG@abin789】-5842
【蜘蛛侠TG@abin789】-5843
【蜘蛛侠TG@abin789】-5844
【蜘蛛侠TG@abin789】-5845
【蜘蛛侠TG@abin789】-5846
【蜘蛛侠TG@abin789】-5847
【蜘蛛侠TG@abin789】-5848
【蜘蛛侠TG@abin789】-5849
【蜘蛛侠TG@abin789】-5850
【蜘蛛侠TG@abin789】-5851
【蜘蛛侠TG@abin789】-5852
【蜘蛛侠TG@abin789】-5853
【蜘蛛侠TG@abin789】-5854
【蜘蛛侠TG@abin789】-5855
【蜘蛛侠TG@abin789】-5856
【蜘蛛侠TG@abin789】-5857
【蜘蛛侠TG@abin789】-5858
【蜘蛛侠TG@abin789】-5859
【蜘蛛侠TG@abin789】-5860
【蜘蛛侠TG@abin789】-5861
【蜘蛛侠TG@abin789】-5862
【蜘蛛侠TG@abin789】-5863
【蜘蛛侠TG@abin789】-5864
【蜘蛛侠TG@abin789】-5865
【蜘蛛侠TG@abin789】-5866
【蜘蛛侠TG@abin789】-5867
【蜘蛛侠TG@abin789】-5868
【蜘蛛侠TG@abin789】-5869
【蜘蛛侠TG@abin789】-5870
【蜘蛛侠TG@abin789】-5871
【蜘蛛侠TG@abin789】-5872
【蜘蛛侠TG@abin789】-5873
【蜘蛛侠TG@abin789】-5874
【蜘蛛侠TG@abin789】-5875
【蜘蛛侠TG@abin789】-5876
【蜘蛛侠TG@abin789】-5877
【蜘蛛侠TG@abin789】-5878
【蜘蛛侠TG@abin789】-5879
【蜘蛛侠TG@abin789】-5880
【蜘蛛侠TG@abin789】-5881
【蜘蛛侠TG@abin789】-5882
【蜘蛛侠TG@abin789】-5883
【蜘蛛侠TG@abin789】-5884
【蜘蛛侠TG@abin789】-5885
【蜘蛛侠TG@abin789】-5886
【蜘蛛侠TG@abin789】-5887
【蜘蛛侠TG@abin789】-5888
【蜘蛛侠TG@abin789】-5889
【蜘蛛侠TG@abin789】-5890
【蜘蛛侠TG@abin789】-5891
【蜘蛛侠TG@abin789】-5892
【蜘蛛侠TG@abin789】-5893
【蜘蛛侠TG@abin789】-5894
【蜘蛛侠TG@abin789】-5895
【蜘蛛侠TG@abin789】-5896
【蜘蛛侠TG@abin789】-5897
【蜘蛛侠TG@abin789】-5898
【蜘蛛侠TG@abin789】-5899
【蜘蛛侠TG@abin789】-5900
【蜘蛛侠TG@abin789】-5901
【蜘蛛侠TG@abin789】-5902
【蜘蛛侠TG@abin789】-5903
【蜘蛛侠TG@abin789】-5904
【蜘蛛侠TG@abin789】-5905
【蜘蛛侠TG@abin789】-5906
【蜘蛛侠TG@abin789】-5907
【蜘蛛侠TG@abin789】-5908
【蜘蛛侠TG@abin789】-5909
【蜘蛛侠TG@abin789】-5910
【蜘蛛侠TG@abin789】-5911
【蜘蛛侠TG@abin789】-5912
【蜘蛛侠TG@abin789】-5913
【蜘蛛侠TG@abin789】-5914
【蜘蛛侠TG@abin789】-5915
【蜘蛛侠TG@abin789】-5916
【蜘蛛侠TG@abin789】-5917
【蜘蛛侠TG@abin789】-5918
【蜘蛛侠TG@abin789】-5919
【蜘蛛侠TG@abin789】-5920
【蜘蛛侠TG@abin789】-5921
【蜘蛛侠TG@abin789】-5922
【蜘蛛侠TG@abin789】-5923
【蜘蛛侠TG@abin789】-5924
【蜘蛛侠TG@abin789】-5925
【蜘蛛侠TG@abin789】-5926
【蜘蛛侠TG@abin789】-5927
【蜘蛛侠TG@abin789】-5928
【蜘蛛侠TG@abin789】-5929
【蜘蛛侠TG@abin789】-5930
【蜘蛛侠TG@abin789】-5931
【蜘蛛侠TG@abin789】-5932
【蜘蛛侠TG@abin789】-5933
【蜘蛛侠TG@abin789】-5934
【蜘蛛侠TG@abin789】-5935
【蜘蛛侠TG@abin789】-5936
【蜘蛛侠TG@abin789】-5937
【蜘蛛侠TG@abin789】-5938
【蜘蛛侠TG@abin789】-5939
【蜘蛛侠TG@abin789】-5940
【蜘蛛侠TG@abin789】-5941
【蜘蛛侠TG@abin789】-5942
【蜘蛛侠TG@abin789】-5943
【蜘蛛侠TG@abin789】-5944
【蜘蛛侠TG@abin789】-5945
【蜘蛛侠TG@abin789】-5946
【蜘蛛侠TG@abin789】-5947
【蜘蛛侠TG@abin789】-5948
【蜘蛛侠TG@abin789】-5949
【蜘蛛侠TG@abin789】-5950
【蜘蛛侠TG@abin789】-5951
【蜘蛛侠TG@abin789】-5952
【蜘蛛侠TG@abin789】-5953
【蜘蛛侠TG@abin789】-5954
【蜘蛛侠TG@abin789】-5955
【蜘蛛侠TG@abin789】-5956
【蜘蛛侠TG@abin789】-5957
【蜘蛛侠TG@abin789】-5958
【蜘蛛侠TG@abin789】-5959
【蜘蛛侠TG@abin789】-5960
【蜘蛛侠TG@abin789】-5961
【蜘蛛侠TG@abin789】-5962
【蜘蛛侠TG@abin789】-5963
【蜘蛛侠TG@abin789】-5964
【蜘蛛侠TG@abin789】-5965
【蜘蛛侠TG@abin789】-5966
【蜘蛛侠TG@abin789】-5967
【蜘蛛侠TG@abin789】-5968
【蜘蛛侠TG@abin789】-5969
【蜘蛛侠TG@abin789】-5970
【蜘蛛侠TG@abin789】-5971
【蜘蛛侠TG@abin789】-5972
【蜘蛛侠TG@abin789】-5973
【蜘蛛侠TG@abin789】-5974
【蜘蛛侠TG@abin789】-5975
【蜘蛛侠TG@abin789】-5976
【蜘蛛侠TG@abin789】-5977
【蜘蛛侠TG@abin789】-5978
【蜘蛛侠TG@abin789】-5979
【蜘蛛侠TG@abin789】-5980
【蜘蛛侠TG@abin789】-5981
【蜘蛛侠TG@abin789】-5982
【蜘蛛侠TG@abin789】-5983
【蜘蛛侠TG@abin789】-5984
【蜘蛛侠TG@abin789】-5985
【蜘蛛侠TG@abin789】-5986
【蜘蛛侠TG@abin789】-5987
【蜘蛛侠TG@abin789】-5988
【蜘蛛侠TG@abin789】-5989
【蜘蛛侠TG@abin789】-5990
【蜘蛛侠TG@abin789】-5991
【蜘蛛侠TG@abin789】-5992
【蜘蛛侠TG@abin789】-5993
【蜘蛛侠TG@abin789】-5994
【蜘蛛侠TG@abin789】-5995
【蜘蛛侠TG@abin789】-5996
【蜘蛛侠TG@abin789】-5997
【蜘蛛侠TG@abin789】-5998
【蜘蛛侠TG@abin789】-5999
Cocos2d-x游戏开发入门-贪吃蛇(下)
15573 学习 · 15 问题
相似问题