Comments (4)
Tiledef is a 2d array so you can use:
var tiledef = [ [1,2,3], [4,5,6], [7,8,9] ]; //use 0 to display no tile.
The integer is an index into an animation.
Most people will want to set up large set of non-animating tiles.
This is the bit that took me a while to get when using a multi animation to select tiles from a sprite sheet you need to set it up in the following way (single frame, multiple animations, once sprite sheet, no looping)
Using a horizontal strip of 50 tiles each 32X32 pixels
var multiAnimation = new $.gameQuery.Animation
({
imageURL: "/graphic/temp/Ground1.png",
type: $.gameQuery.ANIMATION_VERTICAL | $.gameQuery.ANIMATION_MULTI | $.gameQuery.ANIMATION_ONCE,
numberOfFrame: 1,
delta: 32,
distance: 32,
rate: 30
});
var tiledef = [[1,2,3,4,5,6,7,8,9,10],[11,12,13,14,15,16,17,18,19,20]];
$.playground().addTilemap
(
"myTilemap",
tiledef,
multiAnimation,
{width: 32, height: 32, sizex: 10, sizey: 10, posx: 0}
);
$.playground().startGame();
from gamequery.
After I posted this I just used PHP to just make a nested loop to accomplish basically the same thing, but it was making my game slow, so I tried just making one large bmp for the background and it's much faster. I haven't compared actual frame rates though. Have you tried comparing them?
from gamequery.
Haven't done any benchmarking but it would make perfect sense that moving around lots of small divs would slow down the system a lot. I guess these days a really large jpeg isn't going to do much harm. Perhaps once the optimisation for off playground tiles is in it will be worth benchmarking though. There's clearly some design advantages for some types of games by using tiles.
from gamequery.
One advantage of tilemap is that you can use collision detection to find out what kind of tile a sprite is touching. That's very convenient for a platformer for example. When the tiles are animated on the visible one get updated this make the use of quite large animated tilemap quite fast, for very large map there should be a solution comming to gQ 0.7.
from gamequery.
Related Issues (17)
- namespace jquery.gamequery.ext.js HOT 1
- rotate not working in 0.6.0 anymore HOT 2
- Bug while setting dynamic TileMap out of the playground HOT 2
- Contribution to the gamequery HOT 1
- tilemapEditor: background image not displaying in new animations HOT 1
- fadeTo not work ? HOT 3
- some sprites are not cleared HOT 1
- why is "undefined"??? HOT 1
- Callback get executed more than once for ONCE animations
- scenegraph incorrectly positioned HOT 1
- The API Browser hover menu on the API documentation hides content on small screens HOT 4
- Player or Enemies without spriteAnimation, how to change imageURL HOT 4
- Issue with recognision of gamequerry functions HOT 8
- Latest Commit made setAnimation() fails. HOT 5
- Problem getting started HOT 2
- mouse functionality not working HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gamequery.