randomly's Forum Posts

  • Here you go.

    (I just used cjbruce 's code, nothing fancy)

    Btw, in case you didn't know, the % in divisions is the so called modulo operator.

    In returns the rest of a division.

    An example: 5 modulo 2 (5%2) would return 1, since you can put the 2 two times in the four, but you'll have one rest.

    12 % 5 = 2,

    66 % 10 = 6

    and so on.

    This is especially useful here, but generally useful, if you want to see whether a number is dividable by another number.

  • Found this to be an interesting challenge.

    It's just a basic version and it might contain bugs, but it mostly works as intended.

    The actual challenge was the win-detection algorithm.

    Here is the download to the .capx.

    It is by no means perfect, there are many ways to make the win-detection algorithms faster and more effective.

    Two things that I thought of:

    • The Array search area can be reduced to a 5x5 square with the last inserted coin as the center. There is no possible case where you insert a coin and win with a combination that is outside this area.
    • The check for vertical combinations should not check above the last placed coin since you can't place new coins under already placed ones.

    These features are easily implementable, but I didn't have the time to put them in.

    Hope this helps.

  • Thanks for the answer, this is actually almost what I ended up doing!

    With the only difference that I'm using this address now:

    https://maps.googleapis.com/maps/api/browserlocation/json?browser=chromium&sensor=true

    It seemed more accurate to me.

  • Thanks for explaining your project!

    Sooooo, the way I would do it, is this:

    Since Construct 2 comes with no built-in way to export the content of a Sprite, I'd recommend using this plugin.

    It comes with has two important things:

    • An .imageUrl expression that returns the image
    • The action Load image that works similar to the Load from image URL in a Sprite, thus, accepting what has been returned by the .imageUrl expression

    Now, how do you use this for your project?

    The first steps stay the same.

    When taking a photo, you simply load the Paster object with the image from the photo and so on.

    Now, the important part: Saving all the image boards, plus text.

    I would use an Array for this, where each line represents a board and each column stands for different parts of one board, e.g.

    • picture1, containing the imageUrl of the first image, same for picture2, just for the second pic.
    • firstTxt, containing the subtitle for the first pic
    • ThenTxt, subtitle for last pic
    • timer, containing the initial time

    You see where this is going.

    When creating a board, I would give each important object a value representing its board index.

    This will be useful when saving, since you can then loop through all the boards.

    In the loop, you fill the Array, using the loopindex as the Y index in the Array.

    When the loop is complete, you can export the Array and its contents with the .AsJSON expression.

    I would use LocalStorage to save it.

    If you have any questions, please ask. If I find some free time, I will try to create an example .capx for you.

  • Found this post on the nw.js Github.

    I don't have a clue when it comes to javascript, can anyone make use of this and modify the Geolocation plugin?

  • Use the sine behavior that has a period offset of 0 and use its CyclePosition

    expression.

    You might need to change 90+ to 270- or something equivalent, depending on how your player Sprite is oriented and whether you are rotating clockwise or counter-clockwise.

  • You could also use Wait 0 seconds, should have the same result.

    If you're interested in the reason why this action might be needed in some cases:

    When an object is created, it sometimes needs a frame to "prepare itself".

    During that time, you can set e.g. parameters or coordinates, but the object isn't interactive yet, thus can't be affected by other plugins/behaviors.

    To give an example, the Text object expression Text.TextHeight doesn't return the correct height in the same frame as setting the text.

    This means, when you change the text and put an action underneath that, calling the .TextHeight expression, it will not return the correct number.

    But if you put a Wait dt seconds in between, it will work.

    So, if you have an issue like this again, where an object just doesn't seem to react or an object expression doesn't return what it should, you might wanna wait a frame.

  • I created an example .capx for you.

    Hope this helps.

  • You can

    That highly depends on your app.

    What do you mean by "Picture boards"?

    Are they just Sprites with different content?

    If it's as simple as that, you can create a dictionary and save the Dicitonary as JSON in a LocalStorage key.

    The advantage of LocalStorage is that you can have multiple Save slots, all renamed individually.

    But to really help you, I will need more information from you.

  • If I understand you correctly, please do this:

    Create this Function:

    Whenever your money or the price of a tower changes, execute this function.

  • Cannot read property 'ApplyLinearImpulse' of null

    Judging from this, it sounds like the action is trying to apply an Impulse on an object that doesn't exist.

    Since you said that the error occurs when you are in a different layout than the one the game saved before:

    • Can the object that you are applying the impulse to be destroyed?
    • What kind of object is it that you are applying the impulse to?
    • What physics type are you using? Did you try to change it? (Project properties -> asm.js/web

    Can you also try to put a "Wait dt seconds" before you apply the impulse?

    If all this doesn't help, you can try to save the object's status' in an Array and save the Array as JSON in LocalStorage.

    This will, of course, be a very tedious thing to do, but if it's the last option, you might wanna do this instead of leaving the error in your game.

  • Hi rexrainbow

    Don't know whether this is intentional or not, but your app recently stopped showing descriptions.

  • You can either use the System action Scroll to: Player.X, Player.Y, every tick

    or

    You can apply the Scroll To behavior to your Player

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • We will definitely need your project .capx or at least a shortened version of it to reproduce the possible bug and to help you with this.

    I am positive though that it is no bug and just a line of code that needs to be changed.

  • You can always use this workaround:

    - (Condition) Is touching object [Button][/code:2p05s6u7]
    If you are using the mouse, you can use this:
    [code:2p05s6u7]- (Condition) Mouse is over object [Button]
    [ul]
    	[li](Condition) Left mouse button is down[/code:2p05s6u7][/li]
    [/ul]
    Also, a little side note:
    
    

    "System - Every tick + Touch - Is touching (Sprite) > Player - Move 5 pixels at angle 90"

    You can remove the Every tick condition, see why here.

    Also, one last thing:

    If you're asking questions that are specific to your project, try to always attach a .capx of your project.

    It helps the community to understand your problem better and thus, it helps you to get a faster and better response.