The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Ghost feature

View previous topic View next topic Go down

Solved Ghost feature

Post by Spyro Dragon™ on December 29th 2014, 4:36 am

i can't find that ghost feature...i want to replace the ghost with a different picture so a picture of a dragon will randomly pop up anywhere on the site

Spyro Dragon™
Forumember

Male Posts : 202
Reputation : 2
Language : English

http://SpyroDragon.com

Back to top Go down

Solved Re: Ghost feature

Post by Ange Tuteur on December 29th 2014, 5:07 am

Hi,

You are speaking of this script, correct ?
Code:
$(function() {
  var ghost = document.createElement('IMG'), actif = false;
  ghost.src = 'http://i39.servimg.com/u/f39/18/21/60/73/ghost10.png';
  ghost.setAttribute('style','position:fixed;top:0%;left:0%;z-index:99999;display:none;');
  document.body.appendChild(ghost);
  
  ghost.onclick = function() { ghost.style.display = 'none' };
  window.setInterval('_spook_ghost()', 1000);
  _spook_ghost = function() {
    if (random(5) === 4 && actif === false) {
      actif = true;
      ghost.style.left = random(76) + '%';
      ghost.style.top = random(76) + '%';
      ghost.style.width = '48px';
      ghost.style.opacity = '1';
  ghost.style.display = '';
      _animation_ghost = window.setInterval(function() {
        if (Number(ghost.style.opacity) <= 0) {
          ghost.style.display = 'none';
          window.clearInterval(_animation_ghost);
          return actif = false;
        }
        ghost.style.width = Number(ghost.style.width.replace(/px/,'')) + 10 + 'px';
        ghost.style.opacity = Number(ghost.style.opacity) - 0.01;
      },1);
    }
  };
  function random(val) { return Math.floor(Math.random() * val) };
});

Just change http://i39.servimg.com/u/f39/18/21/60/73/ghost10.png to the image you want. Wink

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2681
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Ghost feature

Post by Spyro Dragon™ on December 29th 2014, 6:54 am

is there a way to make it rarely appeer? it likes pops out every 2 seconds for me.. i put it in topics only...
i want to make it like a scavenger hunt for members..   Like .. Malefor Dragon is lurking around the forum somewhere find him for 1,000 Crystals...so i want him to hardly ever apeer


and when he does show up i want him to show up for a good 5 seconds, not a good 5 millaseconds

Spyro Dragon™
Forumember

Male Posts : 202
Reputation : 2
Language : English

http://SpyroDragon.com

Back to top Go down

Solved Re: Ghost feature

Post by _Twisted_Mods_ on December 29th 2014, 6:59 am

if (random(5) === 4 && actif === false)


random(5) create a random number 1 to 5 if that random number = 4 then ghost appears so change 5 to 15 and it will have a less chace of the random # being 4

_Twisted_Mods_
Helper
Helper

Male Posts : 2020
Reputation : 299
Language : English
Location : Ms

http://liquidcode.forumotion.com

Back to top Go down

Solved Re: Ghost feature

Post by Spyro Dragon™ on December 29th 2014, 7:01 am

so what if i change 5 to 100 ?

Spyro Dragon™
Forumember

Male Posts : 202
Reputation : 2
Language : English

http://SpyroDragon.com

Back to top Go down

Solved Re: Ghost feature

Post by Ange Tuteur on December 29th 2014, 8:08 am

It would be a 1 in 100 chance. Wink

