Changing background image during runtime ?

This forum is meant for requesting technical support or reporting bugs.

Moderators: time-killer-games, Vengeance66, Candle, reneuend, GM-Support

Changing background image during runtime ?

Postby Lucifell » Thu Mar 12, 2009 4:47 pm

Hello again everyone.

Today I'll be bothering you with background questions !

So, is there a way to change permanently the background image of a frame via VBScript (or something even more simple) ?

I'm thinking of having night and day changes of my backgrounds so that would be useful.
Lucifell
Member
 
Posts: 33
Joined: Mon Mar 02, 2009 2:09 pm

Postby reneuend » Thu Mar 12, 2009 5:48 pm

interesting question. I can think of 2 possible methods to change the lighting:

1. Create a duplicate frame and change the background based on the time of day.

2. Create a full screen hotspot and use a gradient overlay to dim the scene. Not sure how well that would work. Also, there might be a plugin that would create this affect, but I'm not sure.
---


Image
Image
User avatar
reneuend
Administrator
 
Posts: 2718
Joined: Sat Nov 22, 2008 8:37 pm
Location: Midwest Cornfield, USA

Postby Lucifell » Thu Mar 12, 2009 6:02 pm

Thanks for quick reply.

I do not have trouble with the image itself, since I already have two versions of my background.

I just can't create that huge hotspot, since it would be a pain to rethink all the numbers, and I have a couple hotspots like that already.

I can duplicate my frame and change its background ... but isn't there some simple way to acces the database and simply change the image's name ?
Lucifell
Member
 
Posts: 33
Joined: Mon Mar 02, 2009 2:09 pm

Postby Lyberodoggy » Thu Mar 12, 2009 10:07 pm

Lucifell wrote:but isn't there some simple way to acces the database and simply change the image's name ?

No :P
You could do it with an external program, which you would first need to create, but I definitely don't recommend that.

I think there's a property storing the background picture. By changing it and reloading the frame you should be able to do that. The problem is that I don't remember the object and property
User avatar
Lyberodoggy
Administrator
 
Posts: 2519
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby Lucifell » Thu Mar 12, 2009 11:17 pm

All right ! At least I tried ^ ^

I just should have thought more about things before rushing ...
The huge hotspot is definitely the best option.

As for me, I'll have to create other frames : /

Thank you for your help !
Lucifell
Member
 
Posts: 33
Joined: Mon Mar 02, 2009 2:09 pm

Postby ShadowHunter » Fri Mar 13, 2009 8:33 am

Hi,

The object is "BackgroundObject"

You can use all properties:

BackgroundObject.Picture
BackgroundObject.Height
BackgroundObject.Width
...
...

What you need is:

Set BackgroundObject.Picture = INSERT FULL PATH TO YOUR BACKGROUND IMAGE (best to put it in the external folder and use the GetPath(2) & "\MyPicture.jpg")

Don't forget on the end to:

BackgroundObject.Refresh

Good luck,

ShAdOwHuNtEr
User avatar
ShadowHunter
Forum Admin and Games Page admin
 
Posts: 1304
Joined: Fri Jun 06, 2003 10:37 pm
Location: Belgium

Postby Lucifell » Fri Mar 13, 2009 9:46 am

Holy cow, now that's just what I needed.

I am having issues with BackgroundObject.Picture though.
Here's the error I get with my code :

Set BackgroundObject.Picture = ""+GetPath (4)+"BG-Dodo.jpg"
AM error : Required object : 'BackgroundObject.Picture'

I tried without "set", and had the folowing error :
'Incompatible type : 'BackgroundObject.Picture'

What am I doing wrong ?
Lucifell
Member
 
Posts: 33
Joined: Mon Mar 02, 2009 2:09 pm

Postby ShadowHunter » Fri Mar 13, 2009 9:57 am

Hi,

I mixed up some functions :oops:

The code below will do the trick for you:

BackgroundObject.Picture = LoadPicture(GetPath(2) & "/mypicture.jpg")

Good luck,

With best regards,

ShAdOwHuNtEr

Lucifell wrote:Holy cow, now that's just what I needed.

I am having issues with BackgroundObject.Picture though.
Here's the error I get with my code :

Set BackgroundObject.Picture = ""+GetPath (4)+"BG-Dodo.jpg"
AM error : Required object : 'BackgroundObject.Picture'

I tried without "set", and had the folowing error :
'Incompatible type : 'BackgroundObject.Picture'

What am I doing wrong ?
User avatar
ShadowHunter
Forum Admin and Games Page admin
 
Posts: 1304
Joined: Fri Jun 06, 2003 10:37 pm
Location: Belgium

Postby Lucifell » Fri Mar 13, 2009 10:01 am

Ok, thank you again, it worked perfectly this time.
Lucifell
Member
 
Posts: 33
Joined: Mon Mar 02, 2009 2:09 pm

