AllanR's Recent Forum Activity

  • Lerp would certainly work, although it might be easier to just calculate a scale factor...

    if the top of the screen is 0 and the bottom is 800. And you want it to be full size (100%) at the bottom, and say 10% at the top then: (whenever you change the y value)

    sprite > set scale to Sprite.Y/800 * 0.9 + 0.1

    if the screen bottom is 1024 and you want it to be 20% when at the top:

    sprite > set scale to Sprite.Y/1024 * 0.8 + 0.2

    You would also want to adjust the speed as it shrinks to help sell the idea that it is moving away from you...

    EDIT: ok, just read your post again, you mention that there would be a set point where it would be full size... so you want to clamp it

    at the top of screen set it to 10% and at y=500 and below have it at 100%:

    sprite > set scale to Clamp(Sprite.Y/500 * 0.9 + 0.1, 1, 0.1)

    clamp will now prevent it from getting bigger than 100%, or smaller than 10%, so it will stay 100% between 500 and the bottom of the screen, but will scale smoothly towards the top of the screen once y is less than 500...

  • corlenbelspar

    adding variables to objects is a great way to do things. Variables take up very little room. The graphics, sounds, music take up a lot more memory.

    Try exporting and running to see if that takes an acceptable amount of time to start, and compare that to a preview.

    Or try running the debugger and see what is slowing things down.

  • maordany

    It gets surprisingly complicated. There is no pre-built scroll bar, so you have to make your own. I just happened to make one recently, so I thought I would share a simplified version of it.

    This version scrolls the whole layout (with a tall picture on it). You need a top layer that contains the scroll bar, and doesn't scroll with the rest of the layout (set its parallax to 0,0). It automatically adapts to the layout, so if you change screen dimensions and it will snap to the right side of the screen, and position and resize itself.

    You can change the speed at which it scrolls by changing the ScrollSpeed instance variable in the ScrollBar sprite. You can also change the ScaleSize to make it appear bigger or smaller if necessary. This version only works with a mouse. Touch adds more complexity - like how do you properly handle multi-touch, do you want to pan around, pinch to zoom, etc...

    If you were wanting a scroll bar to scroll an image inside a window on the layout, without scrolling the whole layout, that gets even more complicated. Then you need a whole separate layer for that, then need to mask off the parts to not show...

    Hopefully, this will get you started.

    http://www.rieperts.com/games/forum/Scroll.capx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Awesome! Thanks Ashley!

    A higher-res sprite font scaled down to half size looks much better (sharper) than a smaller sprite font at 100% - at least with small point sizes.

    And then one font can easily do multiple sizes - 50% for small, regular text, 100% for headings, and 150% for titles.

    Although I am eager to try the new web fonts in C3...

  • pcprice76

    There are a bunch of ways to make it do what you want... it depends on how complex your project is. If there is a lot going on, and you want to pause all that and enter a different state, then you would want to put code in different groups and disable groups you don't want running. (that would disable the sprite that creates the m.Glass one, so you don't have to worry about it processing a tap).

    The most simple way is to just make sure the m.Glass sprite is not overlapping the other sprite. I made a quick example of that...

    http://www.rieperts.com/games/forum/Tap.capx

  • rotacak

    99Instances2Go suggestion should work fine, another way would be to add a second condition to the big sprite click that says "mouse not over small spite"

    so:

    IF small sprite is clicked: add score

    IF big sprite is clicked AND mouse not over small sprite: decrease score

    (You do a "not over" condition by adding another condition that says Mouse Over object, and then right-click that and invert it)

  • Problem Description

    When a Spritefont is scaled down (to 0.5 for example), character spacing changes slightly as the text changes. On the same line you often get the same letter spaced differently. I made a line of text with the word "this" repeated several times. Sometimes the i was closer to the h and sometimes it was closer to the s.

    At full scale it works fine. Adjusting character widths only made things worse because there was no way to predict how letters were going to get spaced. Using a smaller spritefont at a scale of 1.0 spaced properly, but was too blurry. The larger spritefont scaled down was much sharper, but inconsistently spaced.

    It looked like a rounding issue to me, so I went digging in the Spritefont plugin and commented out two lines where the x value was being rounded. That seems to have fixed the problem, and now looks just how I was hoping. I know it is a really bad idea to change official plugins, and I don't want to make my own spritefont plugin (and I am not sure this was the best solution).

    The lines I changed are:

    if (angle === 0)
    {
    // roundX = Math.round(roundX);
       roundY = Math.round(roundY);
    }
    [/code:12m67hdp]
    
    in the instanceProto.draw and instanceProto.drawGL functions.
        
    [b]Attach a Capx[/b]
    [url]http://www.rieperts.com/games/forum/spritefont_bug.capx[/url]
        
    [b]Description of Capx[/b]
    the capx has two lines of text - with the same spritefont. One line is at a scale of 1.0, the second at a scale of 0.5
    Then ever 2 seconds a period is inserted at the beginning of each line, to show how the spacing changes for various letters in the scaled line of text. Letters that were closer to one side seem to jump to being closer to the letter on the other side.
    
    [b]Steps to Reproduce Bug[/b]
    [ul]
        [li] set the spritefont scale to less than 1.0[/li][/ul]
        
    [b]Observed Result[/b]
    notice how letters shift as the line changed, and the periods are not evenly spaced either.
        
    [b]Expected Result[/b]
    expect character spacing to be consistent regardless of the scale.
        
    [b]Affected Browsers[/b]
    [ul]
        [li] Chrome: (YES)
        [/li][li] FireFox: (YES)
        [/li][li] Internet Explorer: (not tested)
        [/li][li] Edge: (YES)[/li][/ul]
        
    [b]Operating System and Service Pack[/b]
    Windows 10
        
    [b]Construct 2 Version ID[/b]
    r242
  • pcprice76

    I was dealing with a similar mouse issue last night - I was doing something when the left mouse button was clicked on an object. But I was also doing something while the left button was down in another fuction. Out of curiosity, I put a counter in that button down function, and it was getting called on average 9 times along with the first routine. And that was just a normal short mouse click.

    Things generally happen a lot quicker than you think. I bet C2 thinks your "touch" event happens for quite a few ticks. On the first tick of the touch it creates the m.Glass, then the next tick thinks you are touching the m.Glass. so starts running that code. The 0.01 second delay may not be long enough.

    Another issue I ran into months ago is that a tap on objects that overlap registers as a tap on all of them. So, you need to make a way to disable the first sprite while the m.Glass sprite is visible. Then re-enable it when you destroy the m.Glass one. Making the first sprite invisible will not work - the tap will still be processed for it. you have to disable the events where it processes the tap, or move the sprite off screen, or add conditions that say not to process the tap if the m.Glass sprite is overlapping or visible.

  • ikazuchi

    The reason you can't pick the new instance inside the function is that C2 does not complete creating the new instances until the next top level event. (That is why you can outside the function - because it is in a different top level event.

    Inside the function you can continue to access the new instance in sub events, under the one that created it. So, you could add a sub event inside the for loop that says if numberDisplay.display_number=1 then set Text to "A"

    Since you try to pick the instance outside the loop, but before a top level event, C2 has not added the new instance into its internal indexes and can't find it.

  • resdesign

    The Z-order is the Tab index. You can change the controls' z-order as you require, and that sets the tab index,

  • well, that was an entertaining thread

    AndyRevenko

    Thought I would add another example...

    Like gameglaux said (maybe a little poorly), if you don't want the single tap code to execute, you have to add a delay and wait to see if there is going to be a double-tap. After a short delay, if there has not been a double tap, then you can execute the single tap code. The single tap event will always fire, so you have to come up with a method of waiting. The double tap event does fire if there are two quick taps on the sprite.

    I took up gameglaux's challenge and make a capx where you single tap to destroy a sprite, or double tap to make it flash. It took 4 events (plus two to spawn a new sprite to try again).

    http://www.rieperts.com/games/forum/TapDoubleTap.capx

  • AndyRevenko

    You can add another condition to the tap on background to say "Touch is not touching player"

    (you do that by saying "Touch is touching Player" and then Invert that).

AllanR's avatar

AllanR

Member since 21 Nov, 2013

Twitter
AllanR has 23 followers

Trophy Case

  • 10-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • Forum Hero Made 1,000 posts in the forums
  • Popular Game One of your games has over 1,000 players
  • x2
    Coach One of your tutorials has over 1,000 readers
  • Regular Visitor Visited Construct.net 7 days in a row
  • Steady Visitor Visited Construct.net 30 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

19/44
How to earn trophies