Change the script to this, it'll be easier for you to edit.
Code:
$(function() {
  var chance = 5, speed = 100,
  
  ghost = document.createElement('IMG'), actif = false;
  ghost.src = 'http://i39.servimg.com/u/f39/18/21/60/73/ghost10.png';
  ghost.setAttribute('style','position:fixed;top:0%;left:0%;z-index:99999;display:none;');
  document.body.appendChild(ghost);
  
  ghost.onclick = function() { ghost.style.display = 'none' };
  window.setInterval('_spook_ghost()', 1000);
  _spook_ghost = function() {
    if (random(chance) === 4 && actif === false) {
      actif = true;
      ghost.style.left = random(76) + '%';
      ghost.style.top = random(76) + '%';
      ghost.style.width = '48px';
      ghost.style.opacity = '1';
  ghost.style.display = '';
      _animation_ghost = window.setInterval(function() {
        if (Number(ghost.style.opacity) <= 0) {
          ghost.style.display = 'none';
          window.clearInterval(_animation_ghost);
          return actif = false;
        }
        ghost.style.width = Number(ghost.style.width.replace(/px/,'')) + 10 + 'px';
        ghost.style.opacity = Number(ghost.style.opacity) - 0.01;
      },speed);
    }
  };
  function random(val) { return Math.floor(Math.random() * val) };
});

chance : the chance for the object to appear. higher being rarer and lower being more common.

speed : the speed of the animation when the object shows itself.

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2681
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Ghost feature

Post by Spyro Dragon™ on December 29th 2014, 5:38 pm

what if we want the member to click on the picture when they find it,.sso ittl lead them to the Winner Page and post what colored crystal they want because they found it?

Spyro Dragon™
Forumember

Male Posts : 202
Reputation : 2
Language : English

http://SpyroDragon.com

Back to top Go down

Solved Re: Ghost feature

Post by Ange Tuteur on December 29th 2014, 6:37 pm

Change your script to this :
Code:
$(function() {
  var chance = 5, speed = 100, clickURL = '/h1-',
  
  ghost = document.createElement('IMG'), actif = false;
  ghost.src = 'http://i39.servimg.com/u/f39/18/21/60/73/ghost10.png';
  ghost.setAttribute('style','position:fixed;top:0%;left:0%;z-index:99999;display:none;');
  document.body.appendChild(ghost);
  
  ghost.onclick = function() { ghost.style.display = 'none'; window.location.href = clickURL };
  window.setInterval('_spook_ghost()', 1000);
  _spook_ghost = function() {
    if (random(chance) === 4 && actif === false) {
      actif = true;
      ghost.style.left = random(76) + '%';
      ghost.style.top = random(76) + '%';
      ghost.style.width = '48px';
      ghost.style.opacity = '1';
  ghost.style.display = '';
      _animation_ghost = window.setInterval(function() {
        if (Number(ghost.style.opacity) <= 0) {
          ghost.style.display = 'none';
          window.clearInterval(_animation_ghost);
          return actif = false;
        }
        ghost.style.width = Number(ghost.style.width.replace(/px/,'')) + 10 + 'px';
        ghost.style.opacity = Number(ghost.style.opacity) - 0.01;
      },speed);
    }
  };
  function random(val) { return Math.floor(Math.random() * val) };
});

and modify clickURL to change the redirect page.

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2681
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Ghost feature

Post by Spyro Dragon™ on December 29th 2014, 7:02 pm

So if the page is h5... just replace j1 with h5-  you don't need the entire link?

this is the page link i just recently created for it
http://tlos.openu2.com/h5-malefor

not sure what im suppost to replace wut with wut

Spyro Dragon™
Forumember

Male Posts : 202
Reputation : 2
Language : English

http://SpyroDragon.com

Back to top Go down

Solved Re: Ghost feature

Post by Spyro Dragon™ on December 29th 2014, 7:20 pm

[Solved]

Again agie tuter saved my life

Spyro Dragon™
Forumember

Male Posts : 202
Reputation : 2
Language : English

http://SpyroDragon.com

Back to top Go down

Solved Re: Ghost feature

Post by Ange Tuteur on December 29th 2014, 7:39 pm

You're welcome ^^

And yes, you can use the whole link, or just the pathname. If you use the path, it will check the local server.

Toipic archived

Have a nice day. Smile

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2681
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum