Jump to content

Ma-Shell

Members
  • Posts

    371
  • Joined

  • Last visited

Posts posted by Ma-Shell

  1. Your EndDeath()-Function only gets called once, after the dying-animation is finnished. Assuming, you want the timer to start then, you should replace

    self.removeBodyTimer = self.removeBodyTimer + (Time:GetSpeed()/100)
    

    at that point by

    self.removeBodyTimer = 0
    

     

    Then you have to increase the timer every frame and check, if its value exceeded the given threshold. So, you should move the line, you originally had into UpdatePhysics()-Function.

    You should have a chunk there that says:

    if mode == "dead" then
       self.removeBodyTimer = self.removeBodyTimer + (Time:GetSpeed()/100)
       if (self.removeBodyTimer > self.removeBodyTime) then
           self.entity:Release()
       end
    end
    

  2. Just one silly begginer question, will the Leadwearks gui work with C++ or I have to always compile from CodeBlocks (if I have no codechanges ...)

     

    Whenever you make code-changes for c++, you will have to compile yourself (usually from within code::blocks). The Leadwerks-GUI only offers an option to run the existing executable binary. This works for LUA-Projects always because the LUA-Code is not compiled into the binary and thus the actual binary doesn't change (and there is a default one from the creation of the project).

     

    EDIT:

    So, if you have no codechanges and compiled it once, you can use the button.

  3. Well, the whole point of EmitSound is an easy way to make an entity make some noise. I didn't want it to require any additional management.

     

    Finally found some time and noticed, this also happens, if I create the source myself, without the use of EmitSound but with "Create", "SetSound" and "Play". From your statement I read, EmitSound should just be a convenient way for doing that, which makes sure, I never use a reference to the created source.

     

    The way it is currently there is absolutely no point in getting a reference to a source and use that, as you can never be sure, it does not vanish, before you use it. That fact is taking a lot of possibilities from you for actually no advantage. sad.png

    I can only repeat: That is, what a reference counter is for... Everyone, who needs a reference increases the refcount and when it is done, it releases it, with the last one destroying the object. So, if I need a reference, I explicitly increase the refcount and when I'm done, I release it. Meanwhile the engine increases the refcount by ONE, while it plays the sound and decreases by ONE, when it is done.

    • Upvote 1
  4. Well, the whole point of EmitSound is an easy way to make an entity make some noise. I didn't want it to require any additional management.

     

    But the only time you would have to do any additional management is, if you want to. If you don't want additional management, you just don't get yourself a reference and don't call addRef. wink.png

    That's exactly the purpose of the reference-counter-concept.

     

    If you want more control over your played sounds you can always use the source class.

    That's exactly, what I'm doing here but only I let EmitSound create the source for me and then get myself a pointer to that instance.

    Or does this problem not occur, if I create the source myself?

     

    What about the response you posted here: http://www.leadwerks.com/werkspace/topic/10830-entityemitsound-loop-stop-and-restart/#entry79363

     

    Is this forthcoming?

    There is no point in getting a reference to the created source, if this is the intended design, as you can not be sure, the source is still there, when you want to access it.

  5. It turns out libsteam_api.so isn't copied into the directory when I build the project, which is a bit of an annoyance. But it seems to work when I copy libsteam_api.so to the published project's root directory.

     

    http://www.leadwerks.com/werkspace/topic/10628-shared-lib-libsteam-apiso-loading-question/page__hl__libsteam

  6. From monster.cpp the variables defined in your main.cpp are not visible (why should they be, the file is not included). Try moving the declarations of monsteriter and monsterarray to monster.h.

     

    Edit:

    You will have to put them at the end of the file because otherwise the class monster, which is needed, won't be defined.

    Also be careful to place the definition outside the class.

  7. The reason for this design is returning a source would require the user to release it.

     

    If there was only a pointer returned, that would not be the case.

    IMHO the most logical way to do that would be:

    A pointer to the created source is returned but the refcounter is not increased.

    If the user wants to keep the reference, he can increase its refcounter (src->AddRef()), so it would not be automatically removed, when it finished playing (the refcount would only be decreased by 1 (Currently it isn't even possible to keep the reference any further due to the bug I reported here: http://www.leadwerks.com/werkspace/topic/10804-finished-sound-sources-are-released-every-frame/)). If the user does not add a reference, the source will be removed once it finished and the user might end up with a corrupt reference, but that would be the user's own fault.

    • Upvote 1
  8. Hi,

     

    When a source has finished playing it gets released every frame. This is a problem, if you want to find out, if it has finished playing, as you can't keep the source (even if you add n AddRefs() for the source, the source will be gone n frames after it finished playing).

     

    You can see this by adding a global static variable:

     

    [App.h add as class-member]
    static Source* src;
    
    [App.cpp]
    Source* App::src;
    
    [App.cpp: App::Start()]
    Sound* s = Sound::Load("Sound\\Footsteps\\jump.wav");
    Entity* e = world->entities.front();
    e->EmitSound(s);
    src = SoundDriver::GetCurrent()->sources.front();
    src->AddRef();
    src->AddRef();
    src->AddRef();
    src->AddRef();
    
    [App.cpp: App::Loop()]
    printf("Time: %f, Refs: %i\n", src->GetTime(), src->GetRefCount());
    

     

    Will lead to the following output:

    (...)
    Time: 0.074989, Refs: 5
    (...)
    Time: 0.000000, Refs: 5
    Time: 0.000000, Refs: 4
    Time: 0.000000, Refs: 3
    Time: 0.000000, Refs: 2
    Time: 0.000000, Refs: 1
    

    And an access violation after that, when accessing the GetTime()-method of the source.

     

    The expected behaviour would be, that the RefCount is decreased only once, so if I added Refs before, I have to release it myself.

    I even tried, setting "src->autorelease = false" but that didn't change anything.

    • Upvote 1
  9. As far, as I understand the question, the problem seems to be, OP wants the files to be present to every project he has.

     

    I assume, placing your assets within your LeadwerksInstallDir\Templates\Common folder will make them available in every project you create afterwards, as this folder seems to simply be copied.

  10. I'm not too experienced in LUA but I would guess, you didn't define the key-value "name" for the ground and thus the function returning nil for that case and a comparison between nil and a String isn't possible (as said, I don't know about LUA, but I would guess that's the case). So have you tried checking whether it is nil before doing that? Something like:

    if pickinfo.entity:GetKeyValue("Name") then --This is the same as a comparison with ~= nil
       if pickinfo.entity:GetKeyValue("Name") == "Block" then
        pickinfo.entity:Release()
       end
    end
    

    • Upvote 1
×
×
  • Create New...