cykod / Quintus

HTML5 Game Engine
http://html5quintus.com
GNU General Public License v2.0
1.41k stars 401 forks source link

Scrollable Container with a scrollbar (Feature) #143

Closed NikunjShah closed 9 years ago

NikunjShah commented 9 years ago

To create a container which can have a text or blocks which can be scrollable. Examples -
1) Like a instruction screen displaying the instructions. 2) Objective screen 3) Achievement screen displaying all the achievements

viki53 commented 9 years ago

Have you tried using HTML elements? They're basically the easiest solution for that kind of use…

NikunjShah commented 9 years ago

I have used the UI.HTMLElement but it does not provide me the functionality. If you are talking about pure HTML elements there is a issue with embedding it into the canvas element and that particular scene.

So if any suggestions do provide.

viki53 commented 9 years ago

What's the problem with UI.HTMLElement? They should be scrollable (or at least easily styled with a bit of CSS)…

NikunjShah commented 9 years ago

I am not able to add any HTML in the UI.HTMLElement , I am not able to see anything on the scene.

viki53 commented 9 years ago

Then you must be using it wrong… ;)

What's your code like?

NikunjShah commented 9 years ago

Here is a scene which I have created to test it out.

Q.scene('Test', function(stage) { var container=stage.insert(new Q.UI.Container({ x:Q.width/2,y:Q.height/4,fill:"rgba(0,0,0,0.1)" })); var label = container.insert(new Q.UI.HTMLElement({html:"

Nikunj is trying ;)
"})); });

Any suggestions.

viki53 commented 9 years ago

You shouldn't be inserting HTML into a container (or any canvas-base object) : the HTML element won't be added to the scene but next to the canvas.

Look at the code to see what it looks like: https://github.com/cykod/Quintus/blob/master/lib/quintus_ui.js#L590

Try this:

var label = new Q.UI.HTMLElement({html:"Nikunj is trying ;)"}); // A div is added next to the canvas
label.el.style.position = "absolute"; // You need to position it
label.el.style.top = "0";
label.el.style.right = "0";
label.el.style.left = "0";
label.el.style.backgroundColor = "#f00"; // Add some color to make it (really) visible
console.dir(label);
NikunjShah commented 9 years ago

Yeah it works now I just need to make it overlap with my canvas scene. I will try that out with some CSS.

Thanks :)