Lumberyard 터치 (5) - 게임 시작편
18816 단어 게임 개발게임게임 제작Lumberyard
← Lumberyard 터치 (4) - 입력편 Lumberyard를 만지는 (최종회) - 충돌 판정편 →
소개
이번에는 마지막으로 얻은 이벤트에서 문자를 숨깁니다.
이미 내가 만든 스크립트의 해설을 해 나갑니다.
스크립트 설정
이전 스크립트와 비슷한 위치에
AddComponent에서 스크립트를 추가합니다.

스크립트
전체.
gamestart.lua
local gamestart =
{
}
function gamestart:OnActivate()
self.clickEventId = GameplayNotificationId(self.entityId, "ClickEvent", "float");
self.clickHandler = GameplayNotificationBus.Connect(self, self.clickEventId);
self.tickHandler = TickBus.Connect(self);
end
function gamestart:OnTick(deltaTime, timePoint)
if (self.tickHandler ~= nil) then
self:SetControls("PlayerCharacter", "EnableControlsEvent", 0);
self.tickHandler:Disconnect();
self.tickHandler = nil;
end
end
function gamestart:OnDeactivate()
if (self.clickHandler) then
self.clickHandler:Disconnect();
self.clickHandler = nil;
end
end
function gamestart:OnEventBegin(value)
if (GameplayNotificationBus.GetCurrentBusId() == self.clickEventId) then
self:SetControls("PlayerCharacter", "EnableControlsEvent", 1);
UiCanvasAssetRefBus.Event.UnloadCanvas(self.entityId);
if (self.tickHandler ~= nil) then
self.tickHandler:Disconnect();
self.tickHandler = nil;
end
end
end
function gamestart:SetControls(tag, event, enabled)
local entity = TagGlobalRequestBus.Event.RequestTaggedEntities(Crc32(tag));
local controlsEventId = GameplayNotificationId(entity, event, "float");
GameplayNotificationBus.Event.OnEventBegin(controlsEventId, enabled);
end
return gamestart
문자 삭제
우선은, 문자 소거만을 해설해 갑니다.
gamestart.luafunction gamestart:OnActivate()
self.clickEventId = GameplayNotificationId(self.entityId, "ClickEvent", "float");
self.clickHandler = GameplayNotificationBus.Connect(self, self.clickEventId);
self.tickHandler = TickBus.Connect(self);
end
OnActivate에서 ClickEvent 알림 버스에 연결합니다.
ClickEvent는 마지막 이벤트 버스에서 구현한 부분입니다.

gamestart.luafunction gamestart:OnEventBegin(value)
if (GameplayNotificationBus.GetCurrentBusId() == self.clickEventId) then
self:SetControls("PlayerCharacter", "EnableControlsEvent", 1);
UiCanvasAssetRefBus.Event.UnloadCanvas(self.entityId);
if (self.tickHandler ~= nil) then
self.tickHandler:Disconnect();
self.tickHandler = nil;
end
end
end
OnEventBegin에서 ClickEvent의 이벤트가 작동했는지 확인한 후 UnluadCanvas에서 자신에게 붙어있는 캔버스를 삭제합니다.
이제 문자를 삭제할 수 있습니다.
gamestart.luafunction gamestart:OnDeactivate()
if (self.clickHandler) then
self.clickHandler:Disconnect();
self.clickHandler = nil;
end
end
알림 버스는 엔티티의 끝 부분에서 지워집니다.
캐릭터 정지
문자는 지울 수 있지만,
이것만으로는 시작 문자가 표시되는 동안
캐릭터가 조작할 수 버립니다.
게임이 시작될 때까지 캐릭터의 정지를 시키는 처리를 해설합니다.
gamestart.luafunction gamestart:OnActivate()
self.clickEventId = GameplayNotificationId(self.entityId, "ClickEvent", "float");
self.clickHandler = GameplayNotificationBus.Connect(self, self.clickEventId);
self.tickHandler = TickBus.Connect(self);
end
OnActivate에서 TickBus 알림 버스에 연결합니다.
TickBus는 매 프레임 처리하는 동작을 구현할 때 유용합니다.
이번에는 점프 처리 활성화 플래그 등이 캐릭터 스크립트의 OnActive에 사용되고 있기 때문에 캐릭터 정지 처리 타이밍을 어긋나기 위해 사용합니다.
gamestart.luafunction gamestart:OnTick(deltaTime, timePoint)
if (self.tickHandler ~= nil) then
self:SetControls("PlayerCharacter", "EnableControlsEvent", 0);
self.tickHandler:Disconnect();
self.tickHandler = nil;
end
end
OnTick은 매 프레임이라고합니다.
여기에서는 캐릭터(슬라이스)의 액티브 플래그를 SetControls에서 정지시키고 있습니다.
OnTick은 캐릭터를 정지시키면 불필요하므로 tick의 버스는 끊습니다.
gamestart.luafunction gamestart:SetControls(tag, event, enabled)
local entity = TagGlobalRequestBus.Event.RequestTaggedEntities(Crc32(tag));
local controlsEventId = GameplayNotificationId(entity, event, "float");
GameplayNotificationBus.Event.OnEventBegin(controlsEventId, enabled);
end
SetControls 에서는 인수로 건네받은 태그명을 가지는 엔티티의 유효 무효를 전환합니다.

