Coder Social home page Coder Social logo

Comments (4)

greenfire27 avatar greenfire27 commented on July 20, 2024 1

So the problem is that the engine picks a different, smaller window size, but still uses 1024x768 for pick point? It sounds like the answer is make sure pick point is using the actual screen size instead of the default screen size. I'll look into it.

On a side note, there is a much easier way to use sprites as buttons. Each individual sprite can have it's own onTouchDown event which can be automatically called when the sprite is clicked. Here's how:

  1. Set your scene to use object input events.
    %myScene.setUseObjectInputEvents(true);
  2. Give your button a class when you create it and have it use input events.
    %myButton = new Sprite { Scene = myScene; class = "StartButton"; useInputEvents = true; };
  3. Create a onTouchDown event for that class (which is technically a namespace).
    function StartButton::onTouchDown(%this, %touchID, %worldPosition) { ... }

I like to have a button superclass that handles onTouchEnter and onTouchLeave so I can give the user a little feedback when the mouse rolls over the button, like growing the button slightly or changing it's frame. Hope this helps!

from torque2d.

ParodyGames avatar ParodyGames commented on July 20, 2024

As a post script, not 100% sure that this is specifically the cause. If I change the default minimum size to be smaller on my laptop, it works fine. However, I tried scaling my dekstop's default size up and wasn't able to reproduce the problem there. I have a workaround by changing the function on winOGLVideo.cc to either return false rather than to try to guess at a workable size or to set it to the screen size if you try to go over, but neither is a really great solution.

from torque2d.

ParodyGames avatar ParodyGames commented on July 20, 2024

Thanks, I'm more used to the old T2D where it was all onMouseDown. I tried to used that when I was first getting started, but I think I was looking at an incorrect note on how to set the attribute.

That being said, I switched over to OnTouchDown and it has the same issue. The clicks do not register in the appropriate location, as I believe it is using the same code to determine what was touched.

from torque2d.

greenfire27 avatar greenfire27 commented on July 20, 2024

Well OnTouchDown is the same thing as OnMouseDown - just renamed - but my point is that you don't need to capture the click on the screen and then try to figure out what was clicked. The engine can do that for you and call OnTouchDown on individual sprites.

from torque2d.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.