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
1
vote
1 answer

Undefined variables in well defined loops

I wonder if you can set me straight on some javascript I'm a little confused with. The code is over here: http://jsfiddle.net/Lbd5k5zh/. The piece of code that escapes me is: [...] // Locate this entity at the given position on the grid at:…
cookie
  • 2,546
  • 7
  • 29
  • 55
1
vote
1 answer

About Crafty - Isometric and gravity; also fourway

I have two questions about Crafty (I've also asked in their google group community, but it seems very few people look at that). I've followed this tutorial http://buildnewgames.com/introduction-to-crafty/ and also took a look at the "isometric" demo…
1
vote
1 answer

Moving to phonegap with CraftyJS, how do I convert the twoway keyboard event?

Ive built an app with craftyjs where my playerobject has gravity and the twoway keyboard event making it jump, by clicking UP/W key. The problem taking it to phonegap and mobile devices is no keyboard :) And how can i trigger that twoway event on…
Jason94
  • 13,320
  • 37
  • 106
  • 184
1
vote
2 answers

Collision detection on a tweened object

I cann't get it to work, seems like tweened objects don't fire the 'Moved' event? I'm tweening a object across the screen, and need to check if it collided with the player (that flies up and down by the keyboard events). It works if I append the…
Jason94
  • 13,320
  • 37
  • 106
  • 184
1
vote
1 answer

Mouse click doesn't fire event with Crafty.js

I've been trying to build a game using Crafty.js. I have an image that serves as a button, and once the user clicks on it he will be led to the next page. However, for some reason the mouse click just isn't firing. Any ideas? Crafty.scene('Main',…
Andrew
  • 3,501
  • 8
  • 35
  • 54
1
vote
1 answer

Override function in craftyjs

I'm new to JS and trying to override a function in Craftyjs, here is my code: Crafty.c('TestA', { init: function() { Crafty.addEvent(this, Crafty.stage.elem, "mousedown", this._e_clickListener); }, …
eee
  • 280
  • 4
  • 15
1
vote
1 answer

Overwriting localStorage with JSON

This is a follow-up question to this I started using the localStorage function, and am unsure whether or not its working as intended. I want to overwrite a boolean in my JSON file. Player hits an exit in a stage, then it triggers the load of the…
Naoto Ida
  • 157
  • 3
  • 13
1
vote
1 answer

Workaround for not being able to save booleans with HTML5 Web Storage

I'm currently making a Mario-esque game with Javascript, or more precisely, CraftyJS. I've looked here as reference, and understand how to save values inputed by the user. But what I want to accomplish is to save certain booleans(is that what they…
Naoto Ida
  • 157
  • 3
  • 13
1
vote
5 answers

jQuery functions not working after JS innerHTML property

I am using this code in my application: document.getElementById("inventory_box").innerHTML = ""; The #inventory_box element is present already, so it just spews out the IMG into #inventory_box. What I want is…
Naoto Ida
  • 157
  • 3
  • 13
1
vote
0 answers

Crafty.js bind not working in Firefox 24.0

I have a very simple Crafty.js script working in Chrome. in my component file I have this component: Crafty.c('PlayerCharacter', { init: function() { var playerRef = this; playerRef.bind("KeyDown", function(e) { if…
avrono
  • 1,648
  • 3
  • 19
  • 40
1
vote
2 answers

Craftyjs Sprite Animation issue

I'm currently trying to make a game with crafty js and I'm stuck with the sprite Animation. I don't really know what I'm doing wrong .. Here is the working code : http://aaahdontpaintmeinred.me.pn/ Here is how I load the sprite in my loading scene…
Sladix
  • 712
  • 2
  • 7
  • 19
1
vote
2 answers

Collision detection for one frame in JavaScript

I'm playing around with the Crafty.js game engine. I have a small game where the player is a ball and he drops down to platforms. Every time he hits the next platform, he gains a point. The score is stored as a variable and displayed on screen. I'm…
Kyle Morgan
  • 660
  • 1
  • 11
  • 21
1
vote
1 answer

Windows Phone 8 + PhoneGap + Crafty = Gray Shading

I'm trying to create a small game in WP8 and PhoneGap, and wanted to use the Crafty (CraftyJS) library. The game seems to be loading correctly (graphics and logic seems fine), but whenever I press anywhere on the screen (both in the Emulator and in…
SaguiItay
  • 2,145
  • 1
  • 18
  • 40
1
vote
1 answer

RequireJS some (not all) functions are undefined

I'm not sure anybody out there will be able to help with this, but here goes. I'm currently refactoring a game I'm writing with CraftyJS (an excellent component based game engine) to use RequireJS. Everything's been going pretty well, but suddenly…
samson
  • 1,152
  • 11
  • 23
1
vote
2 answers

Script to measure the passage of time?

I'm currently developing a small game for a class using Crafty, and our game requires the passage of time. To give context, it's a tamagotchi-like game where the player controls a creature and feeds it, grooms it, etc., when required, so we need to…
Ana Ameer
  • 671
  • 11
  • 30