update
This commit is contained in:
28
src/client/haxe/layout/frames/start.json
Normal file
28
src/client/haxe/layout/frames/start.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"pWidth": 100, "pHeight": 100,
|
||||
"views": [
|
||||
{
|
||||
"@type": "haxework.gui.ImageView",
|
||||
"image": "@asset:image:resources/images/logo/logo.png",
|
||||
"contentSize": true, "bottomMargin": 15
|
||||
},
|
||||
{
|
||||
"id": "start_1p",
|
||||
"@type": "haxework.gui.ButtonView",
|
||||
"text": "1 Player",
|
||||
"@style": "button"
|
||||
},
|
||||
{
|
||||
"id": "start_2p",
|
||||
"@type": "haxework.gui.ButtonView",
|
||||
"text": "2 Player",
|
||||
"@style": "button"
|
||||
},
|
||||
{
|
||||
"id": "start_lan",
|
||||
"@type": "haxework.gui.ButtonView",
|
||||
"text": "Multiplayer",
|
||||
"@style": "button"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
"pWidth": 100, "pHeight": 100,
|
||||
"views": [
|
||||
{
|
||||
"visible": false, "inLayout": false,
|
||||
"id":"top", "@type": "haxework.gui.HGroupView",
|
||||
"pWidth": 100, "height": 44,
|
||||
"skin": {
|
||||
@@ -34,6 +35,10 @@
|
||||
"fillType": "REPEAT"
|
||||
},
|
||||
"views": [
|
||||
{
|
||||
"id": "start",
|
||||
"@type": "ru.m.tankz.view.frames.StartFrame"
|
||||
},
|
||||
{
|
||||
"id": "auth",
|
||||
"@type": "ru.m.tankz.view.frames.AuthFrame"
|
||||
|
||||
@@ -1,18 +1,6 @@
|
||||
{
|
||||
"_button_skin": {
|
||||
"skin": {
|
||||
"@type": "haxework.gui.skin.ButtonBitmapSkin",
|
||||
"image": "@asset:image:resources/images/map/map_4.png",
|
||||
"fillType": "REPEAT"
|
||||
},
|
||||
"fontColor": "0xffffff",
|
||||
"fontEmbed": true,
|
||||
"fontFamily": "@res:text:fontName",
|
||||
"fontSize": 16,
|
||||
"shadowColor": "0x000000"
|
||||
},
|
||||
|
||||
"button_skin": {
|
||||
"button": {
|
||||
"width":250, "height":60,
|
||||
"skin": {
|
||||
"@type": "haxework.gui.skin.ButtonBitmapSkin",
|
||||
"upImage": "@asset:image:resources/images/control/button_normal.png",
|
||||
@@ -20,7 +8,7 @@
|
||||
"overImage": "@asset:image:resources/images/control/button_over.png",
|
||||
"fillType": "NINEPATH"
|
||||
},
|
||||
"fontColor": "0xffffff"
|
||||
"fontFamily":"@res:text:font", "fontEmbed":true, "fontColor":"0xE7E0BB", "fontSize":20
|
||||
},
|
||||
|
||||
"label": {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package ru.m.tankz;
|
||||
|
||||
import flash.text.Font;
|
||||
import ru.m.tankz.view.frames.StartFrame;
|
||||
import haxework.log.SocketLogger;
|
||||
import haxework.resources.Resources;
|
||||
import haxework.resources.IResources;
|
||||
@@ -49,9 +51,8 @@ class Client implements IConnectionHandler {
|
||||
Provider.setFactory(IResources, Resources);
|
||||
Provider.setFactory(GameData, GameData);
|
||||
|
||||
//var font = Assets.getFont("resources/fonts/8-BIT WONDER.TTF");
|
||||
//Provider.get(IResources).text.put("fontName", font.fontName);
|
||||
Provider.get(IResources).text.put("fontName", "Arial");
|
||||
var font:Font = Font.enumerateFonts()[0];
|
||||
Provider.get(IResources).text.put("font", "Bookman Old Style");
|
||||
|
||||
Provider.set(IPacketBuilder, new PacketBuilder());
|
||||
#if flash
|
||||
@@ -66,7 +67,7 @@ class Client implements IConnectionHandler {
|
||||
Provider.set(IFrameSwitcher, view.switcher);
|
||||
Root.bind(view);
|
||||
view.logout.onPress = this;
|
||||
view.switcher.change(AuthFrame.ID);
|
||||
view.switcher.change(StartFrame.ID);
|
||||
}
|
||||
|
||||
public function onPress(view:ButtonView):Void {
|
||||
|
||||
@@ -30,11 +30,11 @@ class PlayerTank extends Tank {
|
||||
}
|
||||
case TankAction.SHOT:
|
||||
//ToDo:
|
||||
//shot();
|
||||
Provider.get(IConnection).send(
|
||||
shot();
|
||||
/*Provider.get(IConnection).send(
|
||||
new GameActionRequest()
|
||||
.setType(GameActionType.SHOT)
|
||||
);
|
||||
);*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,22 +49,22 @@ class PlayerTank extends Tank {
|
||||
|
||||
private function updateMove():Void {
|
||||
if (moveQueue.length == 0) {
|
||||
//stop();
|
||||
Provider.get(IConnection).send(
|
||||
stop();
|
||||
/*Provider.get(IConnection).send(
|
||||
new GameActionRequest()
|
||||
.setType(GameActionType.STOP)
|
||||
);
|
||||
);*/
|
||||
} else {
|
||||
switch (keyBinding.get(moveQueue[0])) {
|
||||
case TankAction.MOVE(direction):
|
||||
//ToDo:
|
||||
//move(direction);
|
||||
Provider.get(IConnection).send(
|
||||
move(direction);
|
||||
/*Provider.get(IConnection).send(
|
||||
new GameActionRequest()
|
||||
.setType(GameActionType.MOVE)
|
||||
.setDirectionX(direction.x)
|
||||
.setDirectionY(direction.y)
|
||||
);
|
||||
);*/
|
||||
case _:
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ class GameFrame extends VGroupView implements ViewBuilder implements IPacketHand
|
||||
var persons = Provider.get(GameData).game.persons;
|
||||
engine.personId = person.id;
|
||||
engine.init(DEFAULT.CONFIG);
|
||||
engine.initTanks(persons);
|
||||
content.addEventListener(Event.ENTER_FRAME, updateGame);
|
||||
Provider.get(IConnection).packetHandler.addListener(this);
|
||||
render.draw(engine);
|
||||
@@ -41,8 +42,8 @@ class GameFrame extends VGroupView implements ViewBuilder implements IPacketHand
|
||||
}
|
||||
|
||||
private function updateGame(_):Void {
|
||||
//game.update();
|
||||
//render.draw(game);
|
||||
engine.update();
|
||||
render.draw(engine);
|
||||
}
|
||||
|
||||
public function onGameUpdateResponse(packet:GameUpdateResponse):Void {
|
||||
|
||||
35
src/client/haxe/ru/m/tankz/view/frames/StartFrame.hx
Normal file
35
src/client/haxe/ru/m/tankz/view/frames/StartFrame.hx
Normal file
@@ -0,0 +1,35 @@
|
||||
package ru.m.tankz.view.frames;
|
||||
|
||||
import ru.m.tankz.proto.Person;
|
||||
import ru.m.tankz.proto.Game;
|
||||
import haxework.gui.frame.IFrameSwitcher;
|
||||
import ru.m.tankz.data.GameData;
|
||||
import haxework.provider.Provider;
|
||||
import haxework.gui.ButtonView;
|
||||
import haxework.gui.ViewBuilder;
|
||||
import haxework.gui.VGroupView;
|
||||
|
||||
@:template("layout/frames/start.json", "layout/styles.json")
|
||||
class StartFrame extends VGroupView implements ViewBuilder {
|
||||
|
||||
public static inline var ID = "start";
|
||||
|
||||
public function init() {
|
||||
start_1p.onPress = this;
|
||||
}
|
||||
|
||||
public function onPress(view:ButtonView):Void {
|
||||
switch (view.id) {
|
||||
case "start_1p":
|
||||
var player = new Person();
|
||||
player.id = 1;
|
||||
var game = new Game();
|
||||
game.creator = player;
|
||||
game.persons.push(player);
|
||||
game.id = 1;
|
||||
Provider.get(GameData).person = player;
|
||||
Provider.get(GameData).game = game;
|
||||
Provider.get(IFrameSwitcher).change(GameFrame.ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user