moayyad February 15th, 2014 hello ,
I watched the (Holes and Moles ) tutorial , and it was a really good idea to separate objects and their behaviors in a different java script file
Is it possible to do the same functionality in isometric games?
by the way , this works fine
wade.iso.createObject(House, {x:11, z: 15});where house.js is :
House = { sprites: { image: 'images/1.png', scale: 3, offset: {x: 0.01, y: 0.05}, sortPoint: {y: 0.27} }, gridSize: {x: 4, z: 4} };but how to add behaviors to house.js ?
hermes February 15th, 2014 Have you tried adding a behaviors field in your House data object? It should work...
House = { sprites: { image: 'images/1.png', scale: 3, offset: {x: 0.01, y: 0.05}, sortPoint: {y: 0.27} }, gridSize: {x: 4, z: 4}, behaviors: ["myBehavior1", "myBehavior2"] };By the way, if you are using wade.iso 1.0.1 (the latest version) you can do all this in a json file, you don't need to have wade.iso.createObject in your main java script file, you can just load a json map with all the data for terrain and objects.
moayyad February 15th, 2014 thank you ! loading JSON is an awesome idea .
but i have one question about your code above : where to implement "myBehavior1", "myBehavior2" ?
hermes February 15th, 2014 I think anywhere, as long as they are defined before you try to create your house (with wade.iso.createObject or by loading a map).
I like having each behvior in a separate file, so I create myBehavior1.js and myBehavior2.js, and load them with wade.loadScript in the load function, so you could load a map with objects that use those behaviors in the init function