How do i blit a texture?

Get help using Construct 2

Post » Sat May 26, 2012 8:28 pm

Sorry if this has been already asked but how do i blit a texture on screen?
ie: i have a 64x64 texture but i want to blit just the {0,0,32,32} rect of it.
Im looking for something like HTML5 canvas.drawImage() functions.

My idea is to make a tile map with it, ive seen some folks using Sprites for each tile but that doesnt seem too good performace wise.


Thanks buds!
B
14
S
6
Posts: 14
Reputation: 1,868

Post » Sat May 26, 2012 8:55 pm

C2 interfaces the javascript for you.
You can either use the sprite plugin to display an image (the sprite object uses a textures set to allow you to display animations or "store" still images in each frame) or the tiled background plugin that will repeat a single texture on all its visible surface/size.

I strongly suggest you to have a look through the beginner's guide and how to make a platform game which are two beginner's tutorials which fully display the method of work in C2, using the most used/useful built-in plugin to make a fully working game.Kyatric2012-05-26 20:56:30
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Sun May 27, 2012 2:22 pm

But that way ill have an sprite instance for each tile meaning that there will be a draw() call for each tile instead of a single one for the entire map.Fersis2012-05-27 15:57:19
B
14
S
6
Posts: 14
Reputation: 1,868

Post » Sun May 27, 2012 4:55 pm

Optimisation: don't waste your time.

You might also want to read how construct2 helps make HTML5 work, c2 vs javascript and c2's architecture for more insights on the engine.

Check the archived blog entries they give tons of details about the depths of C2.



But, if you're concerned with the insides of the engine, you might as well use directly an engine like impact.js in which you have control over the code.Kyatric2012-05-27 16:56:14
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Sun May 27, 2012 5:26 pm

I think he's just looking for an equivalent to "image offset" that tiled BG objects in CC had, which made them ideal for tilesets. Unfortunately C2 can't do that right now. Until then you're gonna have to use sprites.Tokinsom2012-05-27 17:28:05
Image
B
225
S
27
G
13
Posts: 1,774
Reputation: 18,024

Post » Mon May 28, 2012 2:02 pm

@Fersis - Construct 2 exports sprite sheets in the next build. I also could not measure any runtime performance difference at all, so I don't think performance is a good reason to want to do this.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Mon May 28, 2012 5:45 pm

Thanks for all the help folks.
Ashley can we expect this 'next build' this week?
B
14
S
6
Posts: 14
Reputation: 1,868

Post » Mon May 28, 2012 7:15 pm

It went out just now. :)
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544


Return to How do I....?

Who is online

Users browsing this forum: jul, nimos100 and 22 guests