Permalink
Browse files

got doors working, although, my fire hose only works once

  • Loading branch information...
JesterXL committed Feb 12, 2012
1 parent ab14d46 commit cf4f6d27e5b61cd53f880cfa335fa54d5896fd1d
Showing with 292 additions and 79 deletions.
  1. +1 −1 code/Level1.json
  2. BIN code/button-enter.png
  3. +1 −1 code/com/jxl/core/statemachine/StateMachine.lua
  4. +28 −2 code/com/jxl/zombiestick/gamegui/LevelView.lua
  5. +11 −0 code/com/jxl/zombiestick/gamegui/hud/EnterButton.lua
  6. +32 −0 code/com/jxl/zombiestick/gamegui/hud/HudControls.lua
  7. +35 −0 code/com/jxl/zombiestick/gamegui/levelviews/Door.lua
  8. +1 −1 code/com/jxl/zombiestick/services/LoadLevelService.lua
  9. +10 −0 code/com/jxl/zombiestick/states/hud/HudControlsJXLState.lua
  10. BIN design/interface.fla
  11. BIN zombie-stick-level-editor-workspace/level-editor/libs/ModestMapsSWC.swc
  12. +1 −0 ...ck-level-editor-workspace/level-editor/src/com/jxl/zombiestick/constants/subtypes/TerrainTypes.as
  13. +7 −1 zombie-stick-level-editor-workspace/level-editor/src/com/jxl/zombiestick/controls/GameObjectView.as
  14. +65 −46 zombie-stick-level-editor-workspace/level-editor/src/com/jxl/zombiestick/views/LevelWindow.mxml
  15. +16 −13 ...ick-level-editor-workspace/level-editor/src/com/jxl/zombiestick/views/levelviews/LayersPanel.mxml
  16. +12 −2 ...level-editor-workspace/level-editor/src/com/jxl/zombiestick/views/levelviews/PropertiesPanel.mxml
  17. +24 −1 ...orkspace/level-editor/src/com/jxl/zombiestick/views/levelviews/layersviews/LayerItemRenderer.mxml
  18. +24 −11 ...workspace/level-editor/src/com/jxl/zombiestick/views/levelviews/movieviews/MovieItemRenderer.mxml
  19. +24 −0 zombie-stick-level-editor-workspace/level-editor/src/com/jxl/zombiestick/vo/GameObjectVO.as
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
Binary file not shown.
@@ -38,7 +38,7 @@ function StateMachine:new(entity)
end
function stateMachine:addState2(state)
- print("StateMachine::addState2, state: ", state.name)
+ --print("StateMachine::addState2, state: ", state.name)
if self.states[state.name] ~= nil then
print("WARNING: StateMachne::addedState2, overriding existing state: " .. state.name)
end
@@ -10,6 +10,7 @@ require "com.jxl.zombiestick.gamegui.levelviews.Chair"
require "com.jxl.zombiestick.gamegui.levelviews.Firehose"
require "com.jxl.zombiestick.gamegui.levelviews.GenericSensor"
require "com.jxl.zombiestick.gamegui.levelviews.WindowPiece"
+require "com.jxl.zombiestick.gamegui.levelviews.Door"
require "com.jxl.zombiestick.players.PlayerJXL"
require "com.jxl.zombiestick.players.PlayerFreeman"
@@ -177,7 +178,6 @@ function LevelView:new(x, y, width, height)
self:setBackgroundImage(levelVO.backgroundImageShort)
if self.hudControls == nil then
- print("telling HUD Controls to use width: ", width, ", and height: ", height)
local hudControls = HudControls:new(width, height)
self:insert(hudControls)
hudControls:addEventListener("onLeftButtonTouch", self)
@@ -186,6 +186,7 @@ function LevelView:new(x, y, width, height)
hudControls:addEventListener("onJumpButtonTouch", self)
hudControls:addEventListener("onJumpLeftButtonTouch", self)
hudControls:addEventListener("onJumpRightButtonTouch", self)
+ hudControls:addEventListener("onEnterButtonTouch", self)
self.hudControls = hudControls
end
@@ -295,6 +296,27 @@ function LevelView:new(x, y, width, height)
end
end
+ function level:onEnterButtonTouch(event)
+ if event.phase == "began" then
+ local enterButton = event.button
+ local lc = self.levelChildren
+ local n = lc.numChildren
+ local i
+ print("enterButton: ", enterButton)
+ for i=1,n do
+ local child = lc[i]
+ print("name: ", child.name, ", enterButton.targetDoorName: ", enterButton.targetDoorName)
+ if child.name ~= nil and child.name == enterButton.targetDoorName then
+ print("child.anme: ", child.name, ", enterButton.targetDoorName: ", enterButton.targetDoorName)
+ --print("*** px: ", self.player.x, ", py: ", self.player.y, ", cx: ", child.x, ", cy: ", child.y, ", classType: ", child.classType)
+ self.player.x = child.x
+ self.player.y = child.y
+ return true
+ end
+ end
+ end
+ end
+
function level:setBackgroundImage(filename)
if filename ~= nil and filename ~= "" then
local img = display.newImage(filename)
@@ -320,7 +342,9 @@ function LevelView:new(x, y, width, height)
density = event.density,
friction = event.friction,
bounce = event.bounce,
- ledgeExitDirection = event.ledgeExitDirection}
+ ledgeExitDirection = event.ledgeExitDirection,
+ customName = event.customName,
+ targetDoor = event.targetDoor}
if terrainType == "Crate" then
terrain = Crate:new(params)
elseif terrainType == "Floor" then
@@ -359,6 +383,8 @@ function LevelView:new(x, y, width, height)
terrain:addEventListener("collision", terrain)
elseif terrainType == "Generic Sensor" then
terrain = GenericSensor:new(params)
+ elseif terrainType == "Door" then
+ terrain = Door:new(params)
end
self:insertChild(terrain)
end
@@ -0,0 +1,11 @@
+EnterButton = {}
+
+function EnterButton:new()
+
+ local image = display.newImage("button-enter.png")
+ image:setReferencePoint(display.TopLeftReferencePoint)
+ return image
+
+end
+
+return EnterButton
@@ -8,6 +8,7 @@ require "com.jxl.zombiestick.gamegui.hud.TargetButton"
require "com.jxl.zombiestick.gamegui.hud.GunButton"
require "com.jxl.zombiestick.gamegui.hud.GrapplingHookGunButton"
require "com.jxl.zombiestick.gamegui.hud.GunAmmoLine"
+require "com.jxl.zombiestick.gamegui.hud.EnterButton"
require "com.jxl.zombiestick.states.hud.HudControlsJXLState"
require "com.jxl.zombiestick.states.hud.HudControlsFreemanState"
@@ -78,6 +79,16 @@ function HudControls:new(width, height)
grappleButton.isVisible = false
grappleButton.alpha = .5
+ local enterButton = EnterButton:new()
+ enterButton.name = "enterButton"
+ controls:insert(enterButton)
+ enterButton.showing = false
+ enterButton.alpha = 0
+ enterButton.x = width - enterButton.width
+ enterButton.y = (height / 2) - (enterButton.height / 2)
+ enterButton.originalWidth = enterButton.width
+ enterButton.originalHeight = enterButton.height
+
function controls:showJXLAttackButton(show)
print("HudControls::showJXLAttackButtons, show: ", show)
attackButton.isVisible = show
@@ -118,6 +129,24 @@ function HudControls:new(width, height)
end
end
+ function controls:showDoorButton(show, doorName, targetDoorName)
+ if enterButton.showing ~= show then
+ enterButton.doorName = doorName
+ enterButton.targetDoorName = targetDoorName
+ if enterButton.tween ~= nil then
+ transition.cancel(enterButton.tween)
+ end
+
+ if show == true then
+ enterButton.showing = show
+ enterButton.tween = transition.to( enterButton, {time=500, alpha=1, width=enterButton.originalWidth, height=enterButton.originalHeight, transition=easing.outExpo})
+ else
+ enterButton.showing = show
+ enterButton.tween = transition.to( enterButton, {time=500, alpha=0, width=(enterButton.originalWidth * .3), height=(enterButton.originalHeight * .3), stransition=easing.outExpo})
+ end
+ end
+ end
+
function controls:touch(event)
print("HudControls::touch, target: ", event.target.name)
local t = event.target
@@ -137,6 +166,8 @@ function HudControls:new(width, height)
Runtime:dispatchEvent({name="onGunButtonTouch", target=self, phase=event.phase, button=gunButton})
elseif t == grappleButton then
Runtime:dispatchEvent({name="onGrappleButtonTouch", target=self, phase=event.phase, button=grappleButton})
+ elseif t == enterButton then
+ self:dispatchEvent({name="onEnterButtonTouch", target=self, phase=event.phase, button=enterButton})
end
return true
end
@@ -151,6 +182,7 @@ function HudControls:new(width, height)
jumpRightButton:addEventListener("touch", controls)
gunButton:addEventListener("touch", controls)
grappleButton:addEventListener("touch", controls)
+ enterButton:addEventListener("touch", controls)
controls.fsm = StateMachine:new(controls)
controls.fsm:addState2(HudControlsJXLState:new())
@@ -0,0 +1,35 @@
+Door = {}
+
+function Door:new(params)
+ local door = display.newRect(0, 0, params.width, params.height)
+ door:setReferencePoint(display.TopLeftReferencePoint)
+ door.strokeWidth = 2
+ door:setFillColor(255, 0, 0, 100)
+ door.classType = "Door"
+ door.name = params.customName
+ door.targetDoor = params.targetDoor
+ print("Door, name: ", params.customName, ", targetDoor: ", params.targetDoor)
+ door.x = params.x
+ door.y = params.y
+
+ function door:collision(event)
+ print("*** collision, classType: ", event.other.classType, ", phase: ", event.phase)
+ if event.other.classType == "PlayerJXL" or event.other.classType == "PlayerFreeman" then
+ Runtime:dispatchEvent({name="onDoorCollision", target=self, other=event.other, phase=event.phase})
+ return true
+ end
+ end
+ door:addEventListener("collision", door)
+
+ physics.addBody( door, {isSensor = true, filter = {
+ categoryBits = constants.COLLISION_FILTER_TERRAIN_CATEGORY,
+ maskBits = constants.COLLISION_FILTER_TERRAIN_MASK
+ }
+ }
+ )
+ door.bodyType = "kinematic"
+
+ return door
+end
+
+return Door
@@ -1,4 +1,4 @@
-require "json"
+json = require "json"
LoadLevelService = {}
LoadLevelService.loader = nil
@@ -8,11 +8,21 @@ function HudControlsJXLState:new()
function state:onEnterState(event)
print("HudControlsJXLState::onEnterState")
self.entity:showJXLAttackButton(true)
+ Runtime:addEventListener("onDoorCollision", self)
end
function state:onExitState(event)
print("HudControlsJXLState::onExitState")
self.entity:showJXLAttackButton(false)
+ Runtime:removeEventListener("onDoorCollision", self)
+ end
+
+ function state:onDoorCollision(event)
+ if event.phase == "began" then
+ self.entity:showDoorButton(true, event.target.name, event.target.targetDoor)
+ else
+ self.entity:showDoorButton(false)
+ end
end
return state
View
Binary file not shown.
@@ -13,6 +13,7 @@ package com.jxl.zombiestick.constants.subtypes
public static const FIREHOSE:String = "Firehose";
public static const GENERIC_SENSOR:String = "Generic Sensor";
public static const WINDOW_PIECE:String = "Window Piece";
+ public static const DOOR:String = "Door";
}
@@ -61,6 +61,7 @@ package com.jxl.zombiestick.controls
_gameObject.removeEventListener("heightChanged", onGameObjectChanged);
_gameObject.removeEventListener("imageChanged", onGameObjectChanged);
_gameObject.removeEventListener("selectedChanged", onGameObjectChanged);
+ _gameObject.removeEventListener("visibleChanged", onGameObjectChanged);
}
_gameObject = value;
if(_gameObject)
@@ -71,6 +72,7 @@ package com.jxl.zombiestick.controls
_gameObject.addEventListener("heightChanged", onGameObjectChanged);
_gameObject.addEventListener("imageChanged", onGameObjectChanged);
_gameObject.addEventListener("selectedChanged", onGameObjectChanged);
+ _gameObject.addEventListener("visibleChanged", onGameObjectChanged);
}
gameObjectDirty = true;
invalidateProperties();
@@ -201,7 +203,11 @@ package com.jxl.zombiestick.controls
case "selectedChanged":
onSelectionChanged();
- break;
+ break;
+
+ case "visibleChanged":
+ visible = gameObject.visible;
+ break;
}
dispatchEvent(new Event("childSizeChanged"));
}
@@ -50,57 +50,76 @@
private function onSaved(event:SaveLevelServiceEvent):void
{
}
+
+ private function onZoomIn():void
+ {
+ groupWrapper.scaleX += .1;
+ groupWrapper.scaleY += .1;
+ }
+
+ private function onZoomOut():void
+ {
+ groupWrapper.scaleX -= .1;
+ groupWrapper.scaleY -= .1;
+ }
+
+ private function onNormalizeZoom():void
+ {
+ groupWrapper.scaleX = groupWrapper.scaleY = 1;
+ }
]]>
</fx:Script>
- <s:VGroup>
- <s:HGroup>
- <s:Label text="Background:" />
- <s:TextInput id="backgroundImagePath" editable="false" text="{level.backgroundImage}" toolTip="{level.backgroundImage}" />
- <s:Button label="Browse" click="onBrowseForBackgroundImage()" />
- <s:Button label="New" click="onNew()" />
- <s:Button label="Save" click="onSave()" />
- </s:HGroup>
+ <s:Scroller width="100%" height="100%">
- <s:HGroup>
- <s:Group>
- <s:Image source="@Embed(source='/assets/images/iphone.png')"
- top="30" left="10"/>
-
- <s:Scroller top="162" left="43"
- width="320" height="320"
- id="levelCanvasScroller">
- <s:Group>
- <s:Rect width="{levelCanvas.width}" height="{levelCanvas.height}">
- <s:fill>
- <s:SolidColor color="#FF0000" alpha="0" />
- </s:fill>
- </s:Rect>
-
- <zombiestick:LevelCanvas id="levelCanvas" level="{level}" />
-
- </s:Group>
- </s:Scroller>
- </s:Group>
-
- <levelviews:PropertiesPanel />
-
- <!--
- <levelviews:MoviePanel movies="{level.movies}" />
- -->
-
- <!--
- <s:VGroup width="200" height="100%">
- <s:Label text="Selections:" />
- <s:List dataProvider="{levelCanvas.selections}" labelField="type" width="100%" height="100%" />
- </s:VGroup>
- -->
-
- <levelviews:LayersPanel />
-
- </s:HGroup>
- </s:VGroup>
+ <s:VGroup width="100%" height="100%">
+ <s:HGroup>
+ <s:Label text="Background:" />
+ <s:TextInput id="backgroundImagePath" editable="false" text="{level.backgroundImage}" toolTip="{level.backgroundImage}" />
+ <s:Button label="Browse" click="onBrowseForBackgroundImage()" />
+ <s:Button label="New" click="onNew()" />
+ <s:Button label="Save" click="onSave()" />
+ </s:HGroup>
+
+ <s:HGroup width="100%" height="100%">
+ <s:Group>
+ <s:Image source="@Embed(source='/assets/images/iphone.png')"
+ top="30" left="10"/>
+
+ <s:Scroller top="162" left="43"
+ width="320" height="320"
+ id="levelCanvasScroller">
+ <s:Group id="groupWrapper">
+ <s:Rect width="{levelCanvas.width}" height="{levelCanvas.height}">
+ <s:fill>
+ <s:SolidColor color="#FF0000" alpha="0" />
+ </s:fill>
+ </s:Rect>
+
+ <zombiestick:LevelCanvas id="levelCanvas" level="{level}" />
+
+ </s:Group>
+ </s:Scroller>
+ <s:HGroup>
+ <s:Button label="+" width="30" click="onZoomIn()" />
+ <s:Button label="100%" width="60" click="onNormalizeZoom()" />
+ <s:Button label="-" width="30" click="onZoomOut()" />
+ </s:HGroup>
+
+ </s:Group>
+
+ <levelviews:PropertiesPanel />
+
+ <!--
+ <levelviews:MoviePanel movies="{level.movies}" />
+ -->
+
+ <levelviews:LayersPanel />
+
+ </s:HGroup>
+ </s:VGroup>
+ </s:Scroller>
</s:Window>
Oops, something went wrong.

0 comments on commit cf4f6d2

Please sign in to comment.