Sie sind nicht angemeldet.

21

Donnerstag, 9. März 2023, 08:20

htsp01 - htsp03 belong to the same scene.
If you make hotspots in another scene, then
1. they must have other names and, accordingly, other variables in onloaded="if(tag_name...
2. In the counter, you need to specify the number of all clickable hotspots
if(global.hs_tag_count == №, ...

The counter layer is global and counts all clicked hotspots in the entire tour, not just in one scene

Again, how accurate the task originally set is how accurate the executing code will be *squint*

22

Donnerstag, 9. März 2023, 09:50

Got it. I'll enjoy going over the code and see what can be changed. I'm only making a children's 'look and find' tour for a few bored school kids.


Thanks again and PayPal gift sent *thumbsup*

23

Donnerstag, 9. März 2023, 09:55

Got it. I'll enjoy going over the code and see what can be changed. I'm only making a children's 'look and find' tour for a few bored school kids.


Thanks again and PayPal gift sent *thumbsup*

Thanks, andrew22222 *thumbup*
If the kids suddenly crack the code and outwit you - write, we'll come up with another one *thumbsup*

24

Donnerstag, 9. März 2023, 10:47

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<krpano logkey="true">

<preview type="grid" />

<layer name="hscount" type="text" font="arial"
	css="text-align:left;font-weight:bold;color:#0114DD;font-size:25px;padding-left:10px;"
	width="120" height="30" bgcolor="0xffffff" align="topleft" bgalpha="0.8"
	keep="true" x="15" y="15" onloaded="hs_tag_click();" onclick="hs_tag_click();" />

<style name="spot" type="text" width="50" height="50" bgcolor="0x888888" bgalpha="1" tag="game" />

<hotspot name="spot1" style="spot" ath="-20" atv="0" onclick="hs_tag_click(get(name));" />
<hotspot name="spot2" style="spot" ath="0" atv="0" onclick="hs_tag_click(get(name));" />
<hotspot name="spot3" style="spot" ath="20" atv="0" onclick="hs_tag_click(get(name));" />
<hotspot name="spot4" style="spot" ath="0" atv="20" onclick="hs_tag_click(get(name));" />
<hotspot name="spot5" style="spot" ath="0" atv="-20" onclick="hs_tag_click(get(name));" />

<action name="hs_tag_click" scope="local" args="name">
	if(name === null, // reset counter and list!
		set(global.hs_list, '');
		set(layer[hscount].html, 0);
	, hotspot[get(name)].tag === 'game', // else if tagged hotspot
		calc(local.id, xml.scene + '/' + name); // create an id for the clicked hs
		indexoftxt(local.index, get(hs_list), get(id)); // search in global
		if(index LT 0, // not found, then add the id
			if(hs_list, txtadd(hs_list, ',')); // add separator if count > 0
			txtadd(hs_list, get(id)); // add id
		);
		txtsplit(get(hs_list), ',', local.arr); // split to get actual count
		trace('id=',id,' list=',hs_list,' count=',arr.count);
		copy(layer[hscount].html, arr.count); // set count
		if(arr.count === 5,
			txtadd(layer[hscount].html, ' whee!')
		);
	);
</action>

</krpano>

my solution *squint*
each hotspot is only counted once, works across scenes, clicking the counter resets to 0,
see console output

notes:
the scene name is added to the id to allow same names in different scenes
as there is no scene in this example the id is "null/spotN", but it will work if you use scenes.

Dieser Beitrag wurde bereits 6 mal editiert, zuletzt von »indexofrefraction« (9. März 2023, 11:05)


25

Donnerstag, 9. März 2023, 11:36

my solution
each hotspot is only counted once, works across scenes, clicking the counter resets to 0,
see console output

*thumbsup* I like that there is a list with the name of the scenes and the names of the hotspots, you can use it if necessary.
There is only one point left - you need to manually specify the number of clicked hotspots in order to display 'whee!'

26

Donnerstag, 9. März 2023, 22:59

Thanks for the example with code indexofrefraction

Ähnliche Themen