Postby mercedes » Fri Mar 13, 2009 10:17 am

This is really handy Shadow :)
..someone else asked the same question a while back..i think it was Dalton..At least now we have an answer to it.. Thanks..!

Adieux~!
User avatar
mercedes
VIP
 
Posts: 2460
Joined: Sun Mar 09, 2008 10:43 pm
Location: Canada..~

Postby ShadowHunter » Fri Mar 13, 2009 10:41 am

Thanks Mercedes, I must have missed that post :wink:
User avatar
ShadowHunter
Forum Admin and Games Page admin
 
Posts: 1304
Joined: Fri Jun 06, 2003 10:37 pm
Location: Belgium

Postby Lucifell » Thu Mar 19, 2009 10:27 am

Hello again, friends !

After a little bit of testing, I found myself with a problem : the "LoadPicture" function works wonders when I launch my game from the editor but cannot seem to be read when I launch from an exe installed game.
Lucifell
Member
 
Posts: 33
Joined: Mon Mar 02, 2009 2:09 pm

Postby mercedes » Thu Mar 19, 2009 10:34 am

To rule out some questions for Shadow..:)

Are you getting any errors..?
User avatar
mercedes
VIP
 
Posts: 2460
Joined: Sun Mar 09, 2008 10:43 pm
Location: Canada..~

Postby Lucifell » Thu Mar 19, 2009 10:41 am

Here's the error I get :
"File or class name could not be found during Automation operation : 'LoadPicture' "
Lucifell
Member
 
Posts: 33
Joined: Mon Mar 02, 2009 2:09 pm

Postby ShadowHunter » Thu Mar 19, 2009 10:44 am

Hi,

Be sure the picture you load is in the external folder, else the file extension gets encrypte and can not be found during exe-runtime...

Be shure you refresh the backgroundobject after loading a new picture...

Other properties you can use on the backgroundobject are:

Align
Appearance
AutoRedraw
AutoSize
BackColor
BorderStyle
ClipControls
Container
CurrentX
CurrentY
DataChanged
DataField
DataFormat
DataMember
DataSource
DragIcon
DragMode
DrawMode
DrawStyle
DrawWidth
FillColor
FillStyle
Font
FontBold
FontItalic
FontName
FontSize
FontStrikethrough
FontUnderline
ForeColor
HasDC
HDC
Height
HelpContextID
HWnd
Image
Index
Left
LinkItem
LinkMode
LinkTimeOut
LinkTopic
MouseIcon
MousePointer
OLEDragMode
OLEDropMode
Parent
Picture
ScaleHeight
ScaleLeft
ScaleMode
ScaleTop
ScaleWidth
ToolTipText
Top
WhatsThisHelpID
Width

Good luck,

With best regards,

ShAdOwHuNtEr
User avatar
ShadowHunter
Forum Admin and Games Page admin
 
Posts: 1304
Joined: Fri Jun 06, 2003 10:37 pm
Location: Belgium

Postby mercedes » Thu Mar 19, 2009 10:46 am

Did you try putting 'Action' in front of it..? Not sure if that would work ..but i'd try it..

Edit**
I see Shadow answered you...:)

Peace
Last edited by mercedes on Thu Mar 19, 2009 10:47 am, edited 1 time in total.
User avatar
mercedes
VIP
 
Posts: 2460
Joined: Sun Mar 09, 2008 10:43 pm
Location: Canada..~

Postby ShadowHunter » Thu Mar 19, 2009 10:47 am

No need to put action in front of it... I'm sure the picture file is not in the external folder :wink:
User avatar
ShadowHunter
Forum Admin and Games Page admin
 
Posts: 1304
Joined: Fri Jun 06, 2003 10:37 pm
Location: Belgium

Postby mercedes » Thu Mar 19, 2009 10:50 am

Yes..usually when its an automation error..its usually the case..:)--Was my next best guess!..lol..
User avatar
mercedes
VIP
 
Posts: 2460
Joined: Sun Mar 09, 2008 10:43 pm
Location: Canada..~

Postby Lucifell » Thu Mar 19, 2009 10:52 am

It wasn't. I'm testing things as I write (yeah, I'm quite the multitask man :D)
Lucifell
Member
 
Posts: 33
Joined: Mon Mar 02, 2009 2:09 pm

Postby mercedes » Thu Mar 19, 2009 11:04 am

It wasn't in the External folder....---Oh good well at least now that's fixed for you..Really handy to have that feature..:)

To go from night to day in a game..is cool..and saves alot of work on multiple frames..Gotta love that..!~

Adieux~
User avatar
mercedes
VIP
 
Posts: 2460
Joined: Sun Mar 09, 2008 10:43 pm
Location: Canada..~

Postby Lucifell » Thu Mar 19, 2009 11:09 am

Holy HuNtEr, it worked.
Lucifell
Member
 
Posts: 33
Joined: Mon Mar 02, 2009 2:09 pm