gamestart.luafunction gamestart:OnEventBegin(value)
if (GameplayNotificationBus.GetCurrentBusId() == self.clickEventId) then
self:SetControls("PlayerCharacter", "EnableControlsEvent", 1);
UiCanvasAssetRefBus.Event.UnloadCanvas(self.entityId);
if (self.tickHandler ~= nil) then
self.tickHandler:Disconnect();
self.tickHandler = nil;
end
end
end
OnEventBegin에서 ClickEvent 이벤트가 작동했는지 확인한 후 캐릭터를 활성화합니다.
만약을 위해 코코에서도 tick의 버스는 자르는 처리를 넣습니다.
요약
이제 캐릭터 정지와 문자 삭제가 가능했습니다.
캐릭터의 정지와 같은 요령으로 카메라의 정지도 할 수 있다고 생각합니다.
다음 번에는 충돌 판정을 실시해 갑니다.
Reference
이 문제에 관하여(Lumberyard 터치 (5) - 게임 시작편), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/OrotiYamatano/items/069923c94c84bb604a88
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
이전 스크립트와 비슷한 위치에
AddComponent에서 스크립트를 추가합니다.

스크립트
전체.
gamestart.lua
local gamestart =
{
}
function gamestart:OnActivate()
self.clickEventId = GameplayNotificationId(self.entityId, "ClickEvent", "float");
self.clickHandler = GameplayNotificationBus.Connect(self, self.clickEventId);
self.tickHandler = TickBus.Connect(self);
end
function gamestart:OnTick(deltaTime, timePoint)
if (self.tickHandler ~= nil) then
self:SetControls("PlayerCharacter", "EnableControlsEvent", 0);
self.tickHandler:Disconnect();
self.tickHandler = nil;
end
end
function gamestart:OnDeactivate()
if (self.clickHandler) then
self.clickHandler:Disconnect();
self.clickHandler = nil;
end
end
function gamestart:OnEventBegin(value)
if (GameplayNotificationBus.GetCurrentBusId() == self.clickEventId) then
self:SetControls("PlayerCharacter", "EnableControlsEvent", 1);
UiCanvasAssetRefBus.Event.UnloadCanvas(self.entityId);
if (self.tickHandler ~= nil) then
self.tickHandler:Disconnect();
self.tickHandler = nil;
end
end
end
function gamestart:SetControls(tag, event, enabled)
local entity = TagGlobalRequestBus.Event.RequestTaggedEntities(Crc32(tag));
local controlsEventId = GameplayNotificationId(entity, event, "float");
GameplayNotificationBus.Event.OnEventBegin(controlsEventId, enabled);
end
return gamestart
문자 삭제
우선은, 문자 소거만을 해설해 갑니다.
gamestart.luafunction gamestart:OnActivate()
self.clickEventId = GameplayNotificationId(self.entityId, "ClickEvent", "float");
self.clickHandler = GameplayNotificationBus.Connect(self, self.clickEventId);
self.tickHandler = TickBus.Connect(self);
end
OnActivate에서 ClickEvent 알림 버스에 연결합니다.
ClickEvent는 마지막 이벤트 버스에서 구현한 부분입니다.

