Replaceable Image?

For questions about using Classic.

Post » Fri Jan 29, 2010 5:12 am

Hi there!

First I'd like to say that construct is awesome, great work there guys!

I got a little question: Is there a way to make a Sprite ingame replaceable?
Little example:



That there is a piece of my HUD. I would like to make it so, that whenever the player replaces the "HUDImage.jpg" with another "HUDImage.jpg" (wich has another photo) in the main folder, that then the Picture in the HUD changes aswell.

I have searched and found nothing relevant to this, sorry. :(

Any help would be greatly appreciated! :)

Regards,

Mr. Snooley
B
3
S
1
G
2
Posts: 67
Reputation: 959

Post » Fri Jan 29, 2010 7:11 am

Using the "Image Manipulator" plugin, simply run an event such as this...

[code:cfnd60wr]+ System: Start of layout
-> ImageManipulator: Load image AppPath+"newpic.png"
-> ImageManipulator: Copy image to sprite Sprite
[/code:cfnd60wr]

That will replace the sprite with the picture in the specified folder ("AppPath" means look in the .exe or .cap's folder).

Hope that helps.
B
3
S
1
G
3
Posts: 46
Reputation: 1,117

Post » Fri Jan 29, 2010 7:39 am

The awesomeness!

Thank you very much kind sir!

Regards,

Mr. Snooley
B
3
S
1
G
2
Posts: 67
Reputation: 959

Post » Fri Jan 29, 2010 7:50 am

No problem mang.
B
3
S
1
G
3
Posts: 46
Reputation: 1,117

Post » Fri Jan 29, 2010 10:17 am

You can also do it without Image Manipulator - Sprite has an action to load an image from a file as well.
Scirra Founder
B
399
S
236
G
89
Posts: 24,546
Reputation: 195,436

Post » Fri Jan 29, 2010 1:27 pm

Huh. Didn't know that.
B
3
S
1
G
3
Posts: 46
Reputation: 1,117

Post » Fri Jan 29, 2010 3:45 pm

I think it's faster the way Ashley mentioned as well. One less step.
Moderator
B
95
S
34
G
33
Posts: 3,007
Reputation: 27,876

Post » Fri Jan 29, 2010 4:48 pm

Or have a second sprite and turn one off and the other on?

Kind of like frame buffering. Turn on bottom sprite then tun off the top. Switch Z order if you want t to swap back
B
29
S
8
G
8
Posts: 531
Reputation: 7,181

Post » Fri Jan 29, 2010 9:38 pm

[quote="Guyon":1vbkv7m3]Or have a second sprite and turn one off and the other on?[/quote:1vbkv7m3]
that wouldn't load from the file
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests