Rable's Forum Posts

  • Hi everyone,

    I'm currently working on a project that uses only one layout (except for loading and title screen). I was just wondering if this was possible or if I need to make transitions via another layout with maps or such things, to keep everything running smoothly.

    To give you an idea the project is around 6000 events and will have about 100 levels, so it's not a small game. There are sort of world maps (not animated) between each level that I create on a foreground layer, then delete them when going back to the game (which is still running in the background).

    My question is to know whether or not this has technical downside. Will the game start to slow down after a while because I use always the same layout?

    Thanks !

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks, I'll try that !

  • Hi Everyone,

    I've run into a new problem that I didn't manage to resolve by myself. Here is the simplified code :

    When spriteButton is touched (trigger once), set Object.instanceVariable to true (can only be triggered once by half second, with a cooldown mechanism)

    "Object" spawn object "icon"

    wait 4 seconds

    "icon" start flashing for 1 second

    wait 1 second

    delete icon

    set object.instancevariable to false

    This works perfectly as long as I never repress the button while the script is running, but I would like the player to play the script multiple times during the initial 5 seconds.

    As it is, when I re-run the script while it is still active, a second icon will be created and the instancevariable will be set to false 5 seconds after the first launch, because the first script is still running and will set the variable to false

    So my question resumes to : How can I cancel a wait time (or a whole event) in order to start a new one with the wait time back to 0?

    I tried putting the wait part inside a group and deactivationg the group then reactivating it, but it doesn't seems to work.

    Thanks for your help !

  • Thanks a lot for your time, inquiesco. Indeed your solution works fine, but sadly it is not usable in my complete code. The reason is that I simplified the code to have only one instance of the enemy object, while in the complete code I need 2, or 3 instances.

    So, starting from your version, I duplicated the actions in order to create 2 instances in the same "every thick" event, like you suggested. It works just fine. The problem is that when I need to put the life bar's width to be the same as the health, if I put the actions in the same "every thick" event, it applies logically only to the last instance, not all. So I need to create another "every thick" event at the root, and when I do that, it doesn't work at all... :-/

    Here is the capx demonstrating the problem :

    dropbox.com/s/6s9xegcic5nyl1u/project88_debug2.capx?dl=0

    Any further idea of how I could make it work?

    I also tried to put the "set width" action in a "pick all" event at different places in the hierarchy (root level), none of it works...

    ----

    EDIT :

    Ok my problem is solved. I moved the "every thick" (or pick all, it's the same) event, containing the set width actions, at the same root level of the "level=25" event. This implies that I can't change it based on the level, but I don't need to do that. So It's solved ! Thanks a lot inquiesco for your precious help.

    Still, some things are behaving weirdly and I'll be happy if someone can tell me how I could have done that if I needed to apply this effect on only some given levels, not all...

  • Here is the link to the simplified capx :(seems like the forum removed the link... Maybe you can help based on the description below?)

    ok, workaround : to download the capx, just enter

    dropbox.com/s/4ibtr46yhpy8avd/project88_debug.capx?dl=0

    with something at the beginning of the adress

    Curiously, the symptoms are different now, but there is still a bug with the "set width to enemy.health" action. The health bar just keep its default size and isn't resized.

    I found out another cusious thing : I defined a global variable named "level", and added an event :

    if "level" = 25 (default value) play the events.

    If I remove this condition of "if level=25", everything works fine ! The problem is that I need it, as I would like to create different enemies in regards to the level...

    ---

    Edit :

    As it seems like I can't post links, here is the detailed events and actions

    enemy has instance variable Health put to 100

    lifebar has width of 50

    global variable "level" = 25

    Event sheet 1 :

    start of layout :

    delete enemy

    delete lifebar

    include eventsheet2

    ---

    eventsheet 2 :

    if level=25 :

    create enemy

    create lifebar

    put lifebar width to enemy.health

    ---

    the result :

    it creates enemy, it creates the lifebar, but lifebar's width is still 50, not 100.

    If I remove the condition "if level = 25", everything is fine and lifebar's width becomes 100...

    (removing the "destroy" actions at the start doesn't help)

  • Can't do it right now, but I will do this ASAP.

    Thanks !

  • The health variable is an instance variable so its base value is not defined in the code but on the object. The variable call by the healthBar object is done after destroying the enemy, as the destruction occurs at the start of layout.

    The include sheet is in an "every tick" + "trigger once while true" event that is placed just after the "at the start of layout" event, in order to create the objects I need immediately after destroying all the objects that I don't need.

    Thanks !

  • Hi everyone,

    I have a strange bug occuring in one of my project. I simplify everything but it stands like this :

    ---

    object type Enemy has Health instance variable defined to 100 (default value of the object type)

    start of layout:

    • destroy Enemy

    (inside an included event sheet)

    create Enemy

    create healthBar

    set healthBar width to enemy.health

    ---

    At that moment the Enemy health value is 0 (checked in debug mode)... Which shouldn't be the case, as I never told the code to put it to 0.

    I created a new project, entered the simplified code, and it works fine ! Enemy.health is 100, and it sets healthBar width to 100. Just in my bigger project, it doesn't work, and I can't understand what's happening.

    I found two workarounds :

    disabling the event "destroy Enemy" at the start of layout makes the health be 100 at the moment the healthBar needs to read its value.

    adding "set enemy health to 100" before setting the healthbar width also works.

    I already looked a couple hour for the solution, but I can't find any spot in my code where I ask to put the enemy's health to 0. Moreover, by not destroying the object at the start it works just fine.

    Any idea of what's happening?

    Thanks !

  • This is great news ! Thanks a lot !

  • Thank you codah, and sorry for the misunderstanding.

    My original problem was this one : (not allowed to post URLS but check post "Question about using a single event sheet on different level" - last replied wed 27th august 2014 at 6:26 pm)

    What I meant with the number of instances is the following : if I have instances 0, 1 and 2 on layout 1, and I'm currently on layout 2, where there is 3 additional instances of the same object type, will they be numbered 0, 1 and 2 - or - 3, 4 and 5 (IID)

    And so instances awaing for me on layout 3 will be IID 6, 7 and 8?

  • My first goal was to provide a clear way of dealing with the post's original problem : using IID in a more "durable" way.

    I don't have access to C2 right now and would like feedback on the solution I'm providing : is something wrong with the logic, or is there a better way to do it?

    Then I wanted to learn about things that I haven't been able to find informations on until now :

    • Do loops in the "at the start of the layout" condition really loop, or just play once?
    • Is IID dependent on the # of instances on layout or on the project? No informations on that point in the manual...

    The actual thing I can't do : if the IID are #4, 5and 6, how can I "tag" them with a number instance variable 0, 1 and 2? i.e. is there a way to select the instances with the lowest IID on the layout, then select the next one, or the one with the highest IID, in order to be able to tag them correctly.

  • Undigging this one but I have a similar problem and hopefully just found a solution.

    Could this work? :

    (considering the "object" object type has an "index" number instance variable, and that there are 5 instances of "object")

    at the start of layout

    Repeat (5)

    pick loopindex instance of object (pick Nth)

    set variable object.index to loopindex

    From now on, you can start using the "index" instance variable as if it where the instance's IID, as it won't change throughout the layout. Not 100% sure that a loop at the start of layout will play... (anyone know?) but if it don't, it could be put in a group that triggers only one.

    I also have another question : is the IID of the first instance on the layout always 0, or, if there are other instances of this object still alive on previous level, would the first instance on the current layout be more than 0?

    And if it could be more than IID 0, is there a way to still give them correct "index" numbering, i.e. : 0, 1, 2, 3, 4, etc...

    This would require to take the instance with the lowest IID and assign the 0 number to its index instance variable, but I have no idea how to do it... Anyone knows?

  • I can't believe it ! It's working like a charm ! Thank you so much !!

  • Hi everyone,

    I need some object instances to act differently. They behave exactly the same, even though I put a lot of random number on them.

    For example :

    wait 1+random(4) seconds

    All instances will always wait the exact same amount of time. Is there a way around this, and making the instances actually wait each one a different random time?

    Thanks a lot !

  • Thanks for the (very !) quick reply, DuckfaceNinja.

    1) Ok, I guess I'll continue with different object types. I thought I read somewhere that the game has to load each sprites for each different object types, even if the sprite used were the same. Is it true? If it is so, using object instances seems a better solution but I just can't find a way to make them do what I want and selecting the right one easily.

    2) I should have specified that I'm already using event sheet includes for my character (as well as enemies). The first solution you propose ("Put the mechanic in separated event sheet. While storing unique variables/event in the layout event sheet.") seems not useful in my case, as nearly every event refer to a specific enemy name, thus making it not worth using includes. I'm sorry but I don't really understand your second solution. Is it something to change in the project properties or the preferences? If so, I don't see where... Could you tell me more?

    I also tried to regroup my enemies into families, but it didn't really helped so far...

    Among solutions I tried to find, I thought about creating 4 global variables "E1", "E2", "E3" and "E4" and changing the value of the variables at the beginning of each level. For example : global variable E1 = "ninja1", E2="ninja2" for the first level and change the values to "warrior1" and "warrior2" in the second level, then replace the "ninja1" object by E1 in the character event sheet, hoping it would select different object types... But it don't seem to work... Maybe this is just not possible.