In XNA I've created a note sequence, and I'm trying to get the item to be drawn to the screen at a certain time? my check for this is a simple int that gets updated as the gametime does Convert.ToInt64(time)
is the code for that. However the only problem I got was it seemed that it kept drawing it which made the note lag? Could somebody please help?
Create a global variable that check if you draw it or not.
Once you draw it make it true.
In the update, do:
if(!variable&&time>"yourtime")
...
Related
I'm learning webgl2 from https://webgl2fundamentals.org. I'm learning about instancing right now. I can get the demo to work, where it draws many crosses, and I can get it to work with 500 instances.
But I cannot add anything else to the scene. I have a simple triangle that renders fine without the instancing, but with the crosses added the triangle disappears. I believe it has to do with gl.vertexAttribDivisor. I'm not sure when I need to call it, or if I need to undo it somehow.
If I omit calls to vertexAttribDivisor, the crosses don't render correctly, but the triangle is fine. If I replace the call to vertexAttribDivisor, the triangle disappears.
When do I call gl.vertexAttribDivisor? Do I have to undo the call to resume normal, non-instanced rendering? What does it really do?
The vertex attribute functions change a single global state. vertexAttribDivisor sets the divisor for a specified generic vertex attribute (one of the globally available ones), for every draw* call you want to setup the attributes using vertexAttribPointer and vertexAttribDivisor, if you changed the divisor for an attribute for one draw call but don't want to use the same divisor for your following draw call you need to reset it.
I have been struggling with this problem for a time and being unable to solve it led me here. I'm recently new to Actionscript (2.0). I want to do something similar to:
http://gnarshmallow.com/
Were i want something to be painted behind a moving object in real time.
I would like some advice on how to approach the problem.
You need to use line drawing to do this. You will need two points, and it will draw a line from one to the next. I recommend having it run on every movement call. Have it draw the line between the racer's location in the previous frame, and his location in the current frame. For further reference, check out this page.
http://www.actionscript.org/resources/articles/730/1/Drawing-lines-with-AS2/Page1.html
I'm trying to draw lines in Cocos2d using touches.
I had a system where it would just add a small sprite where you touched, but it's working terribly. So I've been trying to find a way to draw actual lines using a method like ccDrawLine, but every tutorial I find seems to leave out something, and I just can't figure it out.
I've found this tutorial, Drawing line on touches moved in COCOS2D but I don't understand a few things about that.
It seems to reference the same variable from two different files, so I don't understand how it's doing that. (The naughtyTouchArray variable)
I can't find a complete guide on drawing lines, so sorry for the codeless question, but I'm getting frustrated.
Thanks.
The answer you've linked in your question provides good solution to your problem. There is no "two different files". Just two different methods of one layer. One method (ccTouchesMoved:withEvent:) handles touches and fill the array of points to be connected to each other one-by-one with lines. From cocos2d documentation, all drawing must be placed in the draw method of the node. So, another (draw) method just draws lines according to the given array. Cocos2d is based on OpenGL and it fully redraws scene every tick, so you cannot just draw new line. You had to draw all of them.
Or any other node can draw your array in it's draw method, so you can simply pass stored array of points from the layer, that detects touches, to this node.
I have worked through the examples of turning on ScissorTestEnable and ScissorRectangle. It works fine. However, when I apply a ScaleMatrix the clipping no longer seems to work. Are these supposed to work together?
You're probably using SpriteBatch, correct? It seems to me that Shawn Hargreaves' comment on this page is probably the answer you're looking for. Have you tried moving the call that sets the scissor rectangle around to see if it starts working? I tried looking at the decompiled sources of Microsoft.Xna.Framework.Graphics - but I couldn't find any relation between GraphicsDevice.set_ScissorRectangle and SpriteBatch's flushing methods. :S
If it doesn't work, you could also try to replace the scale and scissor with a modified projection and viewport call and then render the objects in each player's screen.
I am working on developing a free hand drawing application for the iPad. I have just started out developing the application. I have so far succeeded in capturing the touch points. But, I am unable to render these pixels on the screen.
Are their any particular methods to perform the task? Please help!
Thank You.
Hey Amitabh,I got This while surfing,may be helpful to you. You can get the zip file of the code in the same link,they are implementing freehand tool in the application.
Thanks.
You probably want to maintain a list of points captured and render them to the UIView instance corresponding to your app's canvas. If you want a more detailed answer, we would need a more detailed question (eg, code you have so far, structure of your GUI, etc)
store the last point and use a CGContext to draw a bezier curve (CGContextAddCurveToPoint()) from the last point to the current point. You will probably need to not do this every time the touchesMoved instead make an accumulator.
static int accum = 0;
if ((accum == 0) || (accum == threshold)) {
// drawing code goes here
accum = 0;
}
accum++;
threshold should be an instance variable. You can change the threshold dynamically if you need more precision on curves.