- Where Developers Learn, Share, & Build Careers


I'm using to close the Github game, and I'm having some trouble with the animation for the first time when I I started the animation (when I initialize the player unit in the main scene) then it works. But when I set the animation through the component of my custom control, it only plays the first frame of the animation.

I believe the problem is in the custom controllables component, so here is the code for it:

If you want to clone it and check it is all code:

If someone knows what the problem might be, please tell me thank you!

Edit: Everything is stripped except for the movement and what the animation should be: here

  var SPRITE_SIZE = 32; Crafty.init (); Crafty.canvas.init (); Crafty.sprite (SPRITE_SIZE, "http://i.imgur.com/9sN9V.png", {player_east_1: [0, 0], player_stest: [1, 0], player_ast_3: [2, 0], player_we_1: [ Player_south_2: [1, 2], player_south_3: [2, 2], player_north_1: [0, 1] 3], player_north_2: [1, 3], player_north_3: [2, 3]}); Crete Chest ("2D, DOM, text") .attr ({w: 100, h: 20, x: 150, Y: 120}) .text ("loading"). Css ({"text-align": "center"}); Crafty.load (["http://i.imgur.com/9sN9V.png"], function () {ct. scene ("main");});}); Crafty.scene ("main", function () {Crafty.background ("# 000"); var player = Crafty.e ("2D, DOM, Sprite animation, Player_STesty, collision, tile collision, custom control"). Attr ({x: 0, y: 0, x_velocity: 0, y_velocity: 0, w: SPRITE_SIZE, h: SPRITE_SIZE}) value ("stand_st", 0, 0, 0). Value ("stand_west", 0, 1 , 0) ("stand_south", 0, 3, 0). Value ("walk_stast", [[0, 0], [1, 0], [0, 0]], [2, 0]]). ( "[0, 2], [1, 2], [0, 2], [ Mann ("stand_st", 45, -1). ("Walk_arth", [[0, 3], [1, 3], [0, 3], [2, 3]]). Custom Control ();}); Crafty.c ("CustomControls", {CustomControls: function () {this.bind ("EnterFrame", function () {var up = Crafty.keydown [Crafty.keys.UP_ARROW]; var below = Crafty.keydown [Clever keys .dOWN_ARROW]; var left = Crafty.keydown [Crafty.keys.LEFT_ARROW]; var correct = cunning keyboard [crutches.kiece.RIGHT_ARROW]; if (up) {this.y_velocity = -2; (((Walk! ("Walk_north") ("walk_south") Chetan ("walk_north", 45, -1);}} if (below) {this.y_velocity = 2; if (! This.isplaying ("walk_south") } {This.stop (). Chetan ("walk_south", 45, -1);}} if (left) {this.x_velocity = -2; (!! This.isplaying ("walk_west")) {this.stop ("Walk_west", 45, -1);}} If (right) {this.x_velocity = 2; if (! Run it ("walk_east")) {this.stop (). Chetan ("Walk_east " , 45, -1);}} If (! Left & amp;; right!) {This.x_velocity = 0; this.stop ();} If (! Up and down!) {This Y_velocity = 0; This.stop ();} this.x + = this.x_velocity; this.y + = this.y_velocity;});}}}; Crafty.scene ("Loading"); One ???? At the end of    

"enterFrame" you have: < / P>

  if (! Left & amp; right) {this.x_velocity = 0; This.stop (); } If (! Up and down!) {This.y_velocity = 0; This.stop (); }   

Therefore, the animation has always been turned off and then restarted from the beginning to the next frame, for example, when you are a player (! Left & amp; amp ;! Right) evaluates right and the animation stops if

is to stop the same animation only (! Left and right!) {This.x_velocity = 0; } If (! Up and down!) {This.y_velocity = 0; } If ((top (bottom | bottom | left | right)) {this.stop ();}

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -