Skip to content

Commit 8829b2b

Browse files
committed
Build Phaser v2.7.8
1 parent fa08591 commit 8829b2b

File tree

428 files changed

+9792
-8077
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

428 files changed

+9792
-8077
lines changed

build/creature.js

+126-1
Original file line numberDiff line numberDiff line change
@@ -6486,10 +6486,74 @@ function Creature(load_data)
64866486
this.boundary_indices = [];
64876487
this.boundary_min = vec2.create();
64886488
this.boundary_max = vec2.create();
6489+
this.anchor_point_map = {};
6490+
this.anchor_points_active = false;
64896491

64906492
this.LoadFromData(load_data);
64916493
};
64926494

6495+
// experimental - must enable - disabled by default
6496+
Creature.prototype.SetAnchorPointEnabled = function(value) {
6497+
this.anchor_points_active = value;
6498+
};
6499+
6500+
Creature.prototype.GetPixelScaling = function(desired_x, desired_y)
6501+
{
6502+
// compute pixel scaling relative to mesh scaling
6503+
this.ComputeBoundaryMinMax();
6504+
6505+
var mesh_size_x = this.boundary_max[0] - this.boundary_min[0];
6506+
var mesh_size_y = this.boundary_max[1] - this.boundary_min[1];
6507+
6508+
var scale_x = 1.0 / mesh_size_x * desired_x;
6509+
var scale_y = 1.0 / mesh_size_y * desired_y;
6510+
6511+
return [scale_x, scale_y];
6512+
};
6513+
6514+
Creature.prototype.SetAnchorPoint = function(x, y, anim_clip_name_in) {
6515+
if (!anim_clip_name_in) {
6516+
anim_clip_name_in = 'default';
6517+
}
6518+
6519+
this.ComputeBoundaryMinMax();
6520+
6521+
var mesh_size_x = this.boundary_max[0] - this.boundary_min[0];
6522+
var mesh_size_y = this.boundary_max[1] - this.boundary_min[1];
6523+
6524+
var target_size_x = this.boundary_max[0];
6525+
var target_size_y = this.boundary_max[1];
6526+
6527+
if (x !== 0) {
6528+
target_size_x = this.boundary_max[0] - (mesh_size_x * (x));
6529+
}
6530+
6531+
if (y !== 0) {
6532+
target_size_y = this.boundary_max[1] - (mesh_size_y * (y));
6533+
}
6534+
6535+
var anchor_point_base = {
6536+
AnchorPoints: [
6537+
{
6538+
point: [target_size_x, target_size_y],
6539+
anim_clip_name: anim_clip_name_in
6540+
}
6541+
]
6542+
};
6543+
6544+
this.anchor_point_map = this.FillAnchorPointMap(anchor_point_base);
6545+
};
6546+
6547+
Creature.prototype.GetAnchorPoint = function(anim_clip_name_in)
6548+
{
6549+
if(anim_clip_name_in in this.anchor_point_map)
6550+
{
6551+
return this.anchor_point_map[anim_clip_name_in];
6552+
}
6553+
6554+
return vec2.fromValues(0, 0);
6555+
};
6556+
64936557
// Fills entire mesh with (r,g,b,a) colours
64946558
Creature.prototype.FillRenderColours = function(r, g, b, a)
64956559
{
@@ -6652,8 +6716,45 @@ Creature.prototype.LoadFromData = function(load_data)
66526716
}
66536717

66546718
this.render_composition.resetToWorldRestPts();
6719+
6720+
// Load Anchor Points
6721+
if("anchor_points_items" in load_data)
6722+
{
6723+
var anchor_point_base = load_data["anchor_points_items"];
6724+
this.anchor_point_map = this.FillAnchorPointMap(anchor_point_base);
6725+
}
66556726
};
66566727

6728+
Creature.prototype.FillAnchorPointMap = function(json_obj)
6729+
{
6730+
var anchor_data_node = json_obj["AnchorPoints"];
6731+
6732+
ret_map = {};
6733+
for (var i = 0; i < anchor_data_node.length; i++)
6734+
{
6735+
var cur_node = anchor_data_node[i];
6736+
var cur_pt = this.ReadVector2JSON(cur_node, "point");
6737+
var cur_name = cur_node["anim_clip_name"];
6738+
6739+
ret_map[cur_name] = cur_pt;
6740+
}
6741+
6742+
return ret_map;
6743+
};
6744+
6745+
6746+
Creature.prototype.ReadVector2JSON = function(data, key)
6747+
{
6748+
var raw_array = this.getFloatArray(data[key]);
6749+
return vec2.fromValues(raw_array[0], raw_array[1]);
6750+
};
6751+
6752+
Creature.prototype.getFloatArray = function(raw_data)
6753+
{
6754+
return raw_data;
6755+
};
6756+
6757+
66576758
// CreatureAnimation
66586759
function CreatureAnimation(load_data, name_in)
66596760
{
@@ -6667,6 +6768,28 @@ function CreatureAnimation(load_data, name_in)
66676768
this.LoadFromData(name_in, load_data);
66686769
};
66696770

6771+
CreatureManager.prototype.AlterBonesByAnchor = function(bones_map, animation_name_in)
6772+
{
6773+
if(this.target_creature.anchor_points_active == false)
6774+
{
6775+
return;
6776+
}
6777+
6778+
var anchor_point = this.target_creature.GetAnchorPoint(animation_name_in);
6779+
for(var cur_bone_key in bones_map)
6780+
{
6781+
var cur_bone = bones_map[cur_bone_key];
6782+
var start_pt = cur_bone.getWorldStartPt();
6783+
var end_pt = cur_bone.getWorldEndPt();
6784+
6785+
start_pt = vec3.subtract(start_pt, start_pt, vec3.fromValues(anchor_point[0], anchor_point[1], 0));
6786+
end_pt = vec3.subtract(end_pt, end_pt, vec3.fromValues(anchor_point[0], anchor_point[1], 0));
6787+
6788+
cur_bone.setWorldStartPt(start_pt);
6789+
cur_bone.setWorldEndPt(end_pt);
6790+
}
6791+
};
6792+
66706793
CreatureAnimation.prototype.LoadFromData = function(name_in, load_data)
66716794
{
66726795
var json_anim_base = load_data["animation"];
@@ -6783,7 +6906,7 @@ CreatureManager.prototype.CreateAllAnimations = function(load_data)
67836906
this.CreateAnimation(load_data, cur_name);
67846907
}
67856908

6786-
this.SetActiveAnimationName (all_animation_names.get(0));
6909+
this.SetActiveAnimationName (all_animation_names[0]);
67876910
};
67886911

67896912
// Add an animation
@@ -7162,6 +7285,8 @@ CreatureManager.prototype.PoseCreature = function(animation_name_in, target_pts)
71627285

71637286
bone_cache_manager.retrieveValuesAtTime(this.getRunTime(),
71647287
bones_map);
7288+
7289+
this.AlterBonesByAnchor(bones_map, animation_name_in);
71657290

71667291
if(this.bones_override_callback != null)
71677292
{

build/creature.map

+1-1
Large diffs are not rendered by default.

build/creature.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/custom/p2.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)