Tiled background image offset Help?(Solved)

For questions about using Classic.

Post » Sun Mar 27, 2011 2:36 pm

I need to find a way to copy and paste images from tiled background into a sprite.
(actually several instances of the same sprite)

Iv'e got as far as creating the the image offset x,y events, but i cant work out the rest.
Ive searched the forums, downloaded loads of caps but still can't get it to work. :?

Here's my cap-

[url:20uu3dq9]http://dl.dropbox.com/u/22173473/Tile%20copy%20to%20sprite.cap[/url:20uu3dq9]

Iv'e added comments inside the cap that explain things a bit clearer.
B
19
S
6
G
7
Posts: 1,206
Reputation: 7,300

Post » Sun Mar 27, 2011 3:26 pm

Quick addition to above -

I changed the events in the 'main events group' to-


+ MouseKeyboard: Mouse is over photos
+ System: Always (every tick)
-> TiledBackground1: Set image offset to photos.Value('valx'), photos.Value('valy')

+ MouseKeyboard: On Left Clicked on photos
+ System: Repeat 2 times
-> Canvas: Paste TiledBackground1 into canvas
-> ImageManipulator: Copy image from sprite Canvas
-> ImageManipulator: Copy image to sprite photos

After doing this, i didnt have to double click on the 'photos' to paste in the image.

This doesn't solve the problem (it still pastes to all the sprites) but it stops the 'paste' lag that seems to happen. :?

Thanks
B
19
S
6
G
7
Posts: 1,206
Reputation: 7,300

Post » Sun Mar 27, 2011 6:48 pm

[quote:34a2fx0d]This doesn't solve the problem (it still pastes to all the sprites)[/quote:34a2fx0d]
The Sprites share the same texture, so if you change the texture on one all of them change. One way you can do it is give the Sprite 16 animation frames and assign each instance a different frame. Another method is use TiledBackground objects instead of sprites. They can each have different textures but only with the load texture action, so you'll have to save the image from the canvas to a file first before loading.
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755

Post » Sun Mar 27, 2011 8:55 pm

[quote="R0J0hound":2g1q9ttl][quote:2g1q9ttl]This doesn't solve the problem (it still pastes to all the sprites)[/quote:2g1q9ttl]
The Sprites share the same texture, so if you change the texture on one all of them change. One way you can do it is give the Sprite 16 animation frames and assign each instance a different frame. Another method is use TiledBackground objects instead of sprites. They can each have different textures but only with the load texture action, so you'll have to save the image from the canvas to a file first before loading.[/quote:2g1q9ttl]


In the actual game i need the solution for, i am using a sprite with 9 animations.



These events start when the level loads-

+ PickLevel: On fade out finished
-> System: Create object puzzlecubes on layer 1 at (488, 272)
-> puzzlecubes: Set 'numb' to 1
-> System: Create object puzzlecubes on layer 1 at (240, 272)
-> puzzlecubes: Set 'numb' to 2
-> System: Create object puzzlecubes on layer 1 at (616, 408)
-> puzzlecubes: Set 'numb' to 3
-> System: Create object puzzlecubes on layer 1 at (752, 152)
-> puzzlecubes: Set 'numb' to 4
-> System: Create object puzzlecubes on layer 1 at (648, 152)
-> puzzlecubes: Set 'numb' to 5
-> System: Create object puzzlecubes on layer 1 at (328, 416)
-> puzzlecubes: Set 'numb' to 6
-> System: Create object puzzlecubes on layer 1 at (304, 152)
-> puzzlecubes: Set 'numb' to 7
-> System: Create object puzzlecubes on layer 1 at (744, 408)
-> puzzlecubes: Set 'numb' to 8
-> System: Create object puzzlecubes on layer 1 at (400, 152)
-> puzzlecubes: Set 'numb' to 9
-> System: Create object lydia on layer 1 at (60, 446)
-> lydia: Activate Platform movement

Everything works fine as it is, but i was looking for a way to let the player choose a picture for the puzzle or start the level with a different 'picture' every time.