gamestart.luafunction gamestart:OnEventBegin(value)
if (GameplayNotificationBus.GetCurrentBusId() == self.clickEventId) then
self:SetControls("PlayerCharacter", "EnableControlsEvent", 1);
UiCanvasAssetRefBus.Event.UnloadCanvas(self.entityId);
if (self.tickHandler ~= nil) then
self.tickHandler:Disconnect();
self.tickHandler = nil;
end
end
end
OnEventBegin에서 ClickEvent의 이벤트가 작동했는지 확인한 후 UnluadCanvas에서 자신에게 붙어있는 캔버스를 삭제합니다.
이제 문자를 삭제할 수 있습니다.
gamestart.luafunction gamestart:OnDeactivate()
if (self.clickHandler) then
self.clickHandler:Disconnect();
self.clickHandler = nil;
end
end
알림 버스는 엔티티의 끝 부분에서 지워집니다.
캐릭터 정지
문자는 지울 수 있지만,
이것만으로는 시작 문자가 표시되는 동안
캐릭터가 조작할 수 버립니다.
게임이 시작될 때까지 캐릭터의 정지를 시키는 처리를 해설합니다.
gamestart.luafunction gamestart:OnActivate()
self.clickEventId = GameplayNotificationId(self.entityId, "ClickEvent", "float");
self.clickHandler = GameplayNotificationBus.Connect(self, self.clickEventId);
self.tickHandler = TickBus.Connect(self);
end
OnActivate에서 TickBus 알림 버스에 연결합니다.
TickBus는 매 프레임 처리하는 동작을 구현할 때 유용합니다.
이번에는 점프 처리 활성화 플래그 등이 캐릭터 스크립트의 OnActive에 사용되고 있기 때문에 캐릭터 정지 처리 타이밍을 어긋나기 위해 사용합니다.
gamestart.luafunction gamestart:OnTick(deltaTime, timePoint)
if (self.tickHandler ~= nil) then
self:SetControls("PlayerCharacter", "EnableControlsEvent", 0);
self.tickHandler:Disconnect();
self.tickHandler = nil;
end
end
OnTick은 매 프레임이라고합니다.
여기에서는 캐릭터(슬라이스)의 액티브 플래그를 SetControls에서 정지시키고 있습니다.
OnTick은 캐릭터를 정지시키면 불필요하므로 tick의 버스는 끊습니다.
gamestart.luafunction gamestart:SetControls(tag, event, enabled)
local entity = TagGlobalRequestBus.Event.RequestTaggedEntities(Crc32(tag));
local controlsEventId = GameplayNotificationId(entity, event, "float");
GameplayNotificationBus.Event.OnEventBegin(controlsEventId, enabled);
end
SetControls 에서는 인수로 건네받은 태그명을 가지는 엔티티의 유효 무효를 전환합니다.

