Commit 99177252 9917725262afd16d1d8d3ec1ce8018754c03ccf9 by jinwawa

add xml parse to Json

1 parent 173b1bc3
......@@ -41,8 +41,8 @@
},
"_scale": {
"__type__": "cc.Vec3",
"x": 0.27132086548953405,
"y": 0.27132086548953405,
"x": 0.13871663973241932,
"y": 0.13871663973241932,
"z": 1
},
"_quat": {
......@@ -288,8 +288,8 @@
"__id__": 5
},
"_enabled": true,
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_srcBlendFactor": 1,
"_dstBlendFactor": 769,
"_spriteFrame": {
"__uuid__": "14f1599c-036c-486d-abf5-b3566ed39f15"
},
......@@ -406,7 +406,7 @@
"__id__": 8
},
"_enabled": true,
"_srcBlendFactor": 770,
"_srcBlendFactor": 1,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "987745dd-03d6-4de5-b98e-1d5e75c9f2d3"
......
[
{
"__type__": "cc.SceneAsset",
"_name": "",
"_objFlags": 0,
"_native": "",
"scene": {
"__id__": 1
}
},
{
"__type__": "cc.Scene",
"_objFlags": 0,
"_parent": null,
"_children": [
{
"__id__": 2
}
],
"_active": true,
"_level": 0,
"_components": [],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_scale": {
"__type__": "cc.Vec3",
"x": 0.1,
"y": 0.1,
"z": 1
},
"_quat": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"groupIndex": 0,
"autoReleaseAssets": false,
"_id": "c5bb6714-76a5-4b23-9585-4546b56bcd8e"
},
{
"__type__": "cc.Node",
"_name": "Canvas",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 3
},
{
"__id__": 5
},
{
"__id__": 8
}
],
"_active": true,
"_level": 0,
"_components": [
{
"__id__": 10
},
{
"__id__": 11
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 960,
"height": 640
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_position": {
"__type__": "cc.Vec3",
"x": 480,
"y": 320,
"z": 0
},
"_scale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_rotationX": 0,
"_rotationY": 0,
"_quat": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_skewX": 0,
"_skewY": 0,
"groupIndex": 0,
"_id": "2enr7NbbJA+ohEBDG12MuR"
},
{
"__type__": "cc.Node",
"_name": "Main Camera",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [],
"_active": true,
"_level": 1,
"_components": [
{
"__id__": 4
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_position": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_scale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_rotationX": 0,
"_rotationY": 0,
"_quat": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_skewX": 0,
"_skewY": 0,
"groupIndex": 0,
"_id": "6axvtUu8JLGYQswZVb5i5t"
},
{
"__type__": "cc.Camera",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 3
},
"_enabled": true,
"_cullingMask": 4294967295,
"_clearFlags": 7,
"_backgroundColor": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_depth": -1,
"_zoomRatio": 1,
"_targetTexture": null,
"_id": "dfrdGSAPdDCpridUZu5giH"
},
{
"__type__": "cc.Node",
"_name": "Bg_long",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [],
"_active": true,
"_level": 1,
"_components": [
{
"__id__": 6
},
{
"__id__": 7
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 7280,
"height": 1110
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_position": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_scale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_rotationX": 0,
"_rotationY": 0,
"_quat": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_skewX": 0,
"_skewY": 0,
"groupIndex": 0,
"_id": "9bJ6W6GQ9AuahEivQhXI7q"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
},
"_enabled": true,
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": null,
"_type": 0,
"_sizeMode": 1,
"_fillType": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_state": 0,
"_atlas": null,
"_id": "71UYoTd3tBYZmtHLuAObd3"
},
{
"__type__": "cc.Animation",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 5
},
"_enabled": true,
"_defaultClip": {
"__uuid__": "e0232f2e-c019-4cec-ac64-1cdf42ad3792"
},
"_clips": [
{
"__uuid__": "e0232f2e-c019-4cec-ac64-1cdf42ad3792"
}
],
"playOnLoad": true,
"_id": "c6mMiohwNG6pU+M0q1YOzM"
},
{
"__type__": "cc.Node",
"_name": "Hero",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [],
"_active": true,
"_level": 1,
"_components": [
{
"__id__": 9
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_position": {
"__type__": "cc.Vec3",
"x": -229,
"y": -220,
"z": 0
},
"_scale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_rotationX": 0,
"_rotationY": 0,
"_quat": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_skewX": 0,
"_skewY": 0,
"groupIndex": 0,
"_id": "8cq0Mn63pN2YDLO5ii37LQ"
},
{
"__type__": "dragonBones.ArmatureDisplay",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 8
},
"_enabled": true,
"_armatureName": "armatureName",
"_animationName": "Animation1",
"_preCacheMode": 0,
"_cacheMode": 0,
"playTimes": -1,
"premultipliedAlpha": false,
"_armatureKey": "e3ad9b78-ae63-4929-81c2-5781ca616f08#cdd960ea-e3ab-4991-a37d-3f8f88243de7",
"_accTime": 0,
"_playCount": 0,
"_frameCache": null,
"_curFrame": null,
"_playing": false,
"_armatureCache": null,
"_N$dragonAsset": {
"__uuid__": "e3ad9b78-ae63-4929-81c2-5781ca616f08"
},
"_N$dragonAtlasAsset": {
"__uuid__": "cdd960ea-e3ab-4991-a37d-3f8f88243de7"
},
"_N$_defaultArmatureIndex": 0,
"_N$_animationIndex": 1,
"_N$_defaultCacheMode": 0,
"_N$timeScale": 1,
"_N$debugBones": false,
"_N$enableBatch": false,
"_id": "69fvvqS0tJHpuXMcwVczRW"
},
{
"__type__": "cc.Canvas",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_designResolution": {
"__type__": "cc.Size",
"width": 960,
"height": 640
},
"_fitWidth": false,
"_fitHeight": true,
"_id": "72z44+175OfaMOhtsD1Huo"
},
{
"__type__": "46717GP6RtOGobAYIAnkxCA",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_cLog": null,
"_cApplication": null,
"_cFocus": null,
"_aFocusTargets": [],
"_fiCurrentFocus": null,
"_iSceneStatus": 0,
"_fFocusScaleFactor": 1.06,
"_bIsFocusInit": false,
"_oSceneContext": null,
"_oNextSceneParameter": null,
"_compPlayer": null,
"_aTouchContext": [],
"_defaultBackScene": null,
"_oFocusScaleFactorInfo": null,
"holdClick": false,
"_bShowExitBox": false,
"_id": "01a+mE585Ho7WhSVhlk2o5"
}
]
\ No newline at end of file
{
"ver": "1.0.1",
"uuid": "c5bb6714-76a5-4b23-9585-4546b56bcd8e",
"asyncLoadAssets": false,
"autoReleaseAssets": false,
"subMetas": {}
}
\ No newline at end of file
......@@ -19,7 +19,7 @@ cc.Class({
onLoad: function () {
this._super();
this._hero_start_x = 500;
this._hero_start_x = 400;
this.bg_1 = this.node.getChildByName("bg_1");
this.bg_2 = this.node.getChildByName("bg_2");
this.cur_bg = this.bg_1;
......@@ -28,6 +28,8 @@ cc.Class({
this.animLayer = this.testmap.getComponent(cc.TiledMap).getLayer("Animal");
this.hero = this.node.getChildByName("hero");
this._hero_y = this.hero.y;
this.startRun=true;
},
keyDownDirection: function (Direct) {
......@@ -70,8 +72,9 @@ cc.Class({
case cc.macro.KEY.enter:
case cc.macro.KEY.space:
case Common.ANDROID_KEY.enter:
this._hero_start_x += 100;
// this._hero_start_x += 100; //造成误差
this._speed = 1;
this.startRun=true;
// this.hero.getComponent(dragonBones.ArmatureDisplay).playAnimation("Animation1");
// this.doCurrentFocusTVLinkAction(Common.TV_LINK_ACTION_CLICK);
break;
......@@ -92,23 +95,27 @@ cc.Class({
this.bg_2.x = this.bg_1.x + 1820;
this.cur_bg = this.bg_1;
} else {
this.bg_1.x = this.bg_2.x + 1820;
this.bg_1.x = this.bg_2.x + 1815;
this.cur_bg = this.bg_2;
}
}
// cc.log("背景图位置:"+this.cur_bg.x);
// cc.log("hero位置--------》" + this._hero_start_x);
var pos = this._getTilePos(cc.v2(this._hero_start_x, 4));
// cc.log("pos位置------------------》"+pos);
// cc.log("位置----------》"+pos);
if (this._hero_start_x < this._hero_end_x) { //不能超过瓦片地图最长长度
//判断gid是否为0,该地图位置就会出现障碍物
var gid = this.animLayer.getTileGIDAt(pos);
// cc.log("gid========" + gid);
if (gid != 0) {
this._speed = 0;
this.hero.getComponent(dragonBones.ArmatureDisplay).playAnimation("");
}
}
// if (this._hero_start_x < this._hero_end_x) { //不能超过瓦片地图最长长度
// //判断gid是否为0,该地图位置就会出现障碍物
// var gid = this.animLayer.getTileGIDAt(pos);
// // cc.log("gid========" + gid);
// if (gid != 0 && this.startRun) {
// this.startRun=false;
// this._speed = 0;
// this.hero.getComponent(dragonBones.ArmatureDisplay).playAnimation("");
// }
// }
},
doCurrentFocusTVLinkAction: function (strAction) {
......
var Common = require('Common');
var Network = require('Network');
var TVFocus = require('TVFocus');
var FocusInfo = require('FocusInfo');
var TVCanvas = require('TVCanvas');
var TVScrollParameter = require('TVScrollParameter');
var ListView = require('ListView');
var ListCell = require('ListCell');
var xmlToJSON=require('xmlToJSON');
cc.Class({
extends: TVCanvas,
properties: {
},
onLoad: function () {
this._super();
var self=this;
//动态加载背景图,需指定类型(需要拼接图片),指定尺寸(目前使用的是7280*720)
cc.loader.loadRes("game/explore_plus", cc.Texture2D, function (err, texture) {
self.node.getChildByName("Bg_long").getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(texture);
});
cc.loader.loadRes("config/explore_config",function(err,str){
cc.log("源xml--------------->"+str);
// var result=xmlToJSON.parseString(str);
var x2js = new xmlToJSON();
var result=x2js.xml_str2json(str);
cc.log("解析后xml------------>"+JSON.stringify(result));
cc.log("解析后xml------------>"+result.root.explore[0]["_choice2"]);
// cc.log("解析后xml------------>"+result.root[0].explore[0]["_attr"].name["_value"]);
})
},
update:function(){
// cc.log("背景图片-----------------》"+this.node.getChildByName("Bg_long").x);
},
});
{
"ver": "1.0.5",
"uuid": "4671718f-e91b-4e1a-86c0-608027931080",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.0.5",
"uuid": "6cb548d8-7dc8-47f9-9c51-65f091293903",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
{
"__type__": "cc.AnimationClip",
"_name": "bg_roll",
"_objFlags": 0,
"_native": "",
"_duration": 7.5,
"sample": 8,
"speed": 0.3,
"wrapMode": 2,
"curveData": {
"props": {
"x": [
{
"frame": 0,
"value": 2899
},
{
"frame": 7.5,
"value": -744
}
]
}
},
"events": []
}
\ No newline at end of file
{
"ver": "1.0.0",
"uuid": "e0232f2e-c019-4cec-ac64-1cdf42ad3792",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.2.0",
"uuid": "41a684e8-62cf-464e-81a6-04833d9d9628",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"subMetas": {
"explore_plus": {
"ver": "1.0.4",
"uuid": "9c2b11fd-1118-470b-985d-60b8b4617e25",
"rawTextureUuid": "41a684e8-62cf-464e-81a6-04833d9d9628",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 7280,
"height": 1110,
"rawWidth": 7280,
"rawHeight": 1110,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file
{
"ver": "1.0.1",
"uuid": "d2c251d8-e7e5-49e5-8062-af1156471aaa",
"isSubpackage": false,
"subpackageName": "",
"subMetas": {}
}
\ No newline at end of file
<root>
<explore id="1" id2="1" name="555,没人陪我玩,好寂寞。" type="1" map="1" choice1="陪陪蜥蜴,和它交朋友" choice2="陪它去看《小猪佩奇》,开朗的孩子朋友多。" function="1:500054" image="xiyi.png" reward="10001:100"/>
<explore id="2" id2="1" name="555,没人陪我玩,好寂寞。" type="1" map="1" choice1="陪陪蜥蜴,和它交朋友" choice2="去玩叠蛋糕给它看,这个小游戏可好玩了!" function="2:300056" image="xiyi.png" reward="10001:100"/>
<explore id="3" id2="1" name="555,没人陪我玩,好寂寞。" type="1" map="1" choice1="陪陪蜥蜴,和它交朋友" choice2="和小狗一起听儿歌:工程车之歌" function="3:18897" image="xiyi.png" reward="10001:100"/>
<explore id="4" id2="1" name="555,没人陪我玩,好寂寞。" type="1" map="1" choice1="我想和别的小动物一起玩。" choice2="" function="1:500054" image="xiyi.png" reward="10001:100"/>
<explore id="5" id2="1" name="捡到一个宝箱。" type="2" map="1" choice1="" choice2="" function="1:500054" image="baoxiang.png" reward="10001:100"/>
<explore id="6" id2="1" name="迷路了,进度减少10%" type="3" map="1" choice1="" choice2="" function="1:500054" image="xiyi.png" reward="10001:100"/>
<explore id="7" id2="1" name="找到了捷径,进度增加10%" type="4" map="1" choice1="" choice2="" function="1:500054" image="xiyi.png" reward="10001:100"/>
</root>
\ No newline at end of file
{
"ver": "2.0.0",
"uuid": "728ff75e-bd5d-4730-a3a5-d463bca6279e",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "2.2.0",
"uuid": "4ade9de4-3d39-4b87-a82b-92f8ded29646",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
"premultiplyAlpha": false,
"subMetas": {
"explore_plus": {
"ver": "1.0.4",
"uuid": "0dde25a8-400a-4010-ba37-017445b4e960",
"rawTextureUuid": "4ade9de4-3d39-4b87-a82b-92f8ded29646",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 7280,
"height": 1110,
"rawWidth": 7280,
"rawHeight": 1110,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"subMetas": {}
}
}
}
\ No newline at end of file