Commit d3110477 authored by Hubert Denkmair's avatar Hubert Denkmair
Browse files

follow snakes by clicking on their heads or names

parent ab7b4735
......@@ -83,6 +83,8 @@ GameVisualization.prototype.CreateSnake = function(bot)
snake.db_id = bot.db_id;
this.snakes[bot.id] = snake;
this.snakesContainer.addChild(snake.Container);
snake.GetNameSprite().on('click', function() { this.FollowName(bot.name); }, this);
snake.GetHeadSprite().on('click', function() { this.FollowName(bot.name); }, this);
if (snake.GetName() == this.follow_name)
{
......
......@@ -23,12 +23,14 @@ function Snake(headTexture, segmentPool, name, colorScheme, world_size_x, world_
this._headSegment = new SnakeSegment(headTexture);
this._headSegment.SetPosition(-100000, -100000);
this._headSegment.AddSprites(this.Container);
this.GetHeadSprite().interactive = true;
this._nameText = new PIXI.Text(name, {fill:'white', fontSize:64, fontWeight:"bold", dropShadow:true, dropShadowBlur:3, dropShadowDistance:6});
this._nameText.updateText();
this._nameSprite = new PIXI.Sprite(this._nameText.texture);
this._nameSprite.scale.set(0.2, 0.2);
this._nameSprite.scale.set(0.3, 0.3);
this._nameSprite.anchor.set(1.2, 0.5);
this._nameSprite.interactive = true;
this.Container.addChild(this._nameSprite);
this.SetWorldSize(world_size_x, world_size_y);
......@@ -142,6 +144,11 @@ Snake.prototype.GetHeadSprite = function()
return this._headSegment.GetMainSprite();
};
Snake.prototype.GetNameSprite = function()
{
return this._nameSprite;
};
Snake.prototype.GetHeadX = function()
{
return this._headSegment.x;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment