Guizmus's Forum Posts

  • TheNewGuy

    More tree part ?

    If you mean a higher tree, no problem.

    If you are looking for a tree with horizontal branches too, it should, you will have to create a "branch" sprite, and spawn it randomly every 3 successful growth for example.

    There is no need for any more sprite that this for the tree, as the tree can always be separated in 3 parts : the base, the middle and the top (top and middle being the same sprite : "treePart")

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You got me interested but the plugin package don't work on r135 it seems, I can't test it :/

  • TheNewGuy Here is a capx example.

    Click on the ground to spawn a seed, it will then grow. 5 events. You can change speed and height with the globals.

    capx

  • Let's see...

    You could have something like this :

    globals :

    • treeGrowingTick
    • treeMinHeight
    • treeRandomHeight

    treeBase sprite :

    • isActive (boolean, true on create)
    • currentHeight (int, 1 on create)
    • targetHeight (int)

    treePart sprite :

    • treeBaseID (int)
    • initial frame is the top of the tree

    TreeSpawning :

    • spawn a "treeBase" sprite,
    • set targetHeight to round(random(treeRandomHeight)+treeMinHeight),
    • call "treeActualise"(treeBase.UID)

    on Function treeActualise,

    Pick treeBase by UID,

    if treeBase.currentHeight < treeBase.targetHeight

    Pick TreePart by comparaison (treeBaseID = treeBase.UID):

    • wait (treeGrowingTick)
    • set TreeBase frame to something more suitable
    • set treePart Frame to the middle of the tree
    • Spawn treePart at X=treeBase.X, Y=treeBase.Y+(treePart.PickCount+1)*treePart*height
    • set treePart.treeBaseID to treeBase.ID

    on Function treeDestroy (called with the treeBase UID as a parameter, making the tree base a good candidate for a "HP" variable ^^)

    Pick TreePart by comparaison (treeBaseID = treeBase.UID):

    • spawnLoot
    • treePart.destroy
    • treeBase.destroy

    As you can see TheNewGuy , I've written this directly on the forums, didn't test it. I hope it does the trick :)

  • In the Array Plugin, both IndexOf and LastIndexOf take only 1 argument : the value to search for, and I'm sorry to say there isn't, in the official implementation, a way to get the result of a search starting from the Nth index.

    Anyhow, if you don't know how many items will have the searched value, there is no use of having a list of all the index. Why ? Because to use them, you would have to do a forEach on the list/array. Why not just do a simple forEach on the first array, and do the full iteration only when the value matches what you are looking for ?

    Regarding the "too far" consideration, just know that C2 Arrays use javascript arrays to stock datas. Having a big array isn't a problem, as long as the total sum of the datas weight isn't excessive. Having 5k names isn't a problem. Having the base64 code of 100 pictures is. It all depends on how much data is in the array. Arrays are optimised since V8 for very fast access and writing, so lots of elements don't seem to be so problematic now. (more on this here)

  • Simpliest way I see is to set up 2 local variables in the ForEach loop, and saving at the end of each iteration X and Y of the new Leader_Flags.

    You can also pick the last created instance of LeaderFlags, but it won't be the best to manipulate...

  • Hey !

    I wanted to help, but having the free version limits blocked me in the debug process. I think the problem comes from the event "every tick -> set animation to check from the beguining". If I was the computer, I would put the first frame every tick because of this.

    I think you should create a function for this, function taking only few params : animation name, UID of the player (or not, you have only one), ... and call this function instead of setting "check".

  • The global question, "add behavior at runtime", has a simple answer : no, at least impossible right now with C2. In most case, behavior can be enabled/disabled, but not in your particular case.

    I see only 2 ways of doing this, both requiring maybe quite some implementation, depending on your project/project size.

    The first one would be to use families, and have 2 objects in it : one with the persist behavior, the other without it. You could replace all the occurence of your pseudo-persisting object by the family in the events, and you would have to "transfer" the datas from the persisting object to the non-persisting one (or the other way) when you want to change the persist behavior.

    The second one would be to use the load system. Every object that is savable has a "toJSON" function, letting you store your object in a string. There is also a "loadFromJSON" function. So you would have to remove the "persist" behavior, and save/load at each start/end of layout, depending if you want the object to persist or not.

    I would personally try to use the second options that seems more... implementable whatever the project.

  • Hey !

    There are 3 things that you should do if you want this to work :

    1/ right click on the 6th event (the one with the 4 angle tests), and make it an "OR" block, because as it is, it will only trigger if all the conditions are verified, witch isn't possible.

    2/ You have to have at least 2 animation frames. In the capx you linked, the animation is only in 1 frame !

    3/ If you want to manage the animation frames like this, you have to set the animation speed to 0, or it will play the animation. By default (and in your capx), it is set to 5 frames per seconds. So even if you change the frame to 0 (and if you have multiple frames, cf 2/), if will play the animation to its end, and redisplay the 2nd frame in 0.2s.

    I had more things to tell on your capX :

    • carefull, objects you delete in the layout will stay in the project. You have to delete them from the project file system (the frame on the top right by default in C2)
    • Try to have more meaningfull names for your sprites than "Image5", "Sprite", or "Sprite2", it will help you a lot as your project grows.
    • don't repeat the "rotate" action like this. Imagine you have to change how you rotate in the future, or if you decide that it won't be 1 rotation, but a full animation (rotation speed, acceleration, blink when rotating, ...). You would have to do the "rotation" feature 4 times (or more if you use other controls). Instead, call a "function" witch will perform the rotation, like this :

    <img src="http://guizmus.fr/captures/c2/aide.JPG" border="0" />

    I didn't change the way you capture the inputs, but you'll notice that this way let me move the "resize the white sprite" event inside the function, instead of being performed every tick. This is of no impact in a test like this, but in a project, try to evaluate the least possible number of things every tick, this is the best way to keep your framerate around 60fps.

  • Hey,

    Nice original case :)

    The question is about the method to store, yes, but mostly access the data.

    The text storage you are using is fast, and you should keep it in my opinion, for low number access (1-100/sec).

    If you need to pull a lot of data at once, like a thousand names in a tick, I would try to go for a database. SQL could help select the right names, and give you back a list in the same format (1 name per line) but you could just use ALL the names, and not seek the first, then the second, ... effectively speeding the algorithm a lot. (explode is a lot faster than 1000 seek ^^)

    But isn't there another way to use/reuse the names ? Why do you have to pull thousands of names at a time ? Could you imagine load those 1k names over 1 to 2 seconds, displaying a loading bar during this ?

  • There isn't any "join capx" function that I know of, mostly because it would be impossible in the generic case (how do you merge 2 layouts ?

    Best way to do it though is to open both capx in C2 (same instance of C2 of course), copy all the missing object from the first capx to the second one, copy/paste all events (or import event sheet), and do the same for the layouts. This will let you choose how the merging should be done.

  • set Angle is quite simple to understand.

    When you have a sprite selected, you see handles to resize it, and also a center point, with a handle on its side, to rotate the sprite. Basic orientation is 0�.

    If you set another angle on the sprite, it will rotate around its center, the origin point, witch you can change in the animation editing interface (dbl click on the sprite). Be carefull, there is a different center for each frame of each animations !

    How to implement the mats in C2 ? Depends how your "car" is built. If it's, let's say, 1 sprite for the body of the car, and 1 sprite per wheel, you should put those in a container.

    In the event sheet, I would create a function "car.move" (with a direction and a speed maybe ? Everything depends on your implementation). In this function, I would put some action on the car wheel sprite, "set angle to dt*car.speed*360/(3.1415*Sprite.width) + wheel.angle". Of course, you would have to change car.speed, Sprite.width and wheel.angle with the right variables, depending on the name of your objects and the behavior you use to move the car (how the speed is store)

  • You know, you should try the help people give you, especially when they are the developers of the program you are using.

    Just read this, as Ashley suggested.

    Timescaling

    A really cool feature in Construct 2 is timescaling. This allows you to change the rate time passes at in the game, also known as the time scale. You can set the time scale with the system Set Time Scale action. A time scale of 1 means normal speed. 0.5 means half as fast, and 2.0 means twice as fast. If you set your game's time scale to 0.1, it's going ten times slower but still smoothly - a nice slow-motion effect!

    Timescaling works by changing the value returned by dt. This means behaviors are affected, and any movement using dt. If you don't use dt in your movement calculations (like the first event above) the motion is not affected by the time scale! So to use time scaling, you simply have to use dt properly in all movement.

    Pausing

    You can set the time scale to 0. This stops all motion. It's an easy way to pause the game. Set it back to 1 and the game will resume.

  • Let's do some maths then !

    Length = Pi*Sprite.width*rotation(in �)/360

    So if you have the distance (dt*speed), then you have the rotation :

    Rotation = dt*speed*360/(Pi*Sprite.width)

  • rexrainbow

    I know creating copies of a built-in plugin or behavior is bad, I don't suggest you do it at all, but you know this a lot better than me.

    I spent some more time inside this plugin code though, and I don't see any way of doing what you describe with the core plugin without adding any javascript.

    Of course, creating a "text_ext" behaviour that would overwrite the draw function could do the trick too, but I have hard time finding a good way to store texts and color in the behavior parameters.

    There seem to be another way though, by creating a plugin that would automatically create N text objects and manipulate himself, each text object being of one color only. This would require, for what I know, to link the 2 object types at the start of the layout (a little like this plugin) so the "multicolored text" would know what to create. This could be impossible to propagate the Pin behavior though, no idea, you may know better.

    Sorry if this didn't help, I tried my best ^^