gamestart.luafunction gamestart:OnEventBegin(value)
if (GameplayNotificationBus.GetCurrentBusId() == self.clickEventId) then
self:SetControls("PlayerCharacter", "EnableControlsEvent", 1);
UiCanvasAssetRefBus.Event.UnloadCanvas(self.entityId);
if (self.tickHandler ~= nil) then
self.tickHandler:Disconnect();
self.tickHandler = nil;
end
end
end
OnEventBegin에서 ClickEvent 이벤트가 작동했는지 확인한 후 캐릭터를 활성화합니다.
만약을 위해 코코에서도 tick의 버스는 자르는 처리를 넣습니다.
요약
이제 캐릭터 정지와 문자 삭제가 가능했습니다.
캐릭터의 정지와 같은 요령으로 카메라의 정지도 할 수 있다고 생각합니다.
다음 번에는 충돌 판정을 실시해 갑니다.
Reference
이 문제에 관하여(Lumberyard 터치 (5) - 게임 시작편), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/OrotiYamatano/items/069923c94c84bb604a88
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
local gamestart =
{
}
function gamestart:OnActivate()
self.clickEventId = GameplayNotificationId(self.entityId, "ClickEvent", "float");
self.clickHandler = GameplayNotificationBus.Connect(self, self.clickEventId);
self.tickHandler = TickBus.Connect(self);
end
function gamestart:OnTick(deltaTime, timePoint)
if (self.tickHandler ~= nil) then
self:SetControls("PlayerCharacter", "EnableControlsEvent", 0);
self.tickHandler:Disconnect();
self.tickHandler = nil;
end
end
function gamestart:OnDeactivate()
if (self.clickHandler) then
self.clickHandler:Disconnect();
self.clickHandler = nil;
end
end
function gamestart:OnEventBegin(value)
if (GameplayNotificationBus.GetCurrentBusId() == self.clickEventId) then
self:SetControls("PlayerCharacter", "EnableControlsEvent", 1);
UiCanvasAssetRefBus.Event.UnloadCanvas(self.entityId);
if (self.tickHandler ~= nil) then
self.tickHandler:Disconnect();
self.tickHandler = nil;
end
end
end
function gamestart:SetControls(tag, event, enabled)
local entity = TagGlobalRequestBus.Event.RequestTaggedEntities(Crc32(tag));
local controlsEventId = GameplayNotificationId(entity, event, "float");
GameplayNotificationBus.Event.OnEventBegin(controlsEventId, enabled);
end
return gamestart
function gamestart:OnActivate()
self.clickEventId = GameplayNotificationId(self.entityId, "ClickEvent", "float");
self.clickHandler = GameplayNotificationBus.Connect(self, self.clickEventId);
self.tickHandler = TickBus.Connect(self);
end
function gamestart:OnEventBegin(value)
if (GameplayNotificationBus.GetCurrentBusId() == self.clickEventId) then
self:SetControls("PlayerCharacter", "EnableControlsEvent", 1);
UiCanvasAssetRefBus.Event.UnloadCanvas(self.entityId);
if (self.tickHandler ~= nil) then
self.tickHandler:Disconnect();
self.tickHandler = nil;
end
end
end
function gamestart:OnDeactivate()
if (self.clickHandler) then
self.clickHandler:Disconnect();
self.clickHandler = nil;
end
end
function gamestart:OnActivate()
self.clickEventId = GameplayNotificationId(self.entityId, "ClickEvent", "float");
self.clickHandler = GameplayNotificationBus.Connect(self, self.clickEventId);
self.tickHandler = TickBus.Connect(self);
end
function gamestart:OnTick(deltaTime, timePoint)
if (self.tickHandler ~= nil) then
self:SetControls("PlayerCharacter", "EnableControlsEvent", 0);
self.tickHandler:Disconnect();
self.tickHandler = nil;
end
end
function gamestart:SetControls(tag, event, enabled)
local entity = TagGlobalRequestBus.Event.RequestTaggedEntities(Crc32(tag));
local controlsEventId = GameplayNotificationId(entity, event, "float");
GameplayNotificationBus.Event.OnEventBegin(controlsEventId, enabled);
end
function gamestart:OnEventBegin(value)
if (GameplayNotificationBus.GetCurrentBusId() == self.clickEventId) then
self:SetControls("PlayerCharacter", "EnableControlsEvent", 1);
UiCanvasAssetRefBus.Event.UnloadCanvas(self.entityId);
if (self.tickHandler ~= nil) then
self.tickHandler:Disconnect();
self.tickHandler = nil;
end
end
end
이제 캐릭터 정지와 문자 삭제가 가능했습니다.
캐릭터의 정지와 같은 요령으로 카메라의 정지도 할 수 있다고 생각합니다.
다음 번에는 충돌 판정을 실시해 갑니다.
Reference
이 문제에 관하여(Lumberyard 터치 (5) - 게임 시작편), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/OrotiYamatano/items/069923c94c84bb604a88텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)