If i was to use tiledbackground objects could i still make them pushable blocks (platform behaviour) ?
B
19
S
6
G
7
Posts: 1,206
Reputation: 7,300

Post » Mon Mar 28, 2011 1:09 pm

I'd use sprite, tiles are usualy used only as static images. Just click on lydia, than animator tab and in the top window (there is probably the Default animation with 9 frames) right click to add another animation - name it "Image 2" (or whatever) and add 9 frames of the new picture. After, you can add "Image 3" animation for the next picture and so on. Than you can call correct frame with "Set animation" and "Set animation frame" actions.
ImageImage
B
25
S
6
G
8
Posts: 773
Reputation: 6,643

Post » Mon Mar 28, 2011 3:31 pm

[quote="Noga":1ta7532w]I'd use sprite, tiles are usualy used only as static images. Just click on lydia, than animator tab and in the top window (there is probably the Default animation with 9 frames) right click to add another animation - name it "Image 2" (or whatever) and add 9 frames of the new picture. After, you can add "Image 3" animation for the next picture and so on. Than you can call correct frame with "Set animation" and "Set animation frame" actions.[/quote:1ta7532w]

Great idea! thanks for your help. :D
B
19
S
6
G
7
Posts: 1,206
Reputation: 7,300

Post » Mon Mar 28, 2011 7:52 pm

I didnt want to start a new thread, so i will ask the question here? (it is related)

Iv'e got the offset image thingy sorted, but now i'm struggling with the next bit -

How do i create an event to detect when each puzzleblock is in its correct position within the puzzle.....similar to a jigsaw puzzle.

I gave each block, 2 private variable's ( 'xpos' and ypos') and set the values of each to the required resting position....ie Square 9 should be at 552, 608 to be correctly placed.

I tried the following-

+ System: Always (every tick)
+ System: For each puzzlecubes
+ System: puzzlecubes.Value('x') Equal to puzzlecubes.X
+ System: puzzlecubes.Value('y') Equal to puzzlecubes.y
-> puzzlecubes: Destroy

but it didnt work?

Can anybody help me with this?
B
19
S
6
G
7
Posts: 1,206
Reputation: 7,300

Post » Mon Mar 28, 2011 11:49 pm

[quote="chrisbrobs":1hyoifwb]I tried the following-

+ System: Always (every tick)
+ System: For each puzzlecubes
+ System: puzzlecubes.Value('x') Equal to puzzlecubes.X
+ System: puzzlecubes.Value('y') Equal to puzzlecubes.y
-> puzzlecubes: Destroy

but it didnt work?

Can anybody help me with this?[/quote:1hyoifwb]

Sounds like it should work. The always event at the beginning is completely unnecessary btw.

Are you sure the puzzlecube objects reach the correct positions? I mean maybe they end up being at 552.3467 instead of simply 552? Maybe try it like this:

+ System: puzzlecubes.Value('x') Equal to round(puzzlecubes.X)
+ System: puzzlecubes.Value('y') Equal to round(puzzlecubes.y)

Other than that, show a cap! 8)
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Tue Mar 29, 2011 2:48 pm

[quote="PixelRebirth":kka2cpr7][quote="chrisbrobs":kka2cpr7]
Are you sure the puzzlecube objects reach the correct positions? I mean maybe they end up being at 552.3467 instead of simply 552? [/quote:kka2cpr7][/quote:kka2cpr7]
...and, I think it is difficult for a player to pixel precise position those blocks, you could add a range. If a block is between i.e. 550-554, it'd snap to the right position.
ImageImage
B
25
S
6
G
8
Posts: 773
Reputation: 6,643

Post » Tue Mar 29, 2011 7:11 pm

"PixelRebirth
+ System: puzzlecubes.Value('x') Equal to round(puzzlecubes.X)
+ System: puzzlecubes.Value('y') Equal to round(puzzlecubes.y)"

"Noga
...and, I think it is difficult for a player to pixel precise position those blocks, you could add a range. If a block is between i.e. 550-554, it'd snap to the right position"

What do these expressions actually do? :oops:
B
19
S
6
G
7
Posts: 1,206
Reputation: 7,300

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests