태양계 예제
예제
태양계 예제
피니엔진 LNX 소스코드
local function m(fileName) |
print ("loaded ok") |
local rootNode = pini.Node("rootNode") |
pini:AttachDisplay(rootNode) |
rootNode:setAnchorPoint(0.5,0.5) |
rootNode:setScale(1.0,1.0) |
rootNode:setPosition(400,300) |
local sunNode = pini.Sprite("sun","blue.png",nil) |
pini:AttachDisplay(sunNode,"rootNode") |
sunNode:setAnchorPoint(0.5,0.5) |
sunNode:setScale(2.0,2.0) |
sunNode:setPosition(0,0) |
sunNode:setColor(255,243,28) |
sunNode:runAction(cc.RepeatForever:create(cc.RotateBy:create(0.3,90))) |
local venusAnchorNode = pini.Node("venusAnchorNode") |
pini:AttachDisplay(venusAnchorNode,"rootNode") |
venusAnchorNode:setAnchorPoint(0.5,0.5) |
venusAnchorNode:setScale(1.0,1.0) |
venusAnchorNode:setPosition(0,0) |
venusAnchorNode:runAction(cc.RepeatForever:create(cc.RotateBy:create(3,90))) |
local venusNode = pini.Sprite("venus","blue.png",nil) |
pini:AttachDisplay(venusNode,"venusAnchorNode") |
venusNode:setAnchorPoint(0.5,0.5) |
venusNode:setScale(1.0,1.0) |
venusNode:setPosition(100,0) |
venusNode:setColor(17,255,255) |
venusNode:runAction(cc.RepeatForever:create(cc.RotateBy:create(0.7,90))) |
local earthAnchorNode = pini.Node("earthAnchorNode") |
pini:AttachDisplay(earthAnchorNode,"rootNode") |
earthAnchorNode:setAnchorPoint(0.5,0.5) |
earthAnchorNode:setScale(1.0,1.0) |
earthAnchorNode:setPosition(0,0) |
earthAnchorNode:runAction(cc.RepeatForever:create(cc.RotateBy:create(7,90))) |
local earthRootNode = pini.Node("earthRootNode") |
pini:AttachDisplay(earthRootNode,"earthAnchorNode") |
earthRootNode:setAnchorPoint(0.5,0.5) |
earthRootNode:setScale(1.0,1.0) |
earthRootNode:setPosition(250,0) |
local earthNode = pini.Sprite("earthNode","blue.png",nil) |
pini:AttachDisplay(earthNode,"earthRootNode") |
earthNode:setAnchorPoint(0.5,0.5) |
earthNode:setScale(1.0,1.0) |
earthNode:setPosition(0,0) |
earthNode:setColor(47,151,255) |
earthNode:runAction(cc.RepeatForever:create(cc.RotateBy:create(0.3,90))) |
local moonAnchorNode = pini.Node("moonAnchorNode") |
pini:AttachDisplay(moonAnchorNode,"earthRootNode") |
moonAnchorNode:setAnchorPoint(0.5,0.5) |
moonAnchorNode:setScale(1.0,1.0) |
moonAnchorNode:setPosition(0,0) |
moonAnchorNode:runAction(cc.RepeatForever:create(cc.RotateBy:create(1.7,90))) |
local moonNode = pini.Sprite("moonNode","blue.png",nil) |
pini:AttachDisplay(moonNode,"moonAnchorNode") |
moonNode:setAnchorPoint(0.5,0.5) |
moonNode:setScale(0.5,0.5) |
moonNode:setPosition(70,0) |
moonNode:setColor(160,160,160) |
moonNode:runAction(cc.RepeatForever:create(cc.RotateBy:create(1.5,90))) |
print ("step 1") |
end |
return m |
※ cc.RepeatForever 에 관련된 내용은 http://www.cocos2d-x.org/reference/native-cpp/V3.0rc1/d9/d37/classcocos2d_1_1_repeat_forever.html 를 참고해 주세요.
※ cc.RotateBy 에 관련된 내용은 http://www.cocos2d-x.org/reference/native-cpp/V3.0rc1/d0/d28/classcocos2d_1_1_rotate_by.html 를 참고해 주세요.
사용코드
피니엔진 LNX 소스코드
[스크립트 실행="아니오" 파일명="Solar_System.lua" ] |
※ 이 예제는 매크로 등록 및 사용이 아닌, 스크립트를 불러오자마자 작동하는 예제이므로, lua 와 짝이 되는 lnx 파일을 없습니다.
결과