Postby juhuwoorps » Thu Mar 19, 2009 11:10 am

So you can make a game just with one frame :D
juhuwoorps
Code Master
 
Posts: 622
Joined: Tue Jul 08, 2008 3:13 pm

Postby Lucifell » Thu Mar 19, 2009 11:26 am

That would be nasty
Lucifell
Member
 
Posts: 33
Joined: Mon Mar 02, 2009 2:09 pm

Postby Googie_K » Sat Feb 20, 2010 2:24 pm

BackgroundObject seems to refer only to the frame that is currently being displayed.
How would I choose the frame that needs to be changed?

For example, when I click a hotspot on Frame 8, the picture on Frame 2 changes.

Is that possible?

Thanks,
Googie_K

P.S.
What does GetPath(2) do?
User avatar
Googie_K
New Member
 
Posts: 1
Joined: Sat Feb 20, 2010 2:12 pm

Postby Lyberodoggy » Sat Feb 20, 2010 2:54 pm

I would work with hotspots instead of backgrounds. Create a hotspot, resize it to fit the project size and then just change its picture with some code depending on some variable you have set on frame 8


GetPath returns the path that corresponds to the "External" sub-folder of the project folder.

To return the path of a different folder, call the GetPath function with one of the following arguments:

0 : location of the project folder
1: location of the "Root" sub-folder (in the compiled version of the project, it corresponds to the project folder)
2: location of the "External" sub-folder (default)
3: location of the "Config" sub-folder
4: location of the "Areas" sub-folder
5: location of the "Frames" sub-folder
6: location of the "FramesData" sub-folder
7: location of the "Icons" sub-folder

For example, GetPath(7) will return the path of the "Icons" sub-folder that is inside the project folder.
User avatar
Lyberodoggy
Administrator
 
Posts: 2519
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens

Postby Vengeance66 » Fri Aug 12, 2011 6:41 pm

Is this possible just to change the frame image, and the hotspots stays the same?
Stay a while and listen...

Rainbow Enterainment - http://rainbowenter.com/
User avatar
Vengeance66
Administrator
 
Posts: 630
Joined: Wed Oct 13, 2010 2:17 pm
Location: Macedonia

Postby juhuwoorps » Fri Aug 12, 2011 6:58 pm

If you change the background images of the frame, the hotspots stay as before.
juhuwoorps
Code Master
 
Posts: 622
Joined: Tue Jul 08, 2008 3:13 pm

Postby Vengeance66 » Sat Aug 13, 2011 3:38 pm

Code: Select all
BackgroundObject.Picture = LoadPicture(GetPath(2) & "/mypicture.jpg")


I don't understand which path I need to put in the code. The path from the Resources or the path from my external folder that I keep my files? :?
Stay a while and listen...

Rainbow Enterainment - http://rainbowenter.com/
User avatar
Vengeance66
Administrator
 
Posts: 630
Joined: Wed Oct 13, 2010 2:17 pm
Location: Macedonia

Postby juhuwoorps » Sat Aug 13, 2011 3:45 pm

It depends where you have saved your file in your AM project:

0 : location of the project folder
1: location of the "Root" sub-folder (in the compiled version of the project, it corresponds to the project folder)
2: location of the "External" sub-folder (default)
3: location of the "Config" sub-folder
4: location of the "Areas" sub-folder
5: location of the "Frames" sub-folder
6: location of the "FramesData" sub-folder
7: location of the "Icons" sub-folder


If you have saved your image in the external folder you need GetPath(2)

If you have saved it in the Frames folder you need GetPath(5)

I don't know if it works if you're using the path to the source like C:\images\image.jpg.
juhuwoorps
Code Master
 
Posts: 622
Joined: Tue Jul 08, 2008 3:13 pm

Postby Vengeance66 » Sat Aug 13, 2011 4:06 pm

juhuwoorps wrote:It depends where you have saved your file in your AM project:

0 : location of the project folder
1: location of the "Root" sub-folder (in the compiled version of the project, it corresponds to the project folder)
2: location of the "External" sub-folder (default)
3: location of the "Config" sub-folder
4: location of the "Areas" sub-folder
5: location of the "Frames" sub-folder
6: location of the "FramesData" sub-folder
7: location of the "Icons" sub-folder


If you have saved your image in the external folder you need GetPath(2)

If you have saved it in the Frames folder you need GetPath(5)

I don't know if it works if you're using the path to the source like C:\images\image.jpg.


Thanks juhu! I'm trying to solve this now...
Stay a while and listen...

Rainbow Enterainment - http://rainbowenter.com/
User avatar
Vengeance66
Administrator
 
Posts: 630
Joined: Wed Oct 13, 2010 2:17 pm
Location: Macedonia

Next

Return to Adventure Maker Technical Support and Bug Reports

Who is online

Users browsing this forum: No registered users and 1 guest