Questions tagged [craftyjs]

Crafty is an HTML5 game engine written in JavaScript which helps you create games in a structured way. Its core features include Entities & Components, being able to use Canvas, DOM, WebGL and Event binding.

Crafty is an HTML5 game engine written in JavaScript which helps you create games in a structured way. Its core features include:

  • Entities & Components - A clean and decoupled way to organize game elements. No inheritance is needed!
  • Canvas or DOM - Choose the technology to render your entities, it will look exactly the same.
  • Eventbinding - Event system for custom events that can be triggered whenever, whatever and bound just as easy.

For more information, see http://craftyjs.com.

105 questions
0
votes
1 answer

How do I fix 'Uncaught TypeError: Cannot read property 'call' of undefined' in Crafty.js?

So for our project my group and I are trying to program a game. The objective of the game is to change the color of the other player's ship. For example: If Player 1's ship is colored Red, and Player 2's ship is colored green, each bullet from…
user4077377
0
votes
1 answer

Cordova update and lost craftyjs' tween and gravity

I'm trying to update a mobile Cordova game to the following versions: /** * craftyjs 0.7.0 * http://craftyjs.com/ Cordova: { name: 'cordova', description: 'Cordova command line interface tool', 'dist-tags': { latest: '6.0.0', I lost…
fabstao
  • 9
  • 1
  • 6
0
votes
1 answer

Change sprite frame in Craftyjs

How do I manually set the sprite from frame 0 to frame 1? //Load assets Crafty.sprite("assets/img/q.png", { qd1 : [ 0, 0, 17, 16 ], qd2 : [ 0, 17, 17, 16 ] }); var a=Crafty.e("2D, Canvas, SpriteAnimation, qd1").attr({x : 355, y : 225});
Proyb P
  • 35
  • 1
  • 1
  • 7
0
votes
0 answers

Motion in Crafty.js

Im trying to use the Motion component in crafty.js but I fail at the most basic things. It seems like the 'Motion' component is not added. Like this very simple code from example code in the docs. var ent = Crafty.e("2D, Motion"); var vel =…
J.G.Sebring
  • 5,934
  • 1
  • 31
  • 42
0
votes
1 answer

Centering image/entity in Crafty JS

I've got an instance of Crafty running on my page, 320x480. I'm trying to develop a menu for a little game. In the background of the menu scene, I want a pinwheel type effect that rotates. Now, the rotation is not much of an issue, I already have…
SamBC
  • 189
  • 2
  • 8
0
votes
0 answers

How resolve canvas game images with phonegap

I just created a basic game using CraftyJS. I create some characters which are referenced to an image. Those images are located in www/img folder. When i run the app on the emulator the images are blank and only texts are showing. How to resolve…
johndavedecano
  • 522
  • 5
  • 11
0
votes
1 answer

Crafty element with 2 gravity's

I'm trying to understand Crafty. Here's my code. Crafty.init(500,300, document.getElementById('game')); Crafty.e('Floor, 2D, Canvas, Color') .attr({x: 0, y: 250, w: 200, h: 10}) .color('green'); Crafty.e('SecondFloor, 2D, Canvas, Color') …
Mees Maas
  • 29
  • 1
  • 1
  • 7
0
votes
1 answer

Crafty JS error says I'm not closing function

if (char == 'anime') { Crafty.sprite("sprites_hunt_w.png", { guy: [1, 2, 27, 31] }) .reel('guy_right', 1000, [ [1, 64], [34, 64], [65, 65] …
Liam
  • 117
  • 6
0
votes
1 answer

Creating a class of Crafty JS entity (class of a class?)

I am trying to create a class which creates a Crafty entity with specific properties. So far, the functions within the class do not run because 'this' refers to the window object $(document).ready(function () { Crafty.init(window.innerWidth,…
0
votes
2 answers

Date getTime gives low values for longer durations

I am using Date().getTime to measure the duration of a keypress by subtracting the keydown event from the keyup event. However, for keypresses longer than ~500ms, the recorded time appears to return to a lower value. Here is the JSFiddle…
0
votes
1 answer

CraftyJS: I can't destroy an entity with .onHit

I am having a problem with craftyJS. I made a ship that shoots lasers, but I want the lasers to destroy an entity when it collides with it. I already tried to do this, but it don't work. Here is my code: Crafty.init(1340,650,…
user4438529
0
votes
1 answer

cloned entity not draggable although original entity is ,crafyjs

I am building this simple HTML5 drag and drop game using Craftyjs. I created an entity let's call it E1 with some components, one of the components is "Draggable". I created a new entity E2 and made it as a clone of E1 (now E2 should have a copy…
Alsmayer
  • 236
  • 1
  • 4
  • 13
0
votes
1 answer

Drawing a simple circle using Crafty.js and Box2d

i am trying to draw a simple circle using box2d with crafty.js but i can't seem to able to draw it this is the jsfiddle : http://jsfiddle.net/B5UsC/2/ look at this part of the code : var ball = Crafty.e("2D, Canvas,Color, Box2D,ball") …
Sora
  • 2,465
  • 18
  • 73
  • 146
0
votes
0 answers

running craftyjs (via canvas) and redrawing figuers creates weird lines

We are working on a browser/JavaScript based game where sprites are regulary redrawn, however doing so creates weird lines after each redraw. We could of course let the hole view redraw after each frame however that would kill performance quite…
Thijser
  • 2,625
  • 1
  • 36
  • 71
0
votes
1 answer

CraftyJS - viewport.centerOn() not working

I am trying to make 2D JavaScript game with CraftyJS framework. But I am stuck with "centerOn" feature. Here is the code: http://jsfiddle.net/R8ND7/17/ Crafty.init(500, 350, document.getElementById('game')) …
nanuqcz
  • 1,376
  • 3
  • 16